Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Dim bBytes(1 To 8) As Byte
Private Sub Command1_Click()
Dim R As RECT, mBrush As Long, hBitmap As Long
hBitmap = CreateCompatibleBitmap(Picture1.hdc, 200, 100)
mBrush = CreatePatternBrush(hBitmap)
SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight
FillRect Me.hdc, R, mBrush
DeleteObject mBrush
DeleteObject hBitmap
End Sub
上面的代码是我从网络搜来修改的,但怎么改都不对,我在picture1中加载了一 幅小图,我想用这幅小图填充窗体,可一点运行,窗体就变成黑色的了,没有看见图,有高手能告诉我为什么吗?
还有,能不能帮我修改下,怎么才能不用PictureBox控件,就得到app.path & "BS1.dim"的图并填充到窗体去啊?
还有,我怎么才能得到一幅图象的局部区域,比如我想得到图象中间一个方框内的图象,该怎么做到啊?
强烈感谢进来帮助的人,我正在API学习,请多指教,谢谢了
|