http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ShowWindow?



it is shameful while i am developing a game, i am not able to create an app 
which
                show a
                child window.is there anyone who do it before? the code is 
following.
                any typical code is prefered.
                thanks a lot.

                #include "windows.h"

                HINSTANCE hinst;
                HWND    hwndMain;
                HINSTANCE    ghinst;
                HWND    w1;
                WNDCLASS    wc1;
                LRESULT    APIENTRY WndProc(HWND,UINT,WPARAM,LPARAM);


                int APIENTRY WinMain(HINSTANCE hInstance,                    
  HINSTANCE hPrevInstance,
                                    LPSTR     lpCmdLine,                     
int       nCmdShow){

                MSG    msg;
                WNDCLASS    wc;
                if(!hPrevInstance){
                    wc.style = 0;
                    wc.lpfnWndProc = (WNDPROC) WndProc;
                    wc.cbClsExtra = 0;
                    wc.cbWndExtra = 0;
                    wc.hInstance = hInstance;
                    wc.hIcon = LoadIcon((HINSTANCE) NULL, IDI_APPLICATION);
                    wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
                    wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
                    wc.lpszMenuName = "MainMenu";
                    wc.lpszClassName = "MainWndClass";

                    if(!RegisterClass(&wc)) return FALSE;
                }

                hinst = hInstance;
                hwndMain = CreateWindow("MainWndClass","Sample",             
            WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
                               CW_USEDEFAULT,CW_USEDEFAULT,(HWND)NULL,
                    (HMENU)NULL,hinst,(LPVOID)NULL);
                if(!hwndMain)    return FALSE;
                ShowWindow(hwndMain,nCmdShow);
                UpdateWindow(hwndMain);


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



                LRESULT    APIENTRY WndProc(HWND hwnd,UINT uMsg,WPARAM 
wParam,LPARAM lParam){
                    switch(uMsg){
                        case WM_KEYDOWN:
                            switch(wParam){
                                case    VK_F12:
                if(!ghinst){
                    wc1.style = CS_HREDRAW | CS_VREDRAW;
                    wc1.lpfnWndProc = (WNDPROC) NULL;
                    wc1.cbClsExtra = 0;
                    wc1.cbWndExtra = 0;
                    wc1.hInstance = ghinst;
                    wc1.hIcon = LoadIcon((HINSTANCE) NULL, IDI_APPLICATION);
                    wc1.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
                    wc1.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
                    wc1.lpszMenuName = NULL;
                    wc1.lpszClassName = "WndClass1";

                    if(!RegisterClass(&wc1)) return FALSE;
                }
                w1 = CreateWindowEx(0,"WndClass1","Sample window",
                            WS_POPUPWINDOW,50,50,
                            100,100,hwndMain/*(HWND)NULL*/,
                            (HMENU)NULL,ghinst,(LPVOID)NULL);
                if(w1 == NULL)    DestroyWindow(hwndMain);
                ShowWindow(w1,SW_SHOWDEFAULT);
                UpdateWindow(w1);
                //w1 is created but i could not show it anyway.

                                    break;
                            }
                            return 0;
                        case WM_CLOSE:
                                DestroyWindow(hwndMain);
                                return 0;
                        case WM_PAINT:
                            return 0;
                        case WM_SIZE:
                            return 0;
                        case WM_DESTROY:
                            PostQuitMessage(0);
                            return 0;
                        default:
                            return    
DefWindowProc(hwnd,uMsg,wParam,lParam);
                    }
                    return 0;
                }


________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html