|Join the Discussion
|"Post your questions, concerns, views and comments to this article..."
Few weeks ago, I saw a little program that was able to display a magnified view of whatever is beneath the mouse cursor. "Wow really cool, can you do something like that, Zarko?" was my first thought. (...2-3 programming days...)
Read on, and see what I have made.
One form, one image control, one panel, few labels, a button, timer, and a slider. Put image and panel on the form. Place all other controls on the panel. Now, we have everything we need. Before coding, change some properties of those controls. Finally, do some coding (precisely do some API coding). Download full project (6 K).
The idea is to track mouse cursor movement over the screen, and show enlarged (2x to 8x) section around the cursor, in the image control.
To the Screen
Here are some snippets of the program.
// Magnify screen iff app is not iconic
If not IsIconic(Application.Handle) then begin
// Get cursor coordinates
// PosForm represents the rectangle with the
// Form (image control) coordinates.
//Show magnified screen
//if cursor is outside the form.
If not PtInRect(PosForme,Kursor) then begin
// Code below is used to magnify selected
// portion of the screen. With a few
// modifications you could use
// it to shrink the screen
iTmpX:=iWidth / (Slider.Position * 4);
iTmpY:=iHeight / (Slider.Position * 4);
//Retrieve a handle of a desktop window.
//Transfer part of the screen image on TImage.
// Be sure to process all Windows messages.
end; // IsIconic
It is obvious, that program could have few modifications just to look more like loupe (precisely: rectangular loupe). First why not hide title bar, and enable dragging without clicking on the caption of the form. Second, it may be good to limit form resizing. (In fact, I have included this one)
I hope you will find it useful (130 K). Don't hesitate to alter code (6 K) so that it suits you better.
Some related components: