Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2004
    Location
    New Hampshire, America
    Posts
    246
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Dialog Box / C++ Failure to Respond

    Does anyone know why the following code fails to respond to the user? I mean, the dialog box shows up, but when you click on anything, nothing happens! All help appreciated
    ~dunna

    Code:
    #include <windows.h>
    #include <stdio.h>
    #include "resource.h"
    
    HWND g_hWnd;
    char g_szClass[] = "This wont work";
    
    LRESULT CALLBACK WindowProc1(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
      switch(uMsg) {
        case WM_COMMAND:
    
          switch(LOWORD(wParam)) {
    
    	  case IDC_CANCEL:
    		  EndDialog(g_hWnd, 0);
    		  break;
    
    	  default:
    		  break;
    
          }
          break;
    
        case WM_CREATE:
    		break;
    
    
        case WM_DESTROY:
    		PostQuitMessage(0);
    		break;
    
        default: return DefWindowProc(hWnd, uMsg, wParam, lParam);
      }
    
      return 0;
    }
    
    int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
    {  
       WNDCLASS wc;
       MSG Msg;
       
       wc.style         = CS_HREDRAW | CS_VREDRAW;
       wc.lpfnWndProc   = WindowProc1;
       wc.cbClsExtra    = 0;
       wc.cbWndExtra    = DLGWINDOWEXTRA;
       wc.hInstance     = hInst;
       wc.hIcon         = LoadIcon(hInst, IDI_APPLICATION);
       wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
       wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
       wc.lpszMenuName  = NULL;
       wc.lpszClassName = g_szClass;
       RegisterClass(&wc);
    
       g_hWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_OPTIONS), 0, NULL);
       UpdateWindow(g_hWnd);
       ShowWindow(g_hWnd, nCmdShow);
    
    
       while(GetMessage(&Msg,NULL,0,0) > 0)
       {    
    	TranslateMessage(&Msg);
    	DispatchMessage(&Msg);
       }
    	
       UnregisterClass(g_szClass, hInst);
    
       return 0;
    }

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    230
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #3
    Regular Coder
    Join Date
    May 2004
    Location
    New Hampshire, America
    Posts
    246
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Ahh.....Excellent! Just what I've been loking for! I downloaded the whole thing to my hard drive for offline browsing. Thank you aman!


  •  

    Posting Permissions

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