Date: 02-16-2022
Return to Index
created by gbSnippets
'This code shows how to get the dimensions of a resource bitmap.
'Compiler Comments:
'This code was written to compilete in PBWin10. To compile with PBWin9, make
'these changes:
'1. Replace the #Resource line with this:
#Resource "gbsnippets.pbr"
'2. Replace the Graphic Get Canvas line with this:
Graphic Get Size To imgW, imgH
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Resource Bitmap cowgirl "cowgirl.bmp"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local imgH,imgW as Long, hBMP as Dword
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
Graphic Bitmap Load "cowgirl", 0, 0 To hBMP 'put the icon in a memory bitmap 0,0 means normal size
Graphic Attach hBMP, 0
Graphic Get Canvas To imgW, imgH
Graphic Bitmap End
? Format$(imgW) + "x" + Format$(imgH)
End If
End Function
'gbs_00509
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm