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
| //
// main.cpp
// Je commence avec main et non WinMain. WinMain est charger par ma lib. Je me suis inspire de QT sur ce coup la, si un jours je veux rendre mon code portable, ca sera plus facile...
#include "../X.h"
Xbool Event_Escape(HWND wnd, WPARAM wParam, LPARAM lParam);
Xbool Event_Destroy(HWND wnd, WPARAM wParam, LPARAM lParam);
int main(int argc, char** argv)
{
X::XApplication app(argc, argv); // initialisation du programme.
X::XWindow* window; // Creation de la fenetre.
window = new X::XWindow("X_Window");
window->Create(150, 150, 640, 480);
window->Show(SW_SHOW);
X::XEvent event1;
event1.Type = WM_KEYDOWN;
event1.Name = "ESCAPE";
event1.Event = &Event_Escape;
X::XEvent::EventsArray.Append(event1);
X::XEvent event2;
event2.Type = WM_DESTROY;
event2.Name = "DESTROY";
event2.Event = &Event_Destroy;
X::XEvent::EventsArray.Append(event2);
app.Exec(X::GETMESSAGE); // Je lance la boucle de message
delete window;
return EXIT_SUCCESS;
}
Xbool Event_Escape(HWND wnd, WPARAM wParam, LPARAM lParam)
{
X_UNUSED_TYPE(lParam);
if(X_ON_CLICK(VK_ESCAPE)){
DestroyWindow(wnd);
return true;
}
return false;
}
Xbool Event_Destroy(HWND wnd, WPARAM wParam, LPARAM lParam)
{
X_UNUSED_TYPE(wParam);
X_UNUSED_TYPE(lParam);
ReleaseDC(wnd, X::XWindow::GetDeviceContext());
PostQuitMessage(0);
return true;
} |
Partager