I have the same setup and it looks correct to me.
Code: Select all
; -----------------------------------------------------------------------------
; Name: ScreenSize.pb
; Description: see below
; Author: Blueb
; Date: 2023-03-23
; ---------------------------------------------------------------------------------------
; Needed - Needed a way to determine the optimum screen size for my six different monitors
; Goal - Print a visual of the final result with desired screen measurements.
; ----------------------------------------------------------------------------------------
;XIncludeFile "PurePdfModule.pbi"
EnableExplicit
;filename
Global file$="ScreenSize.pdf"
Global Width.s, Height.s, ShowText.s
Global PdfHeight, PdfWidth
;- Enumerations
Enumeration Window
#Window_0
EndEnumeration
Enumeration Gadgets
#Txt_1
#Txt_2
#Txt_3
EndEnumeration
Enumeration Font
#Font_0
EndEnumeration
;- Load Fonts
LoadFont(#Font_0, "Arial", 16)
;- Declare
Declare Resize_Window_0()
Declare Open_Window_0(X = 0, Y = 0, Width = 800, Height = 1280)
Procedure Resize_Window_0()
Protected ScaleX.f, ScaleY.f, Width.s, Height.s, ShowText.s
Static Window_0_WidthIni, Window_0_HeightIni
If Window_0_WidthIni = 0
Window_0_WidthIni = WindowWidth(#Window_0) : Window_0_HeightIni = WindowHeight(#Window_0)
EndIf
Width.s = Str(WindowWidth(#Window_0))
Height.s = Str(WindowHeight(#Window_0))
PdfHeight = WindowHeight(#Window_0)
PdfWidth = WindowWidth(#Window_0)
ShowText.s = Width + " X " + Height
SetGadgetText(#Txt_1, ShowText)
;
EndProcedure
Procedure Open_Window_0(X = 0, Y = 0, Width = 800, Height = 1280)
Define.s DesiredText.s
If OpenWindow(#Window_0, X, Y, Width, Height, "Title", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
SetWindowColor(#Window_0, $AED8EE)
TextGadget(#Txt_1, 300, 10, 200, 40, "Text_1", #PB_Text_Center | #SS_CENTERIMAGE)
SetGadgetColor(#Txt_1, #PB_Gadget_FrontColor, $FF0000)
SetGadgetColor(#Txt_1, #PB_Gadget_BackColor, $FFFFFF)
SetGadgetFont(#Txt_1, FontID(#Font_0))
EditorGadget(#Txt_2, 10, 80, 780, 240, #PB_Editor_ReadOnly|#PB_Editor_WordWrap)
DesiredText.s = "Many of us program for different monitors, and it gets hard to remember the best sizes for each monitor (I have 6 different setups)... so determining the best visual size for your forms on the actual monitor 'before' commiting to starting your form is a God send. No guessing involved!" + #CRLF$ + " " + #CRLF$
DesiredText = DesiredText + "Just use the corner Grab handles to re-size screen to suit your actual monitor, then a PDF will be created on exit. You can print it, if you desire."+ #CRLF$ + " " + #CRLF$
DesiredText = DesiredText + "It's simple, but effective!"
AddGadgetItem(#Txt_2, 1, DesiredText)
SetGadgetColor(#Txt_2, #PB_Gadget_FrontColor, $FF0000)
SetGadgetColor(#Txt_2, #PB_Gadget_BackColor, $FFFFFF)
SetGadgetFont(#Txt_2, FontID(#Font_0))
TextGadget(#Txt_3, 80, 20, 200, 40, "Current Screen Size:", #PB_Text_Right)
SetGadgetColor(#Txt_3, #PB_Gadget_FrontColor, $FF0000)
SetGadgetColor(#Txt_3, #PB_Gadget_BackColor, $AED8EE)
SetGadgetFont(#Txt_3, FontID(#Font_0))
BindEvent(#PB_Event_SizeWindow, @Resize_Window_0(), #Window_0)
PostEvent(#PB_Event_SizeWindow, #Window_0, 0)
WindowBounds(#Window_0, 100, 100, #PB_Ignore, #PB_Ignore)
EndIf
EndProcedure
CompilerIf (#PB_Compiler_IsMainFile)
;- Main Program
Open_Window_0()
;- Event Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
; ;-----[ Make PDF file on Exit]-----
; If PDF::Create()
; PDF::AddPage()
; PDF::SetFillColor(255,255,255)
; PDF::RoundRect(10,10,75,75,5,PDF::#STYLE_DRAWANDFILL)
; PDF::SetFont("Arial","",20)
; PDF::Text(90,50,Str(PdfHeight) + " Pixels High") ;Height
; PDF::Text(25,100,Str(PdfWidth) + " Pixels Wide") ;Width
; PDF::Save(file$)
; EndIf
; RunProgram(file$)
;-----[ End of PDF ]-----
Break
;-> Event Gadget
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
ForEver
CompilerEndIf