Solved

X Marks The Spot

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

22 Experts available now in Live!

Get 1:1 Help Now