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
83
84
85
|
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK Message(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
bool Render(HWND hWnd);
TCHAR g_Text[10]={0};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
HWND hWnd = NULL;
MSG msg = {0};
WNDCLASSEX Window = {0};
Window.cbSize = sizeof(WNDCLASSEX);
Window.cbClsExtra = 0;
Window.cbWndExtra = 0;
Window.hInstance = hInstance;
Window.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
Window.lpszMenuName = NULL;
Window.hCursor = LoadCursor(NULL, IDC_ARROW);
Window.hIcon = LoadIcon(NULL, IDI_WINLOGO);
Window.lpfnWndProc = Message;
Window.lpszClassName = TEXT("WindowClassEx");
Window.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
Window.hIconSm = NULL;
RegisterClassEx(&Window);
hWnd = CreateWindowEx(NULL, TEXT("WindowClassEx"), TEXT("Übung"), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 10, 10, 800, 600, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, nShowCmd);
UpdateWindow(hWnd);
while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
Render(hWnd);
//Move
}
}
}
LRESULT CALLBACK Message(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
return 0;
case WM_MOUSEMOVE:
//swprintf(g_Text, L"%i - %i", LOWORD(lParam), HIWORD(lParam));
//MessageBox(hWnd, "Error", L"ERROR", MB_OK);
return 0;
case WM_PAINT:
//Render(hWnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
bool Render(HWND hWnd)
{
PAINTSTRUCT ps;
RECT rect;
HDC hdc;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rect);
SetTextColor(hdc, RGB(255,0,0));
SetBkColor(hdc, RGB(0,0,0));
TextOut(hdc, 10, 10, L"Test", 4);//g_Text, wcslen(g_Text));
EndPaint(hWnd, &ps);
return true;
}
|