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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
//::::::::::::::::::::::::::::
//:::::::::Window.h:::::::::::
//::::::::::::::::::::::::::::
//::::Copyright by Florian::::
//::::::::::::::::::::::::::::
//-------------------------------Die Fenster funktion---------------------------
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
//----------------------------------Klasse--------------------------------------
class tWindow
{
private: HWND hwnd; //Window handle (Grundfenster)
WNDCLASSEX wincl; //Windows-klasse: Styles
MSG messages; //Window-Message
public: tWindow();
bool creat(char *ClassName, char *titel, tInfo Window); //Erstellt das Fenster!
void run(); //Hier ist die Nachrichtenschleife
MSG message(); //gibt die aktuelle Message wieder
};
//------------------------------------------------------------------------------
tWindow::tWindow(){
reset_Logbuch();
}
//------------------------------------------------------------------------------
bool tWindow::creat(char *ClassName, char *titel, tInfo Window) //erstellt >ein< Fenster!
{
//Windows-klasse
wincl.hInstance = Window.hThisInstance;
wincl.lpszClassName = ClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(Window.Icoid));
wincl.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(Window.Icoid), IMAGE_ICON, 16, 16, 0);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = MAKEINTRESOURCE(Window.Menuid);
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) CreateSolidBrush(RGB(Window.Color.R, Window.Color.G, Window.Color.B));
//Windows-klasse
if (!RegisterClassEx (&wincl)){ //Klasse wird regestriert!
into_Logbuch("Fensterklasse konnte nicht regestiert werden!", false);
return 0;
}else{
into_Logbuch("Fenster wurde regestriert!", true);
}
hwnd = CreateWindowEx ( //Erstellen des Fensters
0,
ClassName,
titel,
WS_OVERLAPPED | WS_BORDER | WS_SYSMENU,
Window.Position.x,
Window.Position.y,
Window.Position.b,
Window.Position.h,
HWND_DESKTOP,
NULL,
Window.hThisInstance,
NULL
);
if (hwnd==NULL){
into_Logbuch("Fenster konnte nicht erstellt werden!", false);
}else{
into_Logbuch("Fenster wurde erstellt!", true);
}
ShowWindow (hwnd, Window.nFunsterStil); //Fenster wird sichtbar gemacht
UpdateWindow(hwnd); //Fenster wird geupdatet
}
//------------------------------------------------------------------------------
void tWindow::run(){ //Hier befindet sich die Nachrichtenschleife!
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages); //Message Übersetzen
DispatchMessage(&messages); //Message setzen
}
}
//------------------------------------------------------------------------------
MSG tWindow::message(){ //Gibt die Message aus
return messages;
}
//------------------------------------------------------------------------------
|