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 RGBQuad
%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,iResult 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)
iResult = GetBitmapBits (hBMP, bm.bmwidthbytes*bm.bmheight, B(1,1))
For y = 1 To bm.bmheight
For x = 1 To bm.bmwidth
B(x,y).rgbBlue = 64
B(x,y).rgbGreen = 64
B(x,y).rgbRed = 64
Next x
Next y
SetBitmapBits hBMP, bm.bmwidthbytes*bm.bmheight, B(1,1)
Graphic ReDraw
End If
End Function
'gbs_00954
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm