Link to home
Start Free TrialLog in
Avatar of viswanathat
viswanathat

asked on

CPaintDC VC++

Hi

I want to partially paint On a third party spread sheet control cell . For this,  the control gives API to get the current cell's Rect Value. If I paint on this it is not paining..

-- code  --------------
CWnd* wnds;
wnds =  GetDlgItem(IDC_TEST);
CPaintDC dc(wnds);

CRECT lpRect;
BOOL b = VarList.MLGetCellRect(hwnd, 1,1,&lpRect);
lpRect.Right  -= 10;

CBrush *cbr = new CBrush;
cbr->CreateSolidBrush(RGB(0,0,0));

dc.FillRect(lpRect,cbr);

------------------------------
Even for a edit box in a  dialog box we are not able to paint by  getting its coordinates in CRect.

But if we create one new Window (using CWnd::Create function) on the dialog and paint on the window it is allowing me to paint..

What can be done to draw on prebuilt controls..?

Regards

Viswanath AT.

 
Avatar of Zoppo
Zoppo
Flag of Germany image

Hi viswanathat,

try it without using CPaintDC ... CPaintDC is especially designed to handle painting
required through a WM_PAINT message (so it includes calls to BeginPaint, EndPaint
and even sets clipping region to invalidate region of the window).

Try it simply like this:

CWnd* wnds;
wnds =  GetDlgItem(IDC_TEST);
CDC* pDC = wnds->GetDC();

// do the paint here with pDC
...

// cleanup
wnds->ReleaseDC( pDC );


hope that helps,

ZOPPO
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of viswanathat
viswanathat

ASKER

It has solved the problem..

I have also increased the points to 50

Tanx a lot..

Regards..

Viswanath AT.
You're welcome,

have a nice day,

regards,

ZOPPO