質問

I have been trying to get my program to display different modeless dialog boxes when different menu items are selected. So far I am only working on displaying 1 but I am unable to get this working.

When I run my code I can see the main window losing focus but the about dialog box is not being displayed.

HWND g_hToolbar = NULL;
HWND hDlgCurrent = NULL;

int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR    lpCmdLine,
int       nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

MSG msg;
HACCEL hAccelTable;

LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_GUIAPP, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);

// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
    return FALSE;
}

while(GetMessage(&msg, NULL, 0, 0) > 0)
{
    if(!IsDialogMessage(g_hToolbar, &msg))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}
return (int) msg.wParam;
}

Here is the code for my about box:

INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{

UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_CREATE:
    g_hToolbar = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUTBOX),
        hDlg, ToolDlgProc
        );
    if(g_hToolbar != NULL)
    {
        ShowWindow(g_hToolbar, SW_SHOW);
    }
case WM_INITDIALOG:
    return (INT_PTR)TRUE;

case WM_ACTIVATE:
    if (0 == wParam)             // becoming inactive
        hDlgCurrent = NULL;
    else                         // becoming active
        hDlgCurrent = hDlg;
    return FALSE;

case WM_COMMAND:
    if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDOK)
    {
        EndDialog(hDlg, LOWORD(wParam));
        return (INT_PTR)TRUE;
    }
    break;
}
return (INT_PTR)FALSE;
}

Then my Call in WndProc

    case IDM_ABOUT:
        CreateDialog(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);        
        break;

I apologize for pasting such large sections of code in but I am unaware as to where exactly the problem is.

Any help on this would be great!

役に立ちましたか?

解決

This issue has been solved.

The solution is contained in the comments.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top