GDI에서 기본적으로 제공하는 Object.
HGDIOBJ GetStockObject(int fnObject);
BLACK_BRUSH
GRAY_BRUSH
NULL_BRUSH(투명)
WHITE_BRUSH
DKGRAY_BRUSH
LTGRAY_BRUSH
DC_BRUSH(색상 브러시, SetDCBrushColor로 색 설정)
BLACK_PEN
WHITE_PEN
NULL_PEN
DC_PEN(색상 펜, SetDCPenColor 함수로 설정)
ANSI_FIXED_FONT 고정폭 폰트
ANSI_VAR_FONT 가변폭 폰트
DEFAULT_PALETTE 시스템 기본 팔레트
사용 예
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass=TEXT("First");
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;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
HBRUSH MyBrush,OldBrush;
switch(iMessage)
{
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
(HBRUSH)SelectObject(hdc,GetStockObject(GRAY_BRUSH));
Rectangle(hdc,50,50,300,200);
EndPaint(hWnd,&ps);
return 0;
case WM_DESTROY : PostQuitMessage(0);
return 0;
}
return (DefWindowProc(hWnd,iMessage,wParam,lParam));
}
'Programming > Visual C++' 카테고리의 다른 글
그래픽4. Brush (0) | 2011.06.30 |
---|---|
그래픽3. PEN (0) | 2011.06.30 |
그래픽 1. GDI Object (0) | 2011.06.30 |
기타. SendMessage - Message 강제 호출 (0) | 2011.06.30 |
타이머. (0) | 2011.06.29 |