首页
社区
课程
招聘
[求助]请问:什么叫做图位画刷,它和平常的画刷有写什么不一样呢?下面这段代码中,代码好像有点问题,就是想实现创建图位画刷?
发表于: 2011-1-3 16:53 4696

[求助]请问:什么叫做图位画刷,它和平常的画刷有写什么不一样呢?下面这段代码中,代码好像有点问题,就是想实现创建图位画刷?

2011-1-3 16:53
4696
请问:什么叫做图位画刷,它和平常的画刷有写什么不一样呢?下面这段代码中,代码好像有点问题,就是想实现创建图位画刷?

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" _
  (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, _
  ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long

Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long

Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long

Private Declare Function PatBlt Lib "gdi32" _
  (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
  ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long

Private Const PATCOPY = &HF00021 ' (DWORD) dest = pattern

Private Const LR_LOADFROMFILE = &H10
Private Const IMAGE_BITMAP = 0
Private Const IMAGE_ICON = 1
Private Const IMAGE_CURSOR = 2
'Private Const IMAGE_ENHMETAFILE = 3
'Private Const CF_BITMAP = 2

Private Sub Form_Load()
  Dim RECT As RECT
  Dim Image As Long
  
  hwd = GetDC(Me.hwnd)
  GetClientRect Me.hwnd, RECT
  'IMAGE_BITMAP:装载位图;IMAGE_CURSOR:装载光标;IMAGE_ICON:装载图标
  Image = LoadImage(0, App.Path & "\1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
  NewImage = CreatePatternBrush(Image)
  SelectObject hwd, NewImage
  
  PatBlt hwd, 5, 5, RECT.Right, RECT.Bottom, PATCOPY
End Sub

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (9)
雪    币: 120
活跃值: (55)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
2
位图画刷吧,汗
所到之处尽是色彩,周围全是花啊,白的黄的都有,你普通刷子刷一下墙上能出个人脸吗
2011-1-3 20:17
0
雪    币: 120
活跃值: (55)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
3
悄悄话是个奢侈品啊,看雪挂不了kx了

VB代码不太懂,你去CSDN吧,都是研究应用程序和界面的
2011-1-3 20:53
0
雪    币: 26
活跃值: (25)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
4
坚持顶,我顶
2011-1-3 21:43
0
雪    币: 1157
活跃值: (847)
能力值: ( LV8,RANK:150 )
在线值:
发帖
回帖
粉丝
5
位图 平铺 在窗口的Rect区域之内
2011-1-4 08:57
0
雪    币: 26
活跃值: (25)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
6
??????
2011-1-4 09:04
0
雪    币: 1157
活跃值: (847)
能力值: ( LV8,RANK:150 )
在线值:
发帖
回帖
粉丝
7
PatBlt
The PatBlt function paints the specified rectangle using the brush that is currently selected into the specified device context. The brush color and the surface color or colors are combined by using the specified raster operation.

BOOL PatBlt(
  HDC hdc,      // handle to DC
  int nXLeft,   // x-coord of upper-left rectangle corner
  int nYLeft,   // y-coord of upper-left rectangle corner
  int nWidth,   // width of rectangle
  int nHeight,  // height of rectangle
  DWORD dwRop   // raster operation code
);
Parameters
hdc
[in] Handle to the device context.
nXLeft
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.
nYLeft
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.
nWidth
[in] Specifies the width, in logical units, of the rectangle.
nHeight
[in] Specifies the height, in logical units, of the rectangle.
dwRop
[in] Specifies the raster operation code. This code can be one of the following values. Value Meaning
PATCOPY Copies the specified pattern into the destination bitmap.
PATINVERT Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator.
DSTINVERT Inverts the destination rectangle.
BLACKNESS Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.)
WHITENESS Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT/2000/XP: To get extended error information, call GetLastError.

Remarks
The values of the dwRop parameter for this function are a limited subset of the full 256 ternary raster-operation codes; in particular, an operation code that refers to a source rectangle cannot be used.

Not all devices support the PatBlt function. For more information, see the description of the RC_BITBLT capability in the GetDeviceCaps function.

Example Code
For an example, see "Example of Menu-Item Bitmaps" in Using Menus.

Requirements
  Windows NT/2000/XP: Included in Windows NT 3.1 and later.
  Windows 95/98/Me: Included in Windows 95 and later.
  Header: Declared in Wingdi.h; include Windows.h.
  Library: Use Gdi32.lib.

看下这个就知道,用位图画刷填充这个窗口客户区,如果位图的大小比这个区域小,那么区域内会出现位图的不断重复,在说了,你运行一下看看就知道了
2011-1-4 09:18
0
雪    币: 233
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
如果位图的大小比这个区域小,那么区域内会出现位图的不断重复
2011-1-4 09:54
0
雪    币: 26
活跃值: (25)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
9
代码谁能来改改?
2011-1-5 08:50
0
雪    币: 1157
活跃值: (847)
能力值: ( LV8,RANK:150 )
在线值:
发帖
回帖
粉丝
10
你知道 DC 这东西吗??不知道的话看看吧,知道的话GDI还有什么呢??

   要改成什么样的功能呢???说说看
2011-1-5 11:47
0
游客
登录 | 注册 方可回帖
返回
//