Destrovi4 icon

Window2

Destrovi4 | PRO | 02/12/15 04:57:46 PM UTC | 0 ⭐ | 10354 👁️ | Never ⏰ | []
C++ (WinAPI) |

0 B

|

None

|

0 👍

/

0 👎

#include <Windows.h>
#include <iostream>
using namespace std;
 
void TellError(const char* error){
    cout << error << endl;
}
 
int AppRunning = 1;
 
LRESULT CALLBACK WindowProcedure(HWND hWnd,UINT msg,WPARAM wparam,LPARAM lparam) {
 
    switch(msg){
        case WM_KEYDOWN:
            AppRunning=0;
            break;
        case WM_CLOSE:
            DestroyWindow(hWnd);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
    }
 
    return DefWindowProc(hWnd,msg,wparam,lparam);
}
 
HWND createWindow(WNDPROC wndProc, int nCmdShow) {
 
    HINSTANCE hInstance = GetModuleHandle(0);
    WNDCLASS WindowClass;
 
    WindowClass.style           = 0;
    WindowClass.lpfnWndProc     = wndProc;
    WindowClass.cbClsExtra      = 0;
    WindowClass.cbWndExtra      = 0;
    WindowClass.hInstance       = hInstance;
    WindowClass.hIcon           = LoadIcon(hInstance, (LPCTSTR)IDI_APPLICATION);
    WindowClass.hCursor         = LoadCursor(NULL, IDC_ARROW);
    WindowClass.hbrBackground   = (HBRUSH)(COLOR_WINDOW+1);
    WindowClass.lpszMenuName    = 0;
    WindowClass.lpszClassName   = TEXT("Class");
    RegisterClass(&WindowClass);
 
    HWND hWnd = CreateWindow(
        "Class",
        NULL,
        WS_BORDER|WS_VISIBLE,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        0,0,
        hInstance,
        NULL
    );
 
    ShowWindow(hWnd, nCmdShow);
    UpdateWindow(hWnd);
 
    return hWnd;
}
 
 
int main() {
    cout << "Start" << endl;
    MSG msg;
    HWND hWnd = createWindow(WindowProcedure, 0);//NewWindow("Hello window", 0, 0, 100, 100);
    if(!hWnd){
        TellError("Cannot create window!");
        return 0;
    }
    while(AppRunning){
        if(PeekMessage(&msg,hWnd,0,0,PM_REMOVE)){
            //if(!IsDialogMessage(hWnd,&msg)){
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            //}
        }
    }
    DestroyWindow(hWnd);
    cout << "End" << endl;
 
    return 0;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎