Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg, hBMP, hDC, hDCB, hMemDC As Dword
Global B() As Long
%IDC_Button = 500
%IDC_Graphic = 600
%IDC_GraphicB = 700
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,120,160, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button,"Push", 10,10,100,20
Control Add Graphic, hDlg, %IDC_Graphic,"Push", 10,40,100,100, %WS_Border
Graphic Attach hDlg, %IDC_Graphic, Redraw
Graphic Render "cowgirl.bmp", (0,0)-(99,99)
Graphic Get DC To hDC
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local x,y As Long, bm As Bitmap
If Cb.Msg = %WM_Command And Cb.Ctl = %IDC_Button And Cb.CtlMsg = %BN_Clicked Then
hBMP = GetCurrentObject(hDC,%OBJ_Bitmap)
GetObject(hBMP,SizeOf(bm),bm)
ReDim B(1 To bm.bmwidth,1 To bm.bmheight)
GetBitmapBits (hBMP, bm.bmwidthbytes*bm.bmheight, B(1,1))
For y = 1 To bm.bmheight
For x = 1 To bm.bmwidth
B(x,y) = 64
Next x
Next y
SetBitmapBits hBMP, bm.bmwidthbytes*bm.bmheight, B(1,1)
Graphic ReDraw
End If
End Function
'gbs_00953
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm