Results 1 to 5 of 5

Thread: Halcyon > Win32 Dialog wo/resource

  1. #1
    Senior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Halcyon > Win32 Dialog wo/resource

    Sample Code:

    #include <windows.h>

    /* Functions */
    ///////////////
    LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
    const char ClassName[ ] = "Dialog";
    ///////////////

    /* Variables */
    ///////////////
    HWND hWnd;
    HWND button_hWnd[2];
    HINSTANCE hInstance;
    const int button_ok = 1;
    const int button_cancel = 0;
    static int xpos, ypos;
    ///////////////

    int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) {
    HWND hWnd;
    MSG messages;
    WNDCLASSEX wincl;
    hInstance = hInstance;
    wincl.hInstance = hInstance;
    wincl.lpszClassName = ClassName;
    wincl.lpfnWndProc = WndProc;
    wincl.style = CS_VREDRAW | CS_HREDRAW;
    wincl.cbSize = sizeof( WNDCLASSEX );
    wincl.hIcon = LoadIcon( NULL, IDI_APPLICATION );
    wincl.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
    wincl.hCursor = LoadCursor( NULL, IDC_ARROW );
    wincl.lpszMenuName = NULL;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;

    wincl.hbrBackground = ( HBRUSH ) COLOR_BACKGROUND;

    if( !RegisterClassEx( &wincl ) ) {
    MessageBox( NULL, "Could not register", "ERROR", MB_OK | MB_ICONERROR );
    return 0;
    }

    xpos = GetSystemMetrics( SM_CXSCREEN );
    ypos = GetSystemMetrics( SM_CYSCREEN );

    hWnd = CreateWindowEx(
    0,
    ClassName,
    "Dialog",
    WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
    ( ( xpos / 2 ) - 143 ),
    ( ( ypos / 2 ) - 102 ),
    286,
    177,
    HWND_DESKTOP,
    NULL,
    hInstance,
    NULL );

    ShowWindow(hWnd,nCmdShow);

    while( GetMessage( &messages, NULL, 0, 0 ) ) {
    TranslateMessage( &messages );
    DispatchMessage( &messages );
    }
    return messages.wParam;
    }

    LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
    switch(message) {
    case WM_CREATE: {
    button_hWnd[1] = CreateWindow( "Button","OK",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,180,20,80,22,hWnd,(HMENU) button_ok,hInstance,NULL );
    button_hWnd[2] = CreateWindow( "Button","Cancel",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,180,50,80,22,hWnd,(HMENU) button_cancel,hInstance,NULL );
    break;
    }

    case WM_COMMAND: {
    if( HIWORD( wParam ) == BN_CLICKED ) {
    switch( LOWORD( wParam) ) {
    case button_cancel:
    DestroyWindow( hWnd );
    break;
    }
    }
    break;
    }

    case WM_DESTROY: {
    PostQuitMessage(0);
    break;
    }
    default:
    return DefWindowProc( hWnd,message,wParam,lParam );
    break;
    }
    return 0;
    }

    - VC6-OGL

  2. #2
    Halcyon
    Guest

    Re: Halcyon > Win32 Dialog wo/resource

    OOOOH....so what you are saying is that make the window you first create a dialog box. That makes sense. But what about if you have a main window already and you want to create a dialog box? Would have to make and MDI application then?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Re: Halcyon > Win32 Dialog wo/resource

    Most Likely.

    - VC6-OGL

  4. #4
    Halcyon
    Guest

    Re: Halcyon > Win32 Dialog wo/resource

    Thanks! Heh..have you ever tried doing MDI in MFC? It's probably just me but that is ONE CONFUSING thing to do. I can sit here reading aobut Convolution filters or vertex and pixel shaders and a lot of it makes sense. But MDI in MFC....that's a WHOLE other story . Lucky me that i use Win32 . Well Happy Holidays!


    - Halcyon

  5. #5
    Senior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Re: Halcyon > Win32 Dialog wo/resource

    I have NEVER tried doing MDI in MFC, and it is confusing.

    Happy Holidays to you to!!!

    - VC6-OGL

Similar Threads

  1. Win32 application freezes with certain dialog boxes
    By johnquinn888 in forum OpenGL: Windows
    Replies: 2
    Last Post: 01-02-2006, 02:37 PM
  2. OpenGL & Win32 Dialog Box
    By Laz in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 05-30-2003, 07:30 PM
  3. Name Change from Halcyon
    By Halcyon in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-26-2003, 07:42 PM
  4. dialog box in win32
    By element in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 02-09-2001, 03:00 PM
  5. Custom dialog box in OpenGL, without Win32 functions.
    By Anonymous Coward in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-04-2000, 03:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean