Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
12-12-2022, 09:24 AM
(This post was last modified: 12-12-2022, 09:28 AM by SMcNeill.)
Code: (Select All) Type POINTAPI
X As Long
Y As Long
End Type
Dim WinMse As POINTAPI
Declare Dynamic Library "Gdi32"
Function CreateEllipticRgn%& (ByVal x1&, Byval y1&, Byval x2&, Byval y2&)
End Declare
Declare Dynamic Library "User32"
Function GetWindowLongA& (ByVal hwnd As Long, Byval nIndex As Long)
Function SetWindowLongA& (ByVal hwnd As Long, Byval nIndex As Long, Byval dwNewLong As Long)
Function SetWindowPos& (ByVal hwnd As Long, Byval hWndInsertAfter As Long, Byval x As Long, Byval y As Long, Byval cx As Long, Byval cy As Long, Byval wFlags As Long)
Function SetWindowRgn (ByVal windowhandle%&, Byval region%&, Byval redraw%%)
Function GetCursorPos (lpPoint As POINTAPI)
Function GetKeyState% (ByVal nVirtKey As Long) 'reads Windows key presses independently
End Declare
GWL_STYLE = -16
WS_VISIBLE = &H10000000
Screen _NewImage(720, 720, 32)
_ScreenHide
hwnd& = _WindowHandle
winstyle& = GetWindowLongA&(hwnd&, GWL_STYLE)
a& = SetWindowLongA&(hwnd&, GWL_STYLE, winstyle& And WS_VISIBLE)
a& = SetWindowPos&(hwnd&, -2, 0, 0, 0, 0, 39)
rgn%& = CreateEllipticRgn(0, 0, _Width - 1, _Height - 1)
result = SetWindowRgn(hwnd&, rgn%&, -1)
magnify = -1
_ScreenShow
zoom = 5
Do
update = (update + 1) Mod 6
Cls , 0
m = GetCursorPos(WinMse)
If GetKeyState(17) < 0 Then 'CTRL +
If GetKeyState(&HBD) < 0 Then zoom = zoom + .2
If GetKeyState(&HBB) < 0 Then zoom = zoom - .2
If GetKeyState(Asc("M")) < 0 Then 'M for MAGNIFY
magnify = Not magnify
If magnify Then _ScreenShow Else _ScreenHide
_Delay .2 'give the user time to get their fat fingers off the CTRL-M keys so we don't have multi on/off events instantly.
End If
If GetKeyState(Asc("Q")) < 0 Then System 'Q for QUIT
If GetKeyState(Asc("P")) < 0 Then _ScreenMove WinMse.X - 320, WinMse.Y - 320 'P for POSITION
End If
If zoom < .2 Then zoom = .2
If zoom > 10 Then zoom = 10
If update = 1 Then
If DTI Then _FreeImage DTI
DTI = _ScreenImage
End If
_PutImage , DTI, 0, (WinMse.X - 50 * zoom, WinMse.Y - 50 * zoom)-(WinMse.X + 50 * zoom, WinMse.Y + 50 * zoom)
_Limit 30
oldx = WinMse.X: oldy = WinMse.Y
_Display
Loop
Ever have a screen where everything is just too small to read? Or maybe it's one where you wish you could easily zoom out on so you could see how it'd look on a higher resolution device? Ever wish QB64-PE could solve the problem for you?
WELL, NOW IT CAN!!
Presenting the one and only, limited time offer, for only three easy payments of $49.97, Windows Magnifier!
IT MAKES THINGS BIGGER! it can make things smaller. It can make your wife yell, "WOWZERS!!", when you step out of the shower and she sees you on your bathroom security cam! Just buy now and pay later, and you can have the power of CONTRL-M in the palm of your hands!!
and what's control-m, you ask?
WHY IT'S NOTHING LESS THAN THE MARVELOUS, AMAZING, STUPENDIOUS, ASTOUNDING HOTKEY TO YOUR OWN WINDOWS MAGNIFIER!! Written completely in QB64-PE!
Zoom in with CONTROL-PLUS. Zoom out with CONTROL-MINUS. Position it wherever you want with CONTROL-P, and then when you're done, you can CTRL-Q to QUIT it!
I'm the Ghost of Milly Hay Bayes, and I approve this product 100%!!!
Posts: 3,964
Threads: 176
Joined: Apr 2022
Reputation:
219
Ah so we can tell a gator from a bird
b = b + ...
Posts: 276
Threads: 14
Joined: Apr 2022
Reputation:
27
I couldn't get it to display a round magnifier. Not sure what I'm doing wrong. It shows a jumble of magnifications in a square screen, which I'm assuming should be hidden...
I did something similar at: https://qb64phoenix.com/forum/showthread.php?tid=741
That one grew out of an old riflescope effect I wrote while playing with _PUTIMAGE.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
(12-12-2022, 12:49 PM)OldMoses Wrote: I couldn't get it to display a round magnifier. Not sure what I'm doing wrong. It shows a jumble of magnifications in a square screen, which I'm assuming should be hidden...
I did something similar at: https://qb64phoenix.com/forum/showthread.php?tid=741
That one grew out of an old riflescope effect I wrote while playing with _PUTIMAGE.
What OS are you using. I didn't think to check for what releases the commands worked with. It may be your OS doesn't support the circle routine.
Posts: 728
Threads: 119
Joined: Apr 2022
Reputation:
106
12-12-2022, 01:06 PM
(This post was last modified: 12-12-2022, 01:07 PM by Dav.)
Nice. It's bigger than mine was that's for sure. And your sales pitch is way better. I'm getting the square too, using Windows 7 32-bit.
Petr made a version here that uses no API's but _MAPTRIANGLE, however I don't think it's Linux friendly because of _SCREENIMAGE. Still cool though.
- Dav
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
(12-12-2022, 01:06 PM)Dav Wrote: Nice. It's bigger than mine was that's for sure. And your sales pitch is way better. I'm getting the square too, using Windows 7 32-bit.
Petr made a version here that uses no API's but _MAPTRIANGLE, however I don't think it's Linux friendly because of _SCREENIMAGE. Still cool though.
- Dav
That's it then. I went and looked up the requirements. At the bottom of the list is:
[quote]
ext-ms-win-ntuser-draw-l1-1-0 (introduced in Windows 8)[\quote]
So it's Windows 8 and above, for the SetWindowRgn function -- and it's the one making our circle.
Kind of odd how it still compiles and doesn't error out with a "Function not found" type statement, though.
Posts: 2,169
Threads: 222
Joined: Apr 2022
Reputation:
103
I go the other route. Instead of Windows Magnifier, I wear Google glasses. My wife likes them, too. Oh, shes says they look stupid as hell, but she really appreciates the auto-complete function.
Magnification 10 Mr. Sulu! Works better on my 1278 x 768 resolution at that setting.
Did you consider trying this out with the app running as a transparent window?
Press Esc to quit. Change level to 200 on another run to see that there is really something covering your screen.
Code: (Select All) CONST HWND_TOPMOST%& = -1
CONST SWP_NOSIZE%& = &H1
CONST SWP_NOMOVE%& = &H2
CONST SWP_SHOWWINDOW%& = &H40
DECLARE DYNAMIC LIBRARY "User32"
FUNCTION GetWindowLongA& (BYVAL hwnd AS LONG, BYVAL nIndex AS LONG)
FUNCTION SetWindowPos& (BYVAL hWnd AS LONG, BYVAL hWndInsertAfter AS _OFFSET, BYVAL X AS INTEGER, BYVAL Y AS INTEGER, BYVAL cx AS INTEGER, BYVAL cy AS INTEGER, BYVAL uFlags AS _OFFSET)
FUNCTION SetWindowLongA& (BYVAL hwnd AS LONG, BYVAL nIndex AS LONG, BYVAL dwNewLong AS LONG)
FUNCTION GetForegroundWindow&
FUNCTION SetLayeredWindowAttributes& (BYVAL hwnd AS LONG, BYVAL crKey AS LONG, BYVAL bAlpha AS _UNSIGNED _BYTE, BYVAL dwFlags AS LONG)
END DECLARE
SCREEN _NEWIMAGE(_DESKTOPWIDTH, _DESKTOPHEIGHT, 32)
_SCREENMOVE 0, 0
GWL_STYLE = -16
ws_border = &H800000
WS_VISIBLE = &H10000000
_TITLE "Transparent Window"
DIM hwnd AS LONG
hwnd = _WINDOWHANDLE
_DELAY .1
Level = 0 ' Range 0 - 255
SetWindowOpacity hwnd, Level
winstyle2& = GetWindowLongA&(hwnd, GWL_STYLE)
winstyle& = -12582913
a& = SetWindowLongA&(hwnd, GWL_STYLE, winstyle& AND WS_VISIBLE) ' AND NOT WS_VSCROLL) ' AND NOT ws_border)
a& = SetWindowPos&(hwnd, 0, 0, 0, 0, 0, 39)
DO
_LIMIT 5
IF INKEY$ = CHR$(27) THEN EXIT DO
LOOP
SYSTEM
SUB SetWindowOpacity (hwnd AS LONG, Level)
DIM Msg AS LONG
CONST G = -20
CONST LWA_ALPHA = &H2
CONST WS_EX_LAYERED = &H80000
Msg = GetWindowLongA&(hwnd, G)
Msg = Msg OR WS_EX_LAYERED
action = SetWindowLongA&(hwnd, G, Msg)
action = SetLayeredWindowAttributes(hwnd, 0, Level, LWA_ALPHA)
END SUB
I imagine the two would play well together, and that way your magnifier window isn't part of the desktop.
Pete
Posts: 301
Threads: 16
Joined: Apr 2022
Reputation:
51
I don't trust Steve with a monocular
Posts: 2,169
Threads: 222
Joined: Apr 2022
Reputation:
103
I scope you're kidding.
Pete
Shoot first and shoot people who ask questions, later.
Posts: 476
Threads: 25
Joined: Nov 2022
Reputation:
45
(12-12-2022, 09:24 AM)SMcNeill Wrote: Code: (Select All) Ever have a screen where everything is just too small to read? Or maybe it's one where you wish you could easily zoom out on so you could see how it'd look on a higher resolution device? Ever wish QB64-PE could solve the problem for you?
This is rad! I've longed for a magnifier that actually didn't try to smooth the jaggies. All the ones I've found (including Glassbrick, which I paid for on GumRoad), have this 'smoothing' antialiasing nonsense hard coded into them.
This one is just what the doctor ordered.
Is there a way to keep it on top?
Also - is the first post the latest version? I'm new to these parts and not sure what the protocol is or if you guys modify the OP source with iterations, etc. if they evolve in thread?
|