a non-modal dialog behaviour

i have a main window with text output which does some things, and i need to display a dialog with progressbar indicating some process. well, i create the dialog with CreateDialogParam(), it goes well with one "but": i cannot set focus to this dialog. i tried everything i think: SetActiveWindow(), SetForegroundWindow(), SetFocus() -- nothing helps. the main window still has the focus, it is active and gets all keyboard input, and dialog box draws on top of the main window but is inactive until i implicitly bring it to focus (i.e. clicking on it). i'd like it to be other way around: the dialog to have focus and get all input. well, of course i can check this state in main window's message processing and shred all keyboard input but i think it will be a kludge. there got to be more elegant way. can anybody help me with this? :)


  • Are you including IsDialogMessage in your message loop?

    Something like this, (hWndDialog is the dialog window handle, say initially NULL and then some value when its created):

    while(GetMessage(&msg, NULL, 0, 0) != 0)
    // if we have dialog, call IsDialogMessage instead, this
    // will check and process the message if its meant for the dialog
    // and return a non zero value
    if(hWndDialog == NULL || IsDialogMessage(hWndDialog, &msg) == 0)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion