먼저 과제임을 밝힐게요
저번주 예비군을 갔다와서 너무 놓친 부분이 많은데
지금 하는 과제는 오목판처럼 그림을 그리고 네모 안을 클릭시 동그라미를 나타내는 과제입니다.
밑에 소스는 강의 때 알려주셨던 소스고요..
이 소스 자체가 과제를 의미하는 거같은데, 잘 안되서 염치불구 질문드려봅니다 ... ㅜㅜ
수정부분과 설명을 달아주시면 보고 공부할 수 있게 도와주세요
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass = TEXT("현선오_2015032161");
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance
, LPSTR lpszCmdParam, int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst = hInstance;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = lpszClass;
WndClass.lpszMenuName = NULL;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
hWnd = CreateWindow(lpszClass, lpszClass, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, (HMENU)NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
while (GetMessage(&Message, NULL, 0, 0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}
#define BSIZE 40
#define BSIZE2 80
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
int i, j;
static int rect[8][4];
static int x, y;
switch (iMessage) {
case WM_CREATE:
x = -50; y = -50;
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
for (i = 0; i < 8; i++)
for (j = 0; j < 4; j++)
{
Rectangle(hdc, i*BSIZE2, j*BSIZE2, (i + 1)*BSIZE2, (j + 1)*BSIZE2);
if (rect[i][j])
Ellipse(hdc, i*BSIZE2, j*BSIZE2, (i + 1)*BSIZE2, (j + 1)*BSIZE2);
}
EndPaint(hWnd, &ps);
break;
case WM_LBUTTONDOWN:
x = LOWORD(lParam) / BSIZE2;
x = HIWORD(lParam) / BSIZE2;
if (x < 8 && y < 4)
rect[x][y] = 1;
InvalidateRgn(hWnd, NULL, TRUE);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}