Date: 02-16-2022
Return to Index
created by gbSnippets
'Button Version
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg,hBitmap,hButton,hButtonDC As Dword, bm As Bitmap
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,220,250, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 200, "Push", 10,10,100,20
Control Handle hDlg, 200 To hButton
Control Add Graphic, hDlg, 300, "", 10,40,200,200, %WS_Border
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = 200 Then
hButtonDC = GetDC(hButton)
hBitMap = GetCurrentObject(hButtonDC, %OBJ_BITMAP)
If hBitMap Then
GetObject hBitMap, SizeOf(bm), bm
MsgBox Str$(bm.bmWidth) + Str$(bm.bmHeight)
End If
End If
End Function
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,220,250, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 200, "Push", 10,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = 200 Then
Local hBitMap,hDesktopDC As Dword, bm As Bitmap
hDesktopDC = GetDC(%Null)
hBitMap = GetCurrentObject(hDesktopDC, %OBJ_BITMAP)
If hBitMap Then
GetObject hBitMap, SizeOf(bm), bm
MsgBox Str$(bm.bmWidth) + Str$(bm.bmHeight)
End If
End If
End Function
'gbs_00946
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm