Dialog boxes question

Started by
5 comments, last by Metal Typhoon 21 years, 11 months ago
it includes Menu.h which is
      
#define MENU_OPEN 11
#define MENU_SAVE 12
#define MENU_EXIT 13

#define OPTION_BACKGROUND 21

#define ABOUT 3
#define ABOUT_OK 31
  
My Window procedure is here
  
LRESULT CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
	switch(Msg)
	{
		case WM_CREATE:
			{
				HMENU Menu,SubMenu;
		
				Menu = CreateMenu();

				SubMenu = CreatePopupMenu();
				AppendMenu(Menu,MF_STRING|MF_POPUP,(UINT) SubMenu,"&File");
				AppendMenu(SubMenu,MF_STRING,MENU_OPEN,"O&pen");
				AppendMenu(SubMenu,MF_STRING,MENU_SAVE,"S&ave");
				AppendMenu(SubMenu,MF_STRING,MENU_EXIT,"E&xit");
			
				SubMenu = CreatePopupMenu();
				AppendMenu(Menu,MF_STRING|MF_POPUP,(UINT) SubMenu,"&Options");
				AppendMenu(SubMenu,MF_STRING,OPTION_BACKGROUND,"Background");

				SubMenu = CreatePopupMenu();
				AppendMenu(Menu,MF_STRING|MF_POPUP,(UINT) SubMenu,"&About");

				SetMenu(hWnd,Menu);
			}
		break;

		case WM_COMMAND:
			{
				switch(LOWORD(wParam))
				{
					case MENU_EXIT:
						if(MessageBox(NULL,"Are you sure you want to leave ?","Closing ...",MB_YESNO) == IDYES)
							DestroyWindow(hWnd);
					break;

					case ABOUT:
						{
							//HELP !

				}
			}
		break;

		case WM_CLOSE:
			if(MessageBox(NULL,"Are you sure you want to leave ?","Closing ...",MB_YESNO) == IDYES)
				DestroyWindow(hWnd);
		break;

		case WM_DESTROY:
			PostQuitMessage(0);
		break;

		default :
		    return DefWindowProc(hWnd,Msg,wParam,lParam);
		break;
	}

	return 0;
}
   
My dialog Procedure is here
      
bool CALLBACK DlgProc(HWDN hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
	switch(Msg)
	{
		case WM_INITDIALOG:
			return true;
		break;

		case WM_COMMAND :
			{
				switch(LOWORD(WPARAM))
				{
					case ABOUT_OK:
						EndDialog(hWnd,ABOUT_OK);
					break;
				}
			}

		default :
			return false;
		break;
	}

	return true;
}
    
My question is what kind of variable i use to creat dialogs ?? like for menu is use HMENU for icon HICON and etc... if there's another way please help me out. thx [edited by - Metal Typhoon on May 31, 2002 1:38:13 AM]
Metal Typhoon
Advertisement
It sounds like you''ve got the dialog described in the rsrc.rc file, which is the first step.

If you call CreateDialog(), you''ll get a non-modal dialog box (and you''ll have a HWND for it). This may not be what you want. To create a modal dialog box, there''s DialogBox(). To display, say, the IDD_MyDialog resource, you''d use something like this:

DialogBox(GetModuleHandle(0), MAKEINTRESOURCE(IDD_MyDialog), hWnd, DlgProc);
i''m not using resources. like i did with the menu can i do it with the dialog ?? just creat it there ?? will CreateDialog work ?? is threr such variable called HDIALOG ? and one more question how would i define the Caption for it an font and other stuff of the dialog ?? thx alot
Metal Typhoon
There is no HDIALOG handle, but you can make your own window using CreateWindow() or CreateWindowEx() if you dont want to use a resource.


I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm
I''m pretty sure you can do that with DialogBoxIndirect(), but I''ve never used that before. I''ll play with it and see if I can get it to work.
I''ve played with DialogBoxIndirect(). Merely declaring the data to pass to it is a disaster. I strongly suggest using resources
quote:Original post by Beer Hunter
I''ve played with DialogBoxIndirect(). Merely declaring the data to pass to it is a disaster. I strongly suggest using resources


LMAO. let me try to see what i get
Metal Typhoon

This topic is closed to new replies.

Advertisement