The modal dialog box problem

This is a discussion on The modal dialog box problem within the Windows Programming forums, part of the Platform Specific Boards category; It's a problem i don't know how to get around When I create the modal dialog box, the owner window ...

  1. #1
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186

    The modal dialog box problem

    It's a problem i don't know how to get around

    When I create the modal dialog box, the owner window (main application widnow in my case) no longer receives any messages instead, the modal dialog box's message loops begins, so all the drawings I did in WM_PAINT no longer get drawn and I get an error.

    The reason of this error i think is that since the window isn't getting any messages, the HDC in it isn't valid any more and that's why i get an error for the drawings in WM_PAINT


    is there any function to freeze a window? to keep it in an idle state with all the information in it and receive no message until an opposite function is called ?

    If i can do this, I will call this function before creating the modal dialog so i wont get the error of drawing



    P.S.: Message boxes also cause the same thing, because there are also modal dialog boxes
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,853
    Post you drawing code for the main window. It could be an error there. Are you using a memory DC?

    You could also use a modeless dialog (as you don't state the need for modal).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    there is no error in drawing because without the modal dialog box it goes completely normal

    this is my drawing code.... i don't think there is any point in this because it's flawless and i'm sure of it as i stated above

    Code:
    HDC               hdc;
    PAINTSTRUCT ps;
    
    case WM_PAINT:
          hdc = BeginPaint(hwnd, &ps);
          pGame->draw_game(hdc);
          EndPaint(hwnd, &ps);
          break;
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  4. #4
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    little update. i tried to cancel the WM_PAINT and do the drawing by GetDC and ReleaseDC

    but the same thing happens ;(
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  5. #5
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    any help ;( ?
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,853
    My modal dlgs do not have any issues with drawing, nor do thier parents.


    You have not been descriptive enough in your original question nor have you posted code.

    Your paint references a non standard function. I have no idea if this is failing.

    You may not be using a memory DC.

    I can see you have an un-optimised paint function that will slow your app down (you paint the whole screen even if only a tiny area needs a repaint).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dialog Box error
    By JJFMJR in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2007, 07:51 AM
  2. Parent of a BrowseForFolder dialog box
    By @nthony in forum Windows Programming
    Replies: 4
    Last Post: 01-08-2007, 01:54 PM
  3. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  4. edit control in dialog box problems
    By Bajanine in forum Windows Programming
    Replies: 11
    Last Post: 11-11-2002, 05:55 PM
  5. Dialog Box Problem....
    By minime6696 in forum Windows Programming
    Replies: 2
    Last Post: 01-08-2002, 07:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21