Click here to Skip to main content
15,886,258 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionEvent Handler Wizard in VC++ 7? Pin
Matt Newman27-Feb-02 11:01
Matt Newman27-Feb-02 11:01 
GeneralQuestion about C++ Pin
Loli1027-Feb-02 10:06
Loli1027-Feb-02 10:06 
GeneralRe: Question about C++ Pin
Chris Losinger27-Feb-02 10:14
professionalChris Losinger27-Feb-02 10:14 
GeneralRe: Question about C++ Pin
Carlos Antollini27-Feb-02 10:19
Carlos Antollini27-Feb-02 10:19 
GeneralRe: Question about C++ Pin
Roger Wright27-Feb-02 13:13
professionalRoger Wright27-Feb-02 13:13 
GeneralMCAD for C++ Pin
TigerNinja_27-Feb-02 9:24
TigerNinja_27-Feb-02 9:24 
GeneralC++ Pin
dannyhoare@nowhere.com27-Feb-02 9:16
dannyhoare@nowhere.com27-Feb-02 9:16 
GeneralRe: C++ Pin
Paul M Watt27-Feb-02 12:48
mentorPaul M Watt27-Feb-02 12:48 
Create a message handler for your WM_PAINT message in the window that you want to draw on.

Inside WM_PAINT add this code assuming hWnd is the handle to your window:

PAINTSTRUCT ps;
HDC hdc;

hdc = ::BeginPaint(hWnd, &ps);

There are a number of functions that you can use to paint on the HDC handle that you have just created, lookup "device context [win32]" in msdn.

You would add these functions here. Here is an example of how to paint two lines and a circle.

// Set the initial pen position for the pen that will draw the line. When you create the DC,
// the default position is at (0,0).
::MoveToEx(hdc, 100, 100, NULL);
// Draw a horizontal line from the current position (100,100) to (200,100).
::LineTo(hdc, 200, 100);
// Draw a line at 45 degrees current position (200,100) to (300,200).
::LineTo(hdc, 200, 100);
// Draw a circle. The circle function does not depend on the current pen position.
::Ellipse(hdc, 100, 100, 200, 200);

Finally, in order to free the DC that you have created with BeginPaint, you must call EndPaint.

::EndPaint(hWnd, &ps);

After reading your message again, I am not sure if you are asking how to paint to the desktop. If so, instead of using BeginPaint in order to create your DC, use this call:

hdc = CreateDC("DISPLAY", NULL, NULL, NULL);

or

hdc = GetDC(NULL);

In either case, this will only create a DC to the primary monitor. If you are programming for a computer with multi-monitor support you will need to use EnumDisplayMonitors to determine which dirver to create the DC for.

Then you will need to use this function to release the DC:

::DeleteDC(hdc);

or

::ReleaseDC(NULL);

Depending on which function you used to allocate the DC.

GeneralRe: C++ Pin
Christian Graus27-Feb-02 15:19
protectorChristian Graus27-Feb-02 15:19 
GeneralRe: C++ Pin
Nish Nishant27-Feb-02 17:14
sitebuilderNish Nishant27-Feb-02 17:14 
GeneralRe: C++ Pin
Christian Graus27-Feb-02 17:31
protectorChristian Graus27-Feb-02 17:31 
GeneralRe: C++ Pin
Nish Nishant27-Feb-02 17:40
sitebuilderNish Nishant27-Feb-02 17:40 
GeneralWildcard Delete Without DOS Window Pin
27-Feb-02 7:42
suss27-Feb-02 7:42 
GeneralRe: Wildcard Delete Without DOS Window Pin
Shog927-Feb-02 7:54
sitebuilderShog927-Feb-02 7:54 
GeneralRe: Wildcard Delete Without DOS Window Pin
Mandy27-Feb-02 8:19
Mandy27-Feb-02 8:19 
GeneralRe: Wildcard Delete Without DOS Window Pin
Michael Dunn27-Feb-02 8:17
sitebuilderMichael Dunn27-Feb-02 8:17 
GeneralRe: Wildcard Delete Without DOS Window Pin
Alvaro Mendez27-Feb-02 10:51
Alvaro Mendez27-Feb-02 10:51 
QuestionTwo state pushbuttons??? Pin
alex.barylski27-Feb-02 7:07
alex.barylski27-Feb-02 7:07 
AnswerRe: Two state pushbuttons??? Pin
Paul M Watt27-Feb-02 7:26
mentorPaul M Watt27-Feb-02 7:26 
GeneralRe: Two state pushbuttons??? Pin
alex.barylski27-Feb-02 7:55
alex.barylski27-Feb-02 7:55 
GeneralClass reutilisation? (newbie) Pin
Joan M27-Feb-02 6:23
professionalJoan M27-Feb-02 6:23 
GeneralRe: Class reutilisation? (newbie) Pin
Joaquín M López Muñoz27-Feb-02 6:30
Joaquín M López Muñoz27-Feb-02 6:30 
GeneralRe: Class reutilisation? (newbie) Pin
Alvaro Mendez27-Feb-02 11:55
Alvaro Mendez27-Feb-02 11:55 
GeneralOpenGL Pin
Mazdak27-Feb-02 5:46
Mazdak27-Feb-02 5:46 
GeneralRe: OpenGL Pin
Mandy27-Feb-02 7:45
Mandy27-Feb-02 7:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.