?
Solved

X Marks The Spot

Posted on 2000-03-15
2
Medium Priority
?
155 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

765 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