Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

X Marks The Spot

Posted on 2000-03-15
2
Medium Priority
?
156 Views
Last Modified: 2010-04-04
What I need, is to be able to draw an X (similar to the one used in the expertsexchange logo) at a point defined by x and y which is given by the user of my application.

i.e. If the user has entered 100 for x and 100 for y then the mark will be drawn at 100, 100.

Also, it must be able to be drawn on any area of the desktop (not only on my form). When the user changes one of the values (x or y) the mark must move, leaving the underlying desktop intact.

I thought that this would be easier if I could create a "virtual cursor" (i.e. to have 2 cursors on the screen, my standard cursor plus one to mark the spot) with the crCross cursor. If this can be done I'd prefer it.

Please include code.

Chris.
0
Comment
Question by:she3i3i
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 200 total points
ID: 2619985
Try this lot:

procedure TForm1.Button1Click(Sender: TObject);
var
  dc : hdc;
  X, Y : LONGINT;
begin
  dc := GetDc(0);
  bmpBuffer := TBitmap.Create;
  bmpBuffer.Width := Screen.Width;
  bmpBuffer.Height := Screen.Height;

  BitBlt(bmpBuffer.Canvas.Handle, 0, 0, Screen.Width - 1, Screen.Height - 1, dc, 0, 0, SRCCOPY);

  X := 100;
  Y := 100;

  MoveToEx(Dc, X, Y, nil);
  LineTo(Dc, X + 100, Y + 100);
  MoveToEx(Dc, X + 100, Y, nil);
  LineTo(Dc, X, Y + 100);
  ReleaseDc(0, Dc);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  dc : hdc;
begin
  dc := GetDc(0);

  BitBlt(dc, 0, 0, Screen.Width - 1, Screen.Height - 1, bmpBuffer.Canvas.Handle, 0, 0, SRCCOPY);
  ReleaseDc(0, Dc);
end;

Button1 will snap the desktop and draw your X (crudely), while Button2 will restore it. You can make it a bit more intelligent and just snap the section of the desktop that you're working with

The Neil
0
 
LVL 1

Author Comment

by:she3i3i
ID: 2622551
Very good.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

610 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