¿¹Á¦ ÄݹéÇÔ¼ö ¼Ò½ºÄÚµå µû¶óÇÏ¸é¼ Çϴµ¥ ¿À·ù°¡ ³³´Ï´Ù. ºñÁÖ¾ó½ºÆ©µð¿À 2022»ç¿ë ÁßÀÔ´Ï´Ù.
RGBºÎºÐ¿¡¼ ¿À·ù¿Í SetTimerÇÔ¼ö¿¡¼ ¿À·ù°¡ ³³´Ï´Ù. È®ÀκÎŹµå¸³´Ï´Ù.
Á¦°¡ ÀÛ¼ºÇÑ ÆÄÀÏ ¿Ã·Áµå¸³´Ï´Ù.
È®ÀκÎŹµå¸³´Ï´Ù.
#include<Windows.h>
#include<WinUser.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass = TEXT("Callback");
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lnCmdLine, _In_ 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, 600, 300, 500, 500, NULL, (HMENU)NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&message, NULL, 0, 0)) {
TranslateMessage(&message);
DispatchMessage(&message);
}
return((int)message.wParam);
}
void CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) {
HDC hdc;
int i;
hdc = GetDC(hWnd);
for (i = 0; i < 1000; i++) {
SetPixel(hdc, rand() % 500, rand() % 400, RGB(rand() % 256, rand() % 256, , rand() % 256)); // ¿À·ù¹ß»ý
}
ReleaseDC(hWnd, hdc);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
HDC hdc;
switch (iMessage) {
case WM_CREATE:
SetTimer(hWnd, 1, 100, TimerProc); //¿À·ù¹ß»ý
return(0);
case WM_LBUTTONDOWN:
hdc = GetDC(hWnd);
Ellipse(hdc, LOWORD(lParam) - 10, HIWORD(lParam) - 10, LOWORD(lParam) + 10, HIWORD(lParam) + 10);
ReleaseDC(hWnd, hdc);
return(0);
case WM_DESTROY:
KillTimer(hWnd, 1);
PostQuitMessage(0);
return(0);
}
return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}

±è¹Î¼ö
|
|