Archived

This topic is now archived and is closed to further replies.

Xtremehobo

Dialog Boxes

Recommended Posts

#include "stdafx.h"
#include "resource.h"

const char AppName[] = "MyProg"; // the name of our program


HINSTANCE hInst; // a place to save our instance

				 // handle, which we may need later.


LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// Init Dialog Box


	hInst = hInstance; // save our instance handle

    DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC) DlgProc); // start the dialog box

    
	return TRUE; // success


	return 0;
}

LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
                                                                                                                           // the dialog procedure

{
     switch(msg)
              {
               case WM_INITDIALOG: // our dialog is being shown

                          MessageBox(hwnd, "Received WM_INITDIALOG message", AppName, MB_OK | MB_ICONINFORMATION);
                          break;

               case WM_COMMAND: // we got a message from a control/menu

                                                       // in this case, a button

                       switch(LOWORD(wParam))
                                        {
                                          case IDC_STARTBROADCAST: // the '&Click Me' button

                                                   MessageBox(hwnd, "Start Broadcast!", AppName, MB_OK | MB_ICONINFORMATION);
                                                   break;

                                          case IDC_ENDBROADCAST:     // user pressed either exit, the X on the top

                                                                           // right, or used ALT+F4

                                                   MessageBox(hwnd, "End Broadcast! Cya!", AppName, MB_OK | MB_ICONINFORMATION);
                                                   EndDialog(hwnd, FALSE); // our job is done, goodbye dear dialog

                                                   break;
                                        }
                       break;

                case WM_DESTROY: // dialog is off the screen by now

                          MessageBox(hwnd, "Received WM_DESTROY message, time for clean-up...", AppName, MB_OK | MB_ICONINFORMATION);
                          break;

                default: // all the messages we don't handle

                           // are handled by Windows


                return FALSE; // this means we haven't processed it

                }
     return TRUE; // this one means we have processed the message

}


How come whenever I start my app (using that code) I immedietly get the "WM_DESTROY" message? Thanks EDIT: btw, I never recieve the WM_INITDIALOG message :- [edited by - Xtremehobo on July 28, 2003 6:04:08 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i probably know the answer but this is still for that DoS app isn''t it? so go away.

Share this post


Link to post
Share on other sites
....I was never making a DoS app....
EDIT: Thankyou for crapping on my thread. If you're not going to help, just don't post at all.

[edited by - Xtremehobo on July 28, 2003 6:05:53 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
my apologies. it was just a mass spammer via net send wasn''t it? i''m referencing the http://www.gamedev.net/community/forums/topic.asp?topic_id=170117 thread in which you were not only called on making a spammer tool but also called "evil."

anyway, what do i care about the poor saps you''re about to inflict pain upon? do you have any common controls, e.g., listview, treeview, spin control, ip control, etc., on the dialog resource? if so you need to call InitCommonControls before displaying the dialog box.

Share this post


Link to post
Share on other sites
Sorry for gettin a little angry, and thanks for the help (Works now )
Yes indeed, it was for a mass net send application, but I never finish these thigns, and although I may play around with it a little (heh), my main goal here is just to finally finish an app that actually works.

Share this post


Link to post
Share on other sites
er, actually, it just shows the controls.. superimposed over the rest of my screen.. no dialog box background :-EDIT: w00t I fixed that too

[edited by - Xtremehobo on July 28, 2003 7:25:48 PM]

Share this post


Link to post
Share on other sites