我在做UI的时候,主界面用了WM_SYSCOMMAND消息,但发现用了之后主界面的菜单没反应了,请问怎么解决?在WM_SYSCOMMAND的处理函数中,我返回了DefWindowProc(hwnd, WM_SYSCOMMAND, wParam,lParam);所以没有其他问题,就是菜单没反应。谢谢。
解决方案 »
- 怎样才能uPNP穿透?
- 高分请教: 关于try...catch错误代码的定位
- 如何在第二个模态对话窗里读第一个模态对话窗口里公共变量?多谢了
- 请问P2P如何进行打洞?
- 在一个线程中建立模式对话框,如何在另一个线程中关闭
- 我在CStatic里的OnPain()里画了一个矩形,可是老是闪!并且按了一下对话框上的按钮之后,居然还消失了!
- 关于在DLL中用EnterCriticalSection出错的问题
- 如何在imagelist加入位图?
- 如何在调用Directx 播放媒体文件的时候,在播放的区域响应鼠标的消息?
- 安装VisualStudio Installer Project失败
- 一个进程执行的问题
- 初学网络编程的通信问题
#define HANDLE_DLGMSG(hwnd, message, fn) \
case (message): return (SetDlgMsgResult(hwnd, uMsg,\
HANDLE_##message((hwnd), (wParam), (lParam), (fn))))int Main_OnSysCommand(HWND hwnd, int wParam, int lParam, UINT codeNotify)
{
switch (wParam)
{
case SC_CLOSE:
EndDialog(hwnd, wParam);
break;
case SC_DEFAULT:
break;
case SC_MINIMIZE:
break;
case SC_MOUSEMENU:
break;
case SC_KEYMENU:
break;
}
// Any WM_SYSCOMMAND messages not handled by the application
// must be passed to DefWindowProc*/
return DefWindowProc(hwnd, WM_SYSCOMMAND, wParam,lParam);
}
//------------------------------------------------------------------------------
// main proc function
//------------------------------------------------------------------------------
int WINAPI MainProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
HANDLE_DLGMSG(hwnd, WM_INITDIALOG, Main_OnInitDialog);
HANDLE_DLGMSG(hwnd, WM_SIZE, Main_OnSize);
HANDLE_DLGMSG(hwnd, WM_COMMAND, Main_OnCommand);
HANDLE_DLGMSG(hwnd, WM_SYSCOMMAND, Main_OnSysCommand);
}
return 0;
}
关键部分只有这些,谢谢~
A window receives this message when the user chooses a command from the window menu (formerly known as the system or control menu) or when the user chooses the maximize button, minimize button, restore button, or close button.WM_SYSCOMMAND
uCmdType = wParam; // type of system command requested
xPos = LOWORD(lParam); // horizontal position, in screen coordinates
yPos = HIWORD(lParam); // vertical position, in screen coordinates
Parameters
uCmdType
Specifies the type of system command requested. This parameter can be one of the following values. Value Meaning
SC_CLOSE Closes the window.
SC_CONTEXTHELP Changes the cursor to a question with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message.
SC_DEFAULT Selects the default item; the user double-clicked the window menu.
SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate.
SC_HSCROLL Scrolls horizontally.
SC_KEYMENU Retrieves the window menu as a result of a keystroke.
SC_MAXIMIZE Maximizes the window.
SC_MINIMIZE Minimizes the window.
SC_MONITORPOWER Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.
lParam can have the following values:1 means the display is going to low power.2 means the display is being shut off.
SC_MOUSEMENU Retrieves the window menu as a result of a mouse click.
SC_MOVE Moves the window.
SC_NEXTWINDOW Moves to the next window.
SC_PREVWINDOW Moves to the previous window.
SC_RESTORE Restores the window to its normal position and size.
SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file.
SC_SIZE Sizes the window.
SC_TASKLIST Activates the Start menu.
SC_VSCROLL Scrolls vertically.