Date: 02-16-2022
Return to Index
created by gbSnippets
Case %IDT_CopyImage
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Resource "gbsnippets.pbr"
Global hDlg, hGraphic, hBMP As DWord
%ID_Graphic = 200
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 150,"Copy", 50,10,100,20
Control Add Button, hDlg, 175,"Copy II", 50,40,100,20
Control Add Graphic, hDlg, %ID_Graphic,"", 50,70,100,100
Control Handle hDlg, %ID_Graphic To hGraphic
Graphic Attach hDlg, %ID_Graphic
Graphic Render "cowgirl", (0,0)-(99,99)
Graphic Bitmap New 100,100 TO hBMP
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 150 AND CB.Ctlmsg = %BN_Clicked Then
'Copy I
Graphic Attach hDlg, %ID_Graphic 'repeated here in case I press 2nd button
Clipboard Reset
Clipboard Set Bitmap hGraphic
End If
If CB.Msg = %WM_Command AND CB.Ctl = 175 AND CB.Ctlmsg = %BN_Clicked Then
'Copy II
Graphic Attach hBMP,0
Graphic Copy hGraphic, 0
Clipboard Reset
Clipboard Set Bitmap hBMP
End If
End Function
'gbs_00508
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm