Thread: DialogBox Message loop?

  1. #1
    Climber spoon_'s Avatar
    Join Date
    Jun 2002

    DialogBox Message loop?

    I'm making a simple file transfer program to learn winsock, however I have one question. My WinMain function is two lines long. My DlgProc function is big.

    Do I need a message loop?

    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int ShowCmd)
    	DialogBox(hInstance, MAKEINTRESOURCE(IDD_MainDlg), NULL, (DLGPROC)DialogProc);
    	MessageBox(NULL, "Hi", "", MB_OK);
    	return 0;
    Note: That messagebox is just for testing. it doesn't come up until you close the program (even then you don't see it but you hear the 'ding' sound). That leads me to believe I need no message loop?

    survey says?

    {RTFM, KISS}

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    You do not need a message loop because you are not registering a window class and creating a window. You are using a dialog box. You do need a dialog box procedure, but what you have looks fine for WinMain.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    train spotter
    Join Date
    Aug 2001
    near a computer
    I think it is more because DialogBox() creates a modal dialog that does not return until closed (EndDialog() is called).

    If you use CreateWindow() (or the Ex) or CreateDialog() and create a modeless window or dialog then you need a msg loop.

    If using sockets on windows for file transfer I would recomend using WSA and socket msg's. (Which require a loop)
    "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. nested loop, simple but i'm missing it
    By big_brother in forum C Programming
    Replies: 19
    Last Post: 10-23-2006, 10:21 PM
  2. Window message loop (Keys)
    By Blackroot in forum Windows Programming
    Replies: 3
    Last Post: 09-12-2006, 05:15 PM
  3. Message loop not working...
    By Hunter2 in forum Windows Programming
    Replies: 24
    Last Post: 07-03-2003, 02:17 PM
  4. Help, the window gets killed......
    By incognito in forum Game Programming
    Replies: 2
    Last Post: 05-28-2002, 02:22 PM