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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
//winh.h
#ifndef WINH_H_INCLUDED
#define WINH_H_INCLUDED
#include <windows.h>
#include <windowsx.h>
#define Handle HWND
#define WindowClass WNDCLASSEX
#define WindowsMain int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
#define Win_Proc LRESULT CALLBACK WindowProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
WindowsMain
{
}
template <typename TYPE, typename NEWTYPE, typename CLASS>
int WindowShow(HWND hWnd,WNDCLASSEX wc,NEWTYPE WinTitle,CLASS className)
{
Win_Proc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = className;
hWnd = CreateWindowExW(NULL,
(L className), // name of the window class
(L WinTitle), // title of the window
WS_OVERLAPPEDWINDOW, // window style
300, // x-position of the window
300, // y-position of the window
500, // width of the window
400, // height of the window
NULL, // we have no parent window, NULL
NULL, // we aren't using menus, NULL
hInstance, // application handle
NULL); // used with multiple windows, NULL
// display the window on the screen
ShowWindow(hWnd, nCmdShow);
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
Win_Proc
{
switch(message)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
} break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
}
#endif // WINH_H_INCLUDED
//test.cpp
#include "winh.h"
WindowsMain
{
Handle BLABLA;
WindowClass HEYTHERE;
WindowShow(BLABLA,HEYTHERE,"Test","WinClass");
}
|