Code: Select all
////////////// Programmer predefined variables //////////////
//Dialog size
Let>Wide=800
Let>High=200
//Magnification factor
Let>Magnification=2
/////////////////////////////////////////////////////////////
//////////////// Calculated variables ///////////////////////
GoSub>SetUp
//////////////// The rest of the program ////////////////////
/////////////// A dialog for custom magnification ///////////
Dialog>Dialog7
Caption=Custom
Width=150
Height=110
Top=CENTER
Left=CENTER
Edit=msEdit1,50,25,44,
Label= Magnification,40,8,true
Button=Ok,35,50,75,25,3
Default=Ok
EndDialog>Dialog7
/////////// Dialog to display the magnified area ////////////
Dialog>Dialog1
Caption=%Magnification%X Magnify
Width=%Wide%
Height=%High%
Top=200
Left=48
Button=1X,0,0,20,20,11
Button=2X,20,0,20,20,12
Button=3X,40,0,20,20,13
Button=4X,60,0,20,20,14
Button=5X,80,0,20,20,15
Button=6X,100,0,20,20,16
Button=7X,120,0,20,20,17
Button=8X,140,0,20,20,18
Button=9X,160,0,20,20,19
Button=10X,180,0,20,20,20
Button=Other,200,0,30,20,21
EndDialog>Dialog1
Show>Dialog1
//////////// Acquire the needed "Device Context" /////////////
// For more on "Device Context", see the Microsoft MSDN web site.
LibFunc>user32,GetDC,HDC1,Dialog1.handle
LibFunc>user32,GetDC,HDC3,0
Label>Loop
GetDialogAction>Dialog1,res1
// Added the following to set the dialog title to reflect current magnification
LibFunc>user32,SetWindowTextA,res,dialog1.handle,%Magnification%X Magnify
If>res1=2
Exit>0
EndIf
If>res1=21
Label>Redo_Custom
Show>Dialog7,res7
ResetDialogAction>Dialog1
ResetDialogAction>Dialog7
GetDialogAction>Dialog1,res1
GetDialogAction>Dialog7,res7
// User me_again's simple method to test for numeric input
Let>test=%Dialog7.msEdit1%+1
Separate>test,+,test
If>%test_count%<2
Let>Magnification=Dialog7.msEdit1
GoSub>SetUp
Else
Goto>Redo_Custom
EndIf
EndIf
If>res1<>0
Let>Magnification=%res1%-10
ResetDialogAction>Dialog1
GoSub>SetUp
EndIf
Let>WIN_USEHANDLE=1
GetWindowSize>dialog1.handle,WinW,WinH
Let>WIN_USEHANDLE=0
If>{(%WinW%<>%Wide%)or(%WinH%<>%High%)}
Let>Wide=%WinW%
Let>High=%WinH%
GoSub>SetUp
EndIf
GetCursorPos>CurX,CurY
Sub>CurX,%UpperLeftAreaX%
Sub>CurY,%UpperLeftAreaY%
Wait>0.01
/////// The function that's doing the display
LibFunc>Gdi32,StretchBlt,SBres,HDC1,0,0,%Wide%,%High%,HDC3,CURX,CURY,%AreaX%,%AreaY%,13369376
GoSub>DrawLine,Dialog1.handle,1,0,%CrossHairDown%,%CrossHairY%,%CrossHairUp%,%CrossHairY%
GoSub>DrawLine,Dialog1.handle,1,0,%CrossHairX%,%CrossHairLeft%,%CrossHairX%,%CrossHairRight%
Goto>Loop
//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd
SRT>DrawLine
LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine
SRT>SetUp
Let>AreaX={round(%Wide%/%Magnification%)}
Let>AreaY={round(%High%/%Magnification%)}
Let>UpperLeftAreaX={round(%AreaX%/2)}
Let>UpperLeftAreaY={round(%AreaY%/2)}
Let>CrossHairX={round(%Wide%/2)}
Let>CrossHairY={round(%High%/2)}
Let>CrossHairUp=%CrossHairX%+10
Let>CrossHairDown=%CrossHairX%-10
Let>CrossHairRight=%CrossHairY%+10
Let>CrossHairLeft=%CrossHairY%-10
END>SetUp