VisualC++ 원그리기에서 중심점 질문드립니다.
누리별
#include windows.h
lresult callback wndproc(hwnd, uint, wparam, lparam);
int apientry winmain(hinstance hinstance,
hinstance hprevinstance,
lpstr ipcmdline,
int nshowcmd)
{
hwnd hwnd;
msg msg;
wndclassex wcex;
wcex.cbsize =sizeof(wndclassex);
wcex.style = cs_hredraw | cs_vredraw;
wcex.lpfnwndproc = (wndproc)wndproc;
wcex.cbclsextra = 0;
wcex.cbwndextra = 0;
wcex.hinstance = hinstance;
wcex.hicon = loadicon(null, idi_application);
wcex.hcursor = loadcursor(null, idc_arrow);
wcex.hbrbackground = (hbrush)(color_window + 1);
wcex.lpszmenuname = null;
wcex.lpszclassname = modelapp;
wcex.hiconsm = loadicon(null , idi_application);
registerclassex(&wcex);
hwnd = createwindow(wcex.lpszclassname,
펜과 브러시의 작성,
ws_overlappedwindow,
cw_usedefault,
cw_usedefault,
cw_usedefault,
cw_usedefault,
null,
null,
hinstance,
null);
showwindow(hwnd, nshowcmd);
updatewindow(hwnd);
while(getmessage(&msg, null,0,0))
{
translatemessage(&msg);
dispatchmessage(&msg);
}
return msg.wparam;
}
lresult callback wndproc(hwnd hwnd,
uint message,
wparam wparam,
lparam lparam)
{
hdc hdc;
paintstruct ps;
static hpen hpen;
static hbrush hbr;
switch(message)
{
case wm_create:
hpen = createpen(ps_dash,1,rgb(255,0,0));
hbr = createhatchbrush(hs_cross,rgb(0,0,255));
return 0;
case wm_paint :
hdc = beginpaint (hwnd, &ps) ;
hbr = createsolidbrush(rgb(255,0,0));
selectobject(hdc, hbr );
ellipse(hdc, 0,0,30,30);
endpaint (hwnd, &ps) ;
return 0 ;
case wm_destroy:
deleteobject(hpen);
deleteobject(hbr);
postquitmessage(0);
return 0;
default:
return defwindowproc( hwnd, message, wparam, lparam);
}
}
ellipse
제가 처음으로하는 visual c++ 책을 보면서 하고 있는데,
원그리기 파트 중에 나온 내용인데요.
화면의 정가운데 반지름이 30인 원을 그리고, 원의 면을 빨간색으로 하라! 라고 나와서
색을 빨간색으로까지 했는데, 반지름 30과 화면의 정 가운데를 어떻게 해야 하는지 책을 아무리 봐도 없네요..
반지름이 지금 제가 ellipse (0,0,30,30)으로 한건 잘못한것 같애요. 반지름이 30인거 같지도 않구요..
아무리 책을 봐도 여기까지 밖에 않되더라구요 ㅠㅠ;;
-
설아
답변 감사드립니다 ^.^ 그런데 우하단의 좌표를 어떻게 알아내는지를 모르곘네요 ㅠ
-
초월
프로그래밍은 대부분 영어로 되어 있어서 가끔씩 영어를 해석하는 것 만으로 문제가 해결될 때가 있습니다. 이 경우 Ellipse 는 원이 아니라 \타원\ 이며 이 때문에 혼돈이 있었던 것 같습니다. 타원 함수는 만국 공통(-_-?)입니다만 사각형 처럼 좌측 상단의 좌표와 우측 하단의 좌표를 넣으면 그 안에 타원을 그려줍니다. 아마도 Ellipse(0, 0, 30, 30) 이라고 하시면 윈도우 좌상단으로 부터 30, 30 위치까지 사각형을 만들고 그 안에