Uses "UI"
' -- ID numbers of controls
Begin ControlID
%Main_Viewport
End ControlID
Begin Const
%MAIN_WIDTH = 320
%MAIN_HEIGHT = 240
End Const
' -- Create dialog here
Function TBMain()
Local hDlg As DWord
Local hViewport As DWord
Dialog New Pixels, 0, "Minimalistic viewport demo",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
' -- Place controls here
hViewport = Control Add VIEWPORT, hDlg, %Main_Viewport, "", 10, 10, %MAIN_WIDTH-20, %MAIN_HEIGHT-20
Dialog_WithCanvas(hViewport)
Dialog Show Modal hDlg, Call cbDialog
End Function
' -- Callback for main dialog
CallBack Function cbDialog()
' -- Test for messages
Select Case CBMSG
Case %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
Case %WM_COMMAND
' -- You can handle controls here
Case %WM_CLOSE
' -- Put code to be executed before dialog end here
End Select
End Function
Begin ControlID
%Viewport_Canvas
End ControlID
'----------------------------------------------------------------------------
Function Dialog_WithCanvas(hViewPort As DWord)
Local hDlg As Long
Dialog New Pixels, hViewPort, "", 0, 0, 500, 500, %WS_CHILD Or %WS_CLIPCHILDREN To hDlg
Control Add Canvas , hDlg, %Viewport_Canvas, "", 0, 0, 500, 500
Canvas_Attach(hDlg, %Viewport_Canvas, TRUE)
Canvas_Clear(%BLACK)
Canvas_Line((0,0), (500, 500), %GREEN)
Canvas_Line((500,0), (0, 500), %GREEN)
Canvas_Redraw
Dialog Show Modeless hDlg, Call cbCanvasDialog
ViewPort_SetChild(hViewPort, hDlg, FALSE )
Function = hDlg
End Function
' -- Callback for canvas dialog
CallBack Function cbCanvasDialog()
' -- Test for messages
Select Case CBMSG
Case %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
Case %WM_COMMAND
' -- You can handle controls here
Case %WM_CLOSE
' -- Put code to be executed before dialog end here
End Select
End Function
Bookmarks