Solved

X Marks The Spot

Posted on 2000-03-15
2
153 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Form ownership 4 127
find a node in VST 2 81
tvirtualstringtree freeze when load too manny images 10 80
delphi popmenu non latine charcters 3 35
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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