到目前为止,我已经查看了 MSDN 大约 2 个小时,但我仍然对如何使用对话框感到非常困惑。我试过在谷歌上阅读几个示例,但感到更加困惑。
目前我有一个弹出菜单,它的选项只是被选中和未被选中,我在菜单上的最后一项是显示一个对话框,在对话框内我将有一个用于一些 radio 的组框按钮,但我不确定在哪里创建对话框或要创建哪种对话框以显示在弹出菜单中。
它是在 WM_CREATE 消息中制作的吗?我认为它可能就像创建一个窗口一样简单,但它看起来并不像它?
或者它是在我触发弹出菜单项的 WM_COMMAND 中创建的。
案例 ID_TOOL_TOOLBOX 是应该调用对话框以显示或创建的地方。但我不确定是否要在那里创建它,甚至不确定要制作什么样的对话框。
还是其他完全不同的地方?
case WM_COMMAND:
case ID_TOOL_POLYGON:
CheckMenuItem(hMenu, Selection, MF_UNCHECKED);
Selection = LOWORD(wParam);
CheckMenuItem(hMenu, Selection, MF_CHECKED);
if (GetMenuState(hMenu, Selection, MF_BYCOMMAND) == MF_CHECKED)
{
MessageBox(hwnd, L"Polygon does nothing this is a test popup msgbox.", L"Works", MB_OK);
}
break;
case ID_TOOL_SELECT:
CheckMenuItem(hMenu, Selection, MF_UNCHECKED);
Selection = LOWORD(wParam);
CheckMenuItem(hMenu, Selection, MF_CHECKED);
break;
case ID_TOOL_TOOLBOX:
最佳答案
这是我们搜索“win32 ShowDialog”时出现的第一个结果:
http://www.functionx.com/win32/Lesson04.htm
A dialog box is created using the DialogBox function. Its syntax is:
INT_PTR DialogBox(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc);
The first argument of this function is a handle to the application that is using the dialog box.
The lpTemplate specifies the dialog box template.
The hWndParent is a handle to the parent window that owns this dialog box.
The lpDialofFunc must a procedure that is in charge of creating this dialog box.
Therefore, you must define a CALLBACK procedure that whose syntax is:
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
关于c - 让弹出菜单显示/创建对话框? Windows32编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13381151/