MFC 스터디


첫째날..

  • API 학습..

~cpp 
#include <windows.h>
#include "resource.h"

LRESULT CALLBACK WindowProc(HWND WindowHandle, UINT message, WPARAM WordParam, LPARAM LongParam)
{
	static bool click = false;
	static x, y;
	static HDC dcHandle;

	switch(message)
	{
	case WM_LBUTTONDOWN:
		click = true;
		dcHandle = GetDC(WindowHandle);
		POINT point;
		MoveToEx(dcHandle, LOWORD(LongParam), HIWORD(LongParam), &point);
		SelectObject(dcHandle, GetStockObject(GRAY_BRUSH));
		break;
	case WM_LBUTTONUP:
		click = false;
		ReleaseDC(WindowHandle, dcHandle);
		break;
	case WM_MOUSEMOVE:
		if(click)
			LineTo(dcHandle, LOWORD(LongParam), HIWORD(LongParam));
		break;
	case WM_COMMAND:
		switch(LOWORD(WordParam))
		{
		case ID_NEW:
			MessageBox(NULL, "얼굴도 못 생긴 것들이~ n만들긴 뭘 만든다고오~~", "옥동자", MB_ICONERROR | MB_OK);
			break;
		case ID_CLOSE:
			DestroyWindow(WindowHandle);
			break;
		}
		break;
	case WM_CLOSE:
		DestroyWindow(WindowHandle);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(WindowHandle, message, WordParam, LongParam);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR IpCmdLine, int nCmdShow)
{
	WNDCLASS shot;
	shot.cbClsExtra = 0;
	shot.cbWndExtra = 0;
	shot.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	shot.hCursor = (HCURSOR)LoadCursor(NULL, IDC_CROSS);
	shot.hIcon = (HICON)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_PHONE));
	shot.hInstance = hInstance;
	shot.lpfnWndProc = WindowProc;
	shot.lpszClassName = "It's Snow~";
	shot.lpszMenuName = NULL;
	shot.style = NULL;


	if(!RegisterClass(&shot))
		return 0;

	HWND WindowHandle;
	WindowHandle = CreateWindow("It's Snow~", "Wheather", WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
		NULL, LoadMenu(hInstance, MAKEINTRESOURCE(IDR_WITCH)), hInstance, NULL);
	if(!WindowHandle)
		return 0;
	ShowWindow(WindowHandle, nCmdShow);
	UpdateWindow(WindowHandle);

	MSG msg;
	while(GetMessage(&msg, NULL, NULL, NULL))
		DispatchMessage(&msg);
	return msg.wParam;
}

아고 머리야..ㅡㅡ;;

Thread

Retrieved from http://wiki.zeropage.org/wiki.php/재니/MFC
last modified 2021-02-07 05:30:43