Results 1 to 5 of 5

Thread: Dialogs

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024

    Dialogs

    Well after a couple of years doing dialog box, buttons, listviews, etc the hard way (ie CreateWindowEX), I have decieded to move on.

    I guess the first question is I still want to use as much pure Win32/API as possible (no MFC) so is using the resource editor and Dialog or CreateDialog the best way to do this?

    My second question is how do I do it? I make a quick dialog using an IDD_PROPAGE_MEDIUM. Now I am trying to get it to just come up. I have tried CreateDialog() and Dialog() with out any luck. Someone want to help me out?

    Doing this I get a NULL g_hWnd

    Code:
    /*---------------------------------*/
    				//Include
    
    #include "Main.h"
    
    /*---------------------------------*/
    				//Global VARs
    
    HWND		g_hWnd;							//Holds The Window Handle
    
    HINSTANCE	g_hInst;						//Holds The Window Instance
    
    TCHAR		g_szClass[]		= "Test Window";//Class Title
    
    HANDLE		g_hMutex		= NULL;			//Handle For The Mutex
    
    /*---------------------------------*/
    				//Modual VARs
    
    int m_iWidth	= 500;						//Main Window Width
    int m_iHeight	= 500;						//Main Window Height
    int m_iX		= CENTERX(m_iWidth);		//Main Window's X Position
    int m_iY		= CENTERY(m_iHeight);		//Main Window's Y Position
    
    
    /*---------------------------------*/
    				//Modual Functions
    
    BOOL CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    
    /*---------------------------------*/
    
    
    
    
    
    
    /*###########################################################################################*/
    
    int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
    {
    /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/	
    	MSG _msg;										//VAR To Hold Our Main Messages
    /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
    
    	if(!Startup(g_szClass))							//Run My Custom Start Function
    		return -1;
    
    	g_hWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, DialogProc);
    	
    	ShowWindow(g_hWnd, SW_SHOW);
    	int i; 
    	while(i = GetMessage(&_msg, NULL, 0, 0))		//Window Message Loop
    	{ 
    		if (i == -1) 
    			break; 
    
    		TranslateMessage(&_msg); 
    		DispatchMessage(&_msg); 
    	}
    
    	return ((int)_msg.wParam);						//Exit The Program
    
    }
    
    
    
    
    
    
    /*###########################################################################################*/
    
    BOOL CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch(uMsg) 
    	{
    		case WM_INITDIALOG:
    			return TRUE;
    		 case WM_CLOSE:
    			DestroyWindow(hWnd); //Closes the dialog box
    			PostQuitMessage(0);  //Exit the program
    		 return TRUE;
    
    	}
    	return FALSE;
    }
    If I use Dialog instead I can get the window to come up, but if I even try to click on it I cant. Its like its not being drawn/redrawn. So I am stuck.

    Any help would be great thanks.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Dialog? Do you mean DialogBox?

    The code actually looks ok to me, I don't see why it shouldn't be working.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Yeah DialogBox, sorry.

    I don't get it either, from what I can tell it SHOULD work too, which is why this is starting to get frustrating. All I wanted to do was make Windows faster instead of having to code everything by hand

    Ok so if I use GetDesktopWindow() instead of NULL:
    CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_MAIN),GetDesktopWindow(),Main_DlgProc);

    I get a window like DialogBox gives me, but I can't click on it or anything (See attached)
    Attached Images Attached Images  
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  4. #4

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Ok I got it stupid POS. I had to change:
    Code:
    	int i; 
    	while(i = GetMessage(&_msg, NULL, 0, 0))		//Window Message Loop
    	{ 
    		if (i == -1) 
    			break; 
    
    		if(!IsDialogMessage(g_hWnd,&_msg))
    		{
    			TranslateMessage(&_msg); 
    			DispatchMessage(&_msg); 
    		}
    	}
    Also for some REASON .NET 2003 has the dialog disabled by default. Oh well it looks like it is working now.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Oh yeah, the special message loop...

    Never actually used it (I used dialogs only in MFC), but I read of it in the Petzold. Probably would have never thought of it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width