Date: 02-16-2022
Return to Index
created by gbSnippets
'An online Graphic control tutorial may be found at:
'http://www.garybeene.com/power/pb-tutor-controls.htm
'Primary Code:
'Syntax: Control Add Graphic, hDlg, id&, "", x&, y&, wide&, high&[, [style&] [, [exstyle&]]] [[,] Call CallBack]
Control Add Graphic, hDlg, 301,"", 10,10,30,30, %WS_Visible Or %SS_Sunken
'Compilable Example: (Jose Includes)
'The following compilable code demonstrates a dialog with multiple graphic controls,
'a resource file, and an imagelist, Various commands to load/size images in the graphic
'controls are used, as well as some basic drawing commands are demonstrated.
'The Dialog Callback response to a mouse click is demonstrated.
'Controls can also have a Callback function of their own.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Resource "gbsnippets.pbr"
Global hDlg As Dword, hLst As Dword, hTemp As Dword
Global style&, extstyle&
Function PBMain() As Long
Dialog New Pixels, 0, "Graphic Control Test",300,300,450,380, %WS_SysMenu, 0 To hDlg
'create imagelist w,h,depth,size
ImageList New Icon 16,16,32,3 To hLst
ImageList Add Icon hLst, "x"
ImageList Add Icon hLst, "y"
ImageList Add Icon hLst, "check"
'create graphic control - various frames
Control Add Graphic, hDlg, 301,"", 10,10,30,30, %WS_Visible Or %SS_Sunken
Control Add Graphic, hDlg, 302,"", 50,10,30,30, %WS_Visible Or %WS_DlgFrame
Control Add Graphic, hDlg, 303,"", 90,10,30,30, %WS_Visible Or %WS_Border
'create graphic control
style& = %WS_Visible Or %SS_Sunken Or %SS_Notify
Control Add Graphic, hDlg, 110,"", 10,50,100,100, style&
Control Add Graphic, hDlg, 120,"", 120,50,100,100, style&
Control Add Graphic, hDlg, 130,"", 230,50,100,100, style&
Control Add Graphic, hDlg, 210,"", 10,160,100,100, style&
Control Add Graphic, hDlg, 220,"", 120,160,100,100, style&
Control Add Graphic, hDlg, 230,"", 230,160,100,100, style&
Control Add Graphic, hDlg, 310,"", 10,270,100,100, style&
Control Add Graphic, hDlg, 320,"", 120,270,100,100, style&
Control Add Graphic, hDlg, 330,"", 230,270,100,100, style&
'PBR FILE
Graphic Attach hDlg, 110
Graphic Render "cowgirl", (0,0)-(100,100) 'same size (could resize)
'BMP FILE bmpname$, (x,y)-(x2,y2) <-- dest coordinates
Graphic Attach hDlg, 120
Graphic Render "icons/cowgirl.bmp", (0,0)-(100,100) 'same size (could resize)
'IMAGELIST (x,y), hList, index&, overlay&, style&
Graphic Attach hDlg, 130
Graphic ImageList (0,0), hLst, 1,0, %ILD_Normal
Graphic ImageList (50,50), hLst, 2,0, %ILD_Normal
Graphic ImageList (10,70), hLst, 3,0, %ILD_Normal
Graphic ImageList (70,30), hLst, 3,0, %ILD_Normal
'COPY hSource, id&
Graphic Attach hDlg, 210 'source
Graphic Copy hDlg, 110 'copy all to 0,0
Graphic Attach hDlg, 220 'source
Graphic Copy hDlg, 110 To (20,20) 'copy all to 40,40
Graphic Attach hDlg, 230 'source
Graphic Copy hDlg, 110, (0,0)-(40,80) To (40,10) 'copy part to 40,40
'STRETCH
Graphic Attach hDlg, 310 'copy all to 0,0
Graphic Stretch hDlg, 110, (0,0)-(100,100) To _
(0,0)-(50,50) 'copy part+shrink
Graphic Attach hDlg, 320
Graphic Stretch hDlg, 110, (0,0)-(100,100) To _
(0,0)-(200,200) 'copy part+expend
'DRAWING
Graphic Attach hDlg, 330
Graphic Print "Print";" here"
Graphic Color %Red
Graphic Print
Graphic Print "Now here!"
Graphic Color %Blue
Graphic Print
Graphic Print "and here!"
Graphic Ellipse (20,20)-(70,95), %Black
Graphic Ellipse (25,15)-(35,25), %Black, %Red
Graphic Line (80,10)-(50,100), %Black
Graphic Paint Border (60,75),%Green, %Black
Graphic Paint Border (60,75),%Green, %Black
Graphic Box (75,60)-(90,90),50, %White, %Red
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 110 AND _
CB.Ctlmsg = %STN_Clicked Then
MsgBox "Clicked!"
End If
End Function
'gbs_00089
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm