Graphic Control - Maintain Virtual Position

Category: Controls - .Techniques

Date: 02-16-2022

Return to Index


 
 
'Compilable Example:  (Jose Includes)
#Compiler PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg,hFont As Dword
%IDC_Graphic = 500
 
Function PBMain() As Long
   Dialog New Pixels, 0, "Parent",300,300,400,600, %WS_OverlappedWindow To hDlg
   Control Add Graphic, hDlg, %IDC_Graphic, "",10,10,75,25, %WS_Border
   Graphic Attach hDlg, %IDC_Graphic
   Graphic Set Virtual 1000,1000
   Graphic Color %Black, %White
   Graphic Clear
   Font New "Comic Sans", 16,1 To hFont
   Graphic Set Font hFont
   Dialog Show Modal hDlg Call DlgProc
End Function
 
CallBack Function DlgProc() As Long
   Local w,h,i As Long
   Static xGraphic, yGraphic As Long
   Select Case Cb.Msg
      Case %WM_InitDialog
         For i = 0 To 100
            Graphic Print "Now is the " + Trim$(Str$(i))
            Graphic Box (0,Graphic(Pos.Y))-(2000,Graphic(Pos.Y)+80), ,%rgb_LightBlue, %rgb_LightBlue
            Graphic Print : Graphic Print : Graphic Print : Graphic Print
         Next i
      Case %WM_Sizing
         xGraphic = Graphic(Pos.X) + Graphic(View.X)
         yGraphic = Graphic(Pos.Y) + Graphic(View.Y)
      Case %WM_Size
         Dialog Get Client hDlg To w,h
         Control Set Size hDlg, %IDC_Graphic, w-20,h-20
         Graphic Set View xGraphic,yGraphic
   End Select
End Function
 
'gbs_00786
'Date: 03-10-2012


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm