1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <Windows.h>
//global class name
const char WindowC[] = "WindowsClass";
//this handles everything you do to the window (clicking etc)
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
//skype is a fegget
case WM_CLOSE: MessageBox(NULL, "NO!", NULL, NULL);
}
return 0;
}
//the main function
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX window;//object
HWND hwnd;//the handle
MSG msg;//the message
window.cbSize = sizeof(WNDCLASSEX);
window.style = 0;
window.lpfnWndProc = WndProc;
window.cbClsExtra = 0;
window.cbWndExtra = 0;
window.hInstance = hInstance;
window.hIcon = LoadIcon(NULL, IDI_APPLICATION);
window.hCursor = LoadCursor(NULL, IDC_ARROW);
window.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
window.lpszMenuName = NULL;
window.lpszClassName = WindowC;
window.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&window))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WindowC, "Hello", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
|