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
|
//initial windows classes for windows C++
#include"StdAfx.h"
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#include"Targetver.h"
#include"Resource.h"
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
//Windows Class
const wchar_t CLASS_NAME[] = L"YAHBOYS";
WNDCLASS wc = { 0 };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
// Creating the window
HWND hwnd = CreateWindowEx(
0, // Style
CLASS_NAME, // ClassName
L"YAHBOYS", // Bar Text
WS_OVERLAPPEDWINDOW, // Window style
// Position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
//Not really sure what this is yet, but ill figure out later
);
if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
// Message loop.
MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
{
return 0;
}
case WM_DESTROY:
//In case They try to destroy my window, I give them a very angry message with an OK slot and a CANCEL slot
if( MessageBox(hwnd,L"YOU TRYING TO CLOSE MY WINDOW!!!!!!!AHHHHHH!!!!!!!!!!!", L"I CANT BELIEVE YOU!", MB_OKCANCEL) == IDOK)
{
DestroyWindow(hwnd);
}
else
{
MessageBox(hwnd,L"BETTER not close my dang window.",L"MMMM HMMM",NULL);
//better pick cancel, sonny
}
return 0;
case WM_PAINT:
{
//This is where Im getting stuck:
PAINTSTRUCT ps = { 0 };
/*The program initializes until it gets here then suddenly STOPS. .
I know because right now even my compiler is saying the next line will be executed.*/
HDC hdc = BeginPaint(hwnd, &ps);
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
EndPaint(hwnd, &ps);
}
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
|