Solved

Draw on screen like in screen saver

Posted on 1998-11-11
3
174 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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