{"id":274,"date":"2012-01-18T11:04:48","date_gmt":"2012-01-18T11:04:48","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=274"},"modified":"2012-01-18T11:07:49","modified_gmt":"2012-01-18T11:07:49","slug":"erste-windows-programmierung-unter-mingw","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=274","title":{"rendered":"Erste Windows Programmierung unter MingW"},"content":{"rendered":"<pre class=\"brush: cpp; collapse: true; light: false; title: Source; toolbar: true; notranslate\" title=\"Source\">\r\n#ifndef UNICODE\r\n#define UNICODE\r\n#endif \r\n\r\n#include &lt;windows.h&gt;\r\n\r\nLRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\r\n\r\nint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow)\r\n{\r\n    \/\/ Register the window class.\r\n    const wchar_t CLASS_NAME&#x5B;]  = L&quot;Sample Window Class&quot;;\r\n    \r\n    WNDCLASS wc = { };\r\n\r\n    wc.lpfnWndProc   = WindowProc;\r\n    wc.hInstance     = hInstance;\r\n    wc.lpszClassName = CLASS_NAME;\r\n\r\n    RegisterClass(&amp;wc);\r\n\r\n    \/\/ Create the window.\r\n\r\n    HWND hwnd = CreateWindowEx(\r\n        0,                              \/\/ Optional window styles.\r\n        CLASS_NAME,                     \/\/ Window class\r\n        L&quot;Learn to Program Windows&quot;,    \/\/ Window text\r\n        WS_OVERLAPPEDWINDOW,            \/\/ Window style\r\n\r\n        \/\/ Size and position\r\n        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,\r\n\r\n        NULL,       \/\/ Parent window    \r\n        NULL,       \/\/ Menu\r\n        hInstance,  \/\/ Instance handle\r\n        NULL        \/\/ Additional application data\r\n        );\r\n\r\n    if (hwnd == NULL)\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    ShowWindow(hwnd, nCmdShow);\r\n\r\n    \/\/ Run the message loop.\r\n\r\n    MSG msg = { };\r\n    while (GetMessage(&amp;msg, NULL, 0, 0))\r\n    {\r\n        TranslateMessage(&amp;msg);\r\n        DispatchMessage(&amp;msg);\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\nLRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\r\n{\r\n    switch (uMsg)\r\n    {\r\n    case WM_DESTROY:\r\n        PostQuitMessage(0);\r\n        return 0;\r\n\r\n    case WM_PAINT:\r\n        {\r\n            PAINTSTRUCT ps;\r\n            HDC hdc = BeginPaint(hwnd, &amp;ps);\r\n\r\n            FillRect(hdc, &amp;ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));\r\n\r\n            EndPaint(hwnd, &amp;ps);\r\n        }\r\n        return 0;\r\n\r\n    }\r\n    return DefWindowProc(hwnd, uMsg, wParam, lParam);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#ifndef UNICODE #define UNICODE #endif #include &lt;windows.h&gt; LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow) { \/\/ Register the window class. const wchar_t CLASS_NAME&#x5B;] = L&quot;Sample Window Class&quot;; WNDCLASS wc = { }; wc.lpfnWndProc = WindowProc; wc.hInstance = hInstance; wc.lpszClassName = CLASS_NAME; RegisterClass(&amp;wc); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,18],"tags":[],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-mingw","category-windows-7"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=274"}],"version-history":[{"count":3,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":277,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions\/277"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}