为了账号安全,请及时绑定邮箱和手机立即绑定

直接用LoadBitmaps函数显示is not a member of 'CButton'?

直接用LoadBitmaps函数显示is not a member of 'CButton'?

C
慕桂英3389331 2022-10-20 15:11:40
这是怎么回事?还有SizeToContent函数;确实函数库里没有,所以想问问怎么调用,万分感谢!!!
查看完整描述

2 回答

?
一只甜甜圈

TA贡献1836条经验 获得超5个赞

如果是API函数的话,调用时要先封装,例如:
Const LR_LOADFROMFILE = &H10
Const IMAGE_BITMAP = 0
Const IMAGE_ICON = 1
Const IMAGE_CURSOR = 2
Const IMAGE_ENHMETAFILE = 3
Const CF_BITMAP = 2
Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal dwImageType As Long, ByVal dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As Long
Private Sub Form_Load()
Dim hDC As Long, hBitmap As Long
'Load the bitmap into the memory
hBitmap = LoadImage(App.hInstance, "d:\pintu\p1.bmp", IMAGE_BITMAP, 400, 290, LR_LOADFROMFILE)
If hBitmap = 0 Then
MsgBox "There was an error while loading the bitmap"
Exit Sub
End If
'open the clipboard
OpenClipboard Me.hwnd
'Clear the clipboard
EmptyClipboard
'Put our bitmap onto the clipboard
SetClipboardData CF_BITMAP, hBitmap
'Check if there's a bitmap on the clipboard
If IsClipboardFormatAvailable(CF_BITMAP) = 0 Then
MsgBox "There was an error while pasting the bitmap to the clipboard!"
End If
'Close the clipboard
CloseClipboard
'Get the picture from the clipboard
Me.Picture = Clipboard.GetData(vbCFBitmap)
End Sub
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
SizeToContent是不是自定义函数就不清楚了,如果是,可以直接Call SizeToContent(参数)就好了。


查看完整回答
反对 回复 2022-10-24
?
一只名叫tom的猫

TA贡献1906条经验 获得超2个赞

要新建一个CBitmapButton 的类对象就可以了

查看完整回答
反对 回复 2022-10-24
  • 2 回答
  • 0 关注
  • 126 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信