Win32 Window

Discussion in 'Win32' started by dontbugme, Mar 30, 2008.

  1. dontbugme

    dontbugme New Member

    Joined:
    Nov 27, 2007
    Messages:
    6
    Likes Received:
    1
    Trophy Points:
    3
    Gender:
    Male
    Hello,

    I have made in win32 window.
    This compiles with dev-c 4 complete without errors but when i start the program it will do nothing.

    Can anyone help me with this please ?

    greetz,

    dontbugme
     
  2. dontbugme

    dontbugme New Member

    Joined:
    Nov 27, 2007
    Messages:
    6
    Likes Received:
    1
    Trophy Points:
    3
    Gender:
    Male
    This is the code i forget

    PHP:
    #include <windows.h>

    LRESULT CALLBACK WndProc(HWNDUINTWPARAMLPARAM);

    int WINAPI WinMain(HINSTANCE hInstanceHINSTANCE hPrevInstancechar szCmdLineint iCmdShow)
    {
    char szAppName[] = "My window";
    HWND               hwnd;
    MSG                msg;
    WNDCLASS          wndclass;

    wndclass.lpfnWndProc       WndProc;
    wndclass.lpszClassName     szAppName;
    wndclass.style             CS_HREDRAW CS_VREDRAW;
    wndclass.hInstance         hInstance;
    wndclass.hIcon             LoadIcon(NULLIDI_APPLICATION);
    wndclass.hCursor           LoadCursor(NULLIDC_ARROW);
    wndclass.hbrBackground     = (HBRUSH) (COLOR_WINDOW+1);
    wndclass.lpszMenuName      NULL;
    wndclass.cbClsExtra        0;
    wndclass.cbWndExtra        0;

    //register class
    if (!RegisterClass(&wndclass))
    {
     
    MessageBox(NULL"Window registration failed!"szAppNameMB_OK);
     return 
    0;
    }

    //create window
    hwnd CreateWindow(szAppName,
                        
    szAppName,
                        
    WS_OVERLAPPEDWINDOW,
                        
    CW_USEDEFAULT,
                        
    CW_USEDEFAULT,
                        
    CW_USEDEFAULT,
                        
    CW_USEDEFAULT,
                        
    NULL,
                        
    NULL,
                        
    hInstance,
                        
    NULL);

    ShowWindow(hwndiCmdShow);
    UpdateWindow(hwnd);


    //messageloop
    while(GetMessage(&msgNULL00))
    {
     
    TranslateMessage(&msg);
     
    DispatchMessage(&msg);
    }
     return 
    msg.wParam;
     }

     
    //window procedure
    LRESULT CALLBACK WndProc(HWND hwndUINT messageWPARAM wParamLPARAM lParam)
    {
     
    HDC                               hdc;
     
    PAINTSTRUCT                       lpps;
     
    RECT                              lprect;

     switch(
    message)
     {
      case 
    WM_PAINT:
                                       
    hdc BeginPaint(hwnd, &lpps);

                                       
    GetClientRect(hwnd, &lprect);
                                       
    DrawText(hdc"Hello World!", -1, &lprectDT_CENTER DT_VCENTER DT_SINGLELINE);

                                       
    EndPaint(hwnd, &lpps);
                                       return 
    0;


      case 
    WM_DESTROY:
                                      
    PostQuitMessage(0);
                                      return 
    0;
     }
      return 
    DefWindowProc(hwndmessagelParamwParam);
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice