Thread: Modeless dialog quits by itself immediatly after creation

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    4

    Modeless dialog quits by itself immediatly after creation

    Hi,

    I am using Modeless dialog in a CAD API program, launching it, it closes immediatly after it is created.

    I am using this two lines to create the dialog.

    MyDialog dlg;
    dlg.Create(IDD_DIALOG_SA,0);
    dlg.ShowWindow(SW_SHOW);


    It just flickers in the sceen, If I show the window, it stays no time. It doesnot call any message functions. Any one knows the reason please suggest resolution.

    Thanks in advance.

    Joseph

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You need to run the message loop (RunModalLoop). It will block until the function closes, but it will not force it to be modal.
    Last edited by Elysia; 05-17-2011 at 07:24 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    Where are you creating this dialog?

    Is sounds like the dialog variable is going out of scope right after the showwindow, meaning the function where the dialog is created ends, killing your dialog variable, therefore no dialog.

    You will need to have a variable for the dialog that will persist longer than the function it is created in.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Regardless, you will still need to pump messages, which you do with RunModalLoop, and it will block, so there is no problem with running out of scope.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    May 2011
    Posts
    4
    Thanks Dave. That worked. I have not used pointer to create dlg, used as local variable

    Thanks for all the replies.
    Last edited by joseph_isreavel; 05-18-2011 at 07:16 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fixing Z-order on a modeless dialog?
    By Viper187 in forum Windows Programming
    Replies: 6
    Last Post: 06-20-2008, 07:10 PM
  2. modeless dialog not interacting with main window
    By scwizzo in forum Windows Programming
    Replies: 3
    Last Post: 08-30-2007, 04:33 PM
  3. Modeless Dialog Communication (MFC)
    By mhandlon in forum Windows Programming
    Replies: 8
    Last Post: 08-22-2006, 01:28 PM
  4. When my modeless dialog has been closed it doesn't open again
    By Frandy in forum Windows Programming
    Replies: 5
    Last Post: 11-21-2004, 08:45 AM
  5. creating modeless dialog
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 03-07-2002, 05:58 PM