Reputation: 87
I created a common dialog class(CCommonDlg) inherited from CDialogEx.
Now I am inheriting CMyDialog from CCommonDialog. Passed CMyDialog dialog resource ID to base class CCommonDialog.I am trying to draw a circle on the dialog. So in CMyDialog::OnPaint()
I tried the below code:
CPaintDC dc(this);
CRect rect;
GetWindowRect(&rect);
ScreenToClient(rect);
dc.Ellipse(rect);
While running i am seeing a part of the bigger circle. Its not fitting to the dialog. So i believe GetWindowRect is not giving me proper dialog dimension.
Can anyone please help on this. NOTE: CommonDlg is one DLL and CMyDlg is anther dll. Thanks
Upvotes: 1
Views: 375
Reputation: 4395
Use this code.
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect); //to get client area only
dc.Ellipse(rect);
the function you are using, GetWindowRect(&rect);
It will include title bar of your window also, so in that area your Ellipse
will be clipped. So as you need to draw on client area only, you should use GetClientRect(&rect);
Upvotes: 1