一些界面编程的问题,恳请各位前辈帮帮忙
问题1:
如何象winamp那样可以在运行时能在任务栏(taskbar)上显示或隐藏,前提是窗体是正常窗体,没有用createwindow
函数的WS_EX_TOOLWINDOW参数,因为此参数能使窗体不在任务栏上显示,问题是如何改变已创建的窗体的
style为WS_EX_TOOLWINDOW,不是formstyle.
问题2:
当点击状态栏(status area)上的图标并使用菜单(context menu)时,如何实现象QQ那样当鼠标点击菜单外的区域
(不包含程序的窗体区域)时能使菜单隐藏,还想问问当鼠标在桌面移动时(不包含在状态栏上的图标)
会不会发送消息(message)给隐藏的窗体?
望各位能给小弟排忧解难.
问题点数:10、回复次数:6Top
1 楼idilent(怎么理解怎么说)回复于 2003-08-03 08:22:13 得分 0
这个问题前面有好多。Top
2 楼viaboy(平凡)回复于 2003-08-03 08:46:13 得分 0
upTop
3 楼wenzy2003()回复于 2003-08-03 17:52:13 得分 0
自己up一下Top
4 楼wenzy2003()回复于 2003-08-04 14:31:26 得分 0
有没有人能提供一些函数?
问题1用setwindowlong函数不能在运行时显示或隐藏,求高手赐教.
问题2鼠标单击桌面时,能不能被application.onmessage收到?Top
5 楼tonylk(=www.tonixsoft.com=)回复于 2003-08-04 14:43:21 得分 10
1。SetWindowLong()
2。状态区图标在收到鼠标消息时,在弹出菜单前,将主form放到桌面的最上层SetForeGround(),可以解决菜单无法正常关闭的问题,但是这个方法我觉得也不爽,你可以试一下用一个隐藏的窗体来处理状态区图标,这样到时候将它放到desk的最上层也看不到,我没试过。Top
6 楼wenzy2003()回复于 2003-08-04 20:10:20 得分 0
问题已全部解决,感谢tony.
1.setwindowlong+setwindowpos
2.bringtofornt函数
to:tony
window API和D7都没有setforeground函数,不过可以用bringtofornt函数代替,隐藏窗体也可实现。
附:msdn中setwindowlong()函数说明:
Platform SDK: Windows User Interface
SetWindowLong
The SetWindowLong function changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory.
Note This function has been superseded by the SetWindowLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Windows, use SetWindowLongPtr.
LONG SetWindowLong(
HWND hWnd, // handle to window
int nIndex, // offset of value to set
LONG dwNewLong // new value
);
Parameters
hWnd
[in] Handle to the window and, indirectly, the class to which the window belongs.
Windows 95/98/Me: The SetWindowLong function may fail if the window specified by the hWnd parameter does not belong to the same process as the calling thread.
nIndex
[in] Specifies the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of an integer. To set any other value, specify one of the following values. Value Action
GWL_EXSTYLE Sets a new extended window style. For more information, see CreateWindowEx.
GWL_STYLE Sets a new window style.
GWL_WNDPROC Sets a new address for the window procedure.
Windows NT/2000/XP: You cannot change this attribute if the window does not belong to the same process as the calling thread.
GWL_HINSTANCE Sets a new application instance handle.
GWL_ID Sets a new identifier of the window.
GWL_USERDATA Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero.
The following values are also available when the hWnd parameter identifies a dialog box. Value Action
DWL_DLGPROC Sets the new address of the dialog box procedure.
DWL_MSGRESULT Sets the return value of a message processed in the dialog box procedure.
DWL_USER Sets new extra information that is private to the application, such as handles or pointers.
dwNewLong
[in] Specifies the replacement value.
Return Values
If the function succeeds, the return value is the previous value of the specified 32-bit integer.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If the previous value of the specified 32-bit integer is zero, and the function succeeds, the return value is zero, but the function does not clear the last error information. This makes it difficult to determine success or failure. To deal with this, you should clear the last error information by calling SetLastError(0) before calling SetWindowLong. Then, function failure will be indicated by a return value of zero and a GetLastError result that is nonzero.
Remarks
Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly.
If you use SetWindowLong with the GWL_WNDPROC index to replace the window procedure, the window procedure must conform to the guidelines specified in the description of the WindowProc callback function.
If you use SetWindowLong with the DWL_MSGRESULT index to set the return value for a message processed by a dialog procedure, you should return TRUE directly afterwards. Otherwise, if you call any function that results in your dialog procedure receiving a window message, the nested window message could overwrite the return value you set using DWL_MSGRESULT.
Calling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. The SetWindowLong function creates the window subclass by changing the window procedure associated with a particular window class, causing the system to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures.
Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASSEX structure used with the RegisterClassEx function.
You must not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function.
If the window has a class style of CS_CLASSDC or CS_OWNDC, do not set the extended window styles WS_EX_COMPOSITED or WS_EX_LAYERED.
Windows 95/98/Me: SetWindowLongW is supported by the Microsoft Layer for Unicode. SetWindowLongA is also supported to provide more consistent behavior across all Windows operating systems. To use these versions, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
Example Code
For an example, see Subclassing a Window.
Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.
See Also
Window Classes Overview, Window Class Functions, CallWindowProc, GetWindowLong, RegisterClassEx, SetParent, SetWindowLongPtr, WindowProc, WNDCLASSEX
Platform SDK Release: August 2001 What did you think of this topic?
Let us know. Order a Platform SDK CD Online
(U.S/Canada) (International)
Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.
See Also
Window Classes Overview, Window Class Functions, CallWindowProc, GetWindowLong, RegisterClassEx, SetParent, SetWindowLongPtr, WindowProc, WNDCLASSEX
Top



