Device context of dialogbox

i want to use graphic gunction line recrcangle /LineTO/MoveTo on dialog box.
i don't know how to get dc of that & where to write code ?
jaydeepAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mikeblasCommented:
Add a handler for WM_PAINT.

In that handler, create a local instance of CPaintDC.  Use the CPaintDC for your painting.

..B ekiM
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

We can use CClientDC as

CClientDC dc(this);
dc.MoveTo(10,10);
dc.LineTo(100,100);

Try it out.
VinExpert
0
jaydeepAuthor Commented:
Hello mikeblas & vinexpert
you can't add WM_PAINT handler to CDialog class.there is WM_CTLCOLOR handler which is for controls.you can't draw on dialog box.
Also by declaring object of CClientDC
it doesn't work .
i have tried it.

0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

jaydeepAuthor Commented:
Hello mikeblas & vinexpert
you can't add WM_PAINT handler to CDialog class.there is WM_CTLCOLOR handler which is for controls.you can't draw on dialog box.
Also by declaring object of CClientDC
it doesn't work .
i have tried it.

0
Vinayak KumbarSr Program ManagerCommented:
Hi,

I was able to draw the line on the dialog's client area by using

CClientDC dc(this);
dc.MoveTo(10,10);
dc.LineTo(100,100);

Try it out.
VinExpert
0
mikeblasCommented:
> you can't add WM_PAINT handler to CDialog class.

Of course you can! Look at the WM_PAINT handler in the code AppWizard gives you when you create a dialog-based project. That code shows both handling WM_PAINT in a dialog, and using CPaintDC.

 > there is WM_CTLCOLOR handler which is for controls.

Right. But you asked about painting on a dialog box, not on controls. Did you really mean to ask about painting on the controls within a dialog box?

 > you can't draw on dialog box.

Yes, you absolutely can.

CClientDC can work, but it swims against the Windows event-driven painting model.

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mikeblasCommented:
Why a "B" and not an "A"? What more information did you need?

..B ekiM
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.