Date: 02-16-2022
Return to Index
created by gbSnippets
Bold the center pixel
Allow moving the dialog to a new position/save pos between sessions
Capture the magnified image/color values on exit (simple text file)
Use mouse wheel to zoom in/out
Display color value when the mouse if over the magnified image
Allow enlargement of the color cells
Different cursor
Case %WM_LButtonDown
Dialog Get Size hDlg To w,h
GetCursorPos pt 'screen position
ScreenToClient hDlg, pt 'overlay position
If pt.x < (w-17) Or pt.y < (h-17) Then
'off marker
If Cb.WParam = %MK_LBUTTON Then SendMessage hDlg, %WM_NCLButtonDown, %HTCaption, ByVal %Null ' force drag
Else
SetCapture hDlg
resizePT = pt
Dialog Get Size hDlg To startX,startY
ResizeInWork = 1 'on marker
End If
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE "gbMagnify.exe"
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_Graphic = 500
Global hDlg, hDesktopDC As Dword, pt As PointAPI
Global x,y,w,h,m,n,x1,y1,x2,y2 As Long
Function PBMain() As Long
w = 10 : h = 10 : m = 10 : n = 10
Dialog New Pixels, 0, "gbMagnify",0,0,w*(2*m+1),h*(2*n+1), %WS_Popup To hDlg
Control Add Graphic, hDlg, %IDC_Graphic, "",0,0,(2*m+1)*w,(2*n+1)*h
Graphic Attach hDlg, %IDC_Graphic
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc()
Local w,h As Long
Select Case Cb.Msg
Case %WM_LButtonDown
Dialog Get Size hDlg To w,h
GetCursorPos pt 'screen position
ScreenToClient hDlg, pt 'overlay position
If pt.y < 30 Then
If Cb.WParam = %MK_LBUTTON Then SendMessage hDlg, %WM_NCLButtonDown, %HTCaption, ByVal %Null ' force drag
Else
SetCapture hDlg : hDeskTopDC = GetDC(%Null) : MousePTR 2
End If
Case %WM_MouseMove : If GetCapture = hDlg Then GetCursorPos pt : DrawPixels
Case %WM_LButtonUp : ReleaseCapture : ReleaseDC(%Null, hDeskTopDC) : MousePTR 1
Case %WM_ContextMenu : Dialog End hDlg
End Select
End Function
Sub DrawPixels
For x = -m To m : x1 = (x+m)*w
For y = -n To n : y1 = (y+n)*h
If x=0 and y=0 Then
Graphic Box (x1,y1)-(x1+w-1,y1+h-1),0,%Red,GetPixel(hDeskTopDC,pt.x+x,pt.y+y)
Else
Graphic Box (x1,y1)-(x1+w-1,y1+h-1),0,-1,GetPixel(hDeskTopDC,pt.x+x,pt.y+y)
End If
Next y : Next x
End Sub
'gbs_01101
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm