Solved

Draw on screen like in screen saver

Posted on 1998-11-11
3
172 Views
Last Modified: 2013-11-20
Hello everyone out there in computerland,

I am new to programing and was wondering how I could draw on the screen?  I mean, I want to really draw on the SCREEN like so I can see the for example lines on the desktop.  I am using MFC and Visual C++.

Thank you!
0
Comment
Question by:ADK
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 220 total points
ID: 1324516
Answer coming...
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324517
To do that, you must first create a window.  You see, the way it works is you take a COPY of the screen and put it in its own window.  Then, you can draw in the window and make it look like you're drawing on the screen.

Here is what you have to do:
- Create your app, using ClassWizard.  Select the dialog based setting.
- Delete all the buttons etc that are in the dialog using the resource editor.
- Change the properties of the dialog window in resource editor so that there is no title bar.

- Add:
   POINT pt;
   GetCursorPos (&pt);
   SendMessage (WM_SYSCOMMAND, SC_MAXIMIZE, pt.y << 16 | pt.x);

   in the "InitDialog" member function.

- Add:
  CPaintDC dc (this); // device context for painting
  CRect rect;
  GetClientRect(rect);

  dc.BitBlt (0, 0, rect.right, rect.bottom,
             GetDesktopWindow ()->GetDC (), 0, 0,
             SRCCOPY);

  to the "else" statement in the OnPaint member function.

At this point, you can draw on the screen using the CDC member functions like LineTo, PolyLine, SetPixel, etc.

If you have any further questions on how to implement this, please feel free to ask.  Thanks!
0
 

Author Comment

by:ADK
ID: 1324518
Good, I think that covers it nicely.  Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now