Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3609926
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:41:20+00:00 2026-05-18T21:41:20+00:00

I’m writing an application following this tutorial . I’m aware that this tutorial dates,

  • 0

I’m writing an application following this tutorial. I’m aware that this tutorial dates, and as such, I have adapted the code to take into consideration the unicode.

I have a main window which looks like an MDI. Then, I have a View menu which toggles a Toolbar dialog as to be shown and hidden.

When I show the dialog, it is displayed, but the PUSHBUTTONs are not displayed correctly. They only appear when I click my main window again.

Plus, I don’t seem to be able to click neither of the PUSHBUTTONs into my toolbar dialog.

The resources (resource.h) are defined as follows (only showing what is relevant to this question):

#define IDD_TOOLBAR              102
#define IDC_PRESS               1000
#define IDC_OTHER               1001
#define ID_VIEW_SHOWTOOLBAR    40002
#define ID_VIEW_HIDETOOLBAR    40003

And the dialog as follows in my .rc file:

IDD_TOOLBAR DIALOGEX 0, 0, 85, 50
    STYLE    DS_FIXEDSYS | DS_MODALFRAME | WS_CAPTION | WS_POPUP
    EXSTYLE  WS_EX_TOOLWINDOW
    CAPTION  L"Toolbar"
    FONT     8, "MS Shell Dlg"
BEGIN
    PUSHBUTTON     L"&Press this button",     IDC_PRESS, 7,  7, 70, 14
    PUSHBUTTON     L"&Or this one",           IDC_OTHER, 7, 28, 70, 14
END

And showing it as follows in my WndProc function:

// As a global variable I have my toolbar handler.
HWND g_hToolbar = NULL;

BOOL CALLBACK ToolbarDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
    switch (Msg) {
        case IDC_OTHER:
            MessageBoxW(hWnd, L"You just clicked IDC_OTHER!", L"Information", MB_OK | MB_ICONINFORMATION);
            break;
        case IDC_PRESS:
            MessageBoxW(hWnd, L"You just clicked ODC_PRESS!", L"Information", MB_OK | MB_ICONINFORMATION);
            break;
        default:
            return FALSE;
    }

    return TRUE;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
    switch (Msg) {
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case ID_VIEW_HIDETOOLBAR:
                    ShowWindow(g_hToolbar, SW_HIDE);
                    break;
                case ID_VIEW_SHOWTOOLBAR: 
                    if (NULL == g_hToolbar) 
                        g_hToolbar = CreateDialogW(GetModuleHandle(NULL)
                                                    , MAKEINTRESOURCE(IDD_TOOLBAR)
                                                    , hWnd
                                                    , ToolbarDlgProc);

                    ShowWindow(g_hToolbar, SW_SHOW);
                    break;
            }
            break;
        default:
            return DefWindowProcW(hWnd, Msg, wParam, lParam);
    }
}

And here’s the way I handle the different messages for my main window and my dialog in my message loop in my WinMain function.

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
    // Declaring, registring and creating my main window to hWnd here...
    MSG Msg;

    ShowWindow(hWnd, nShowCmd);
    UpdateWindow(hWnd);

    while (GetMessageW(&Msg, hWnd, 0, 0) > 0) {
        if (!IsDialogMessageW(g_hToolbar, &Msg)) {
            TranslateMessage(&Msg);
            DispatchMessageW(&Msg);
        }
    }
}

My problem is:

  1. I don’t seem to be able to click on my dialog’s buttons.

  2. When I attempt to click on my dialog’s buttons, my main window becomes very slow to respond to its own messages.

That is, when I want to show my Toolbar dialog as a modeless dialog, because when I show it modal, it works perfectly!

Any clue to solve this issue?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:41:21+00:00Added an answer on May 18, 2026 at 9:41 pm

    The problem is, as DReJ said in the above comment, in my message pump.

    The trouble is that I write:

    while (GetMessageW(&Msg, hWnd, 0, 0) > 0) {
        // Processing message here...
    }
    

    And that I shall write:

    while (GetMessageW(&Msg, NULL, 0, 0) > 0) {
        // Processing message here...
    }
    

    So, because I was getting the messages for a given window, the hWnd instance, my ToolbarDialog seemed to lack of time to draw itself completely or something like it. Replacing hWnd for NULL in that scenario solved the problem entirely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have some data like this: 1 2 3 4 5 9 2 6
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.