window api使用方法~~~为什么我看不明白
各位前辈,请你们明示~~~谢谢
例如:这个函数
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
函数参数应该传什么,里面的是什么意思???
还有像这样的常数:
Public Const ACCESS_SYSTEM_SECURITY = &H1000000
Public Const ACL_REVISION = (2)
这个我知道是用来当参数来传的。。。但是要怎么用啊。。。。我怎么哪个参数用哪个常数啊???
希望各位前辈指点一下,哪怕一句也好,还要这方面应该看什么书啊???
[解决办法]
【VB声明】 Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long【说明】 将一幅位图从一个设备场景复制到另一个。源和目标DC相互间必须兼容 【返回值】 Long,非零表示成功,零表示失败。会设置GetLastError 【备注】 在NT环境下,如在一次世界传输中要求在源设备场景中进行剪切或旋转处理,这个函数的执行会失败 如目标和源DC的映射关系要求矩形中像素的大小必须在传输过程中改变,那么这个函数会根据需要自动伸缩、旋转、折叠、或切断,以便完成最终的传输过程【参数表】 hDestDC -------- Long,目标设备场景 x,y ------------ Long,对目标DC中目标矩形左上角位置进行描述的那个点。用目标DC的逻辑坐标表示 nWidth,nHeight - Long,欲传输图象的宽度和高度 hSrcDC --------- Long,源设备场景。如光栅运算未指定源,则应设为0 xSrc,ySrc ------ Long,对源DC中源矩形左上角位置进行描述的那个点。用源DC的逻辑坐标表示 dwRop ---------- Long,传输过程要执行的光栅运算
[解决办法]
'used with fnWeightConst FW_DONTCARE = 0Const FW_THIN = 100Const FW_EXTRALIGHT = 200Const FW_LIGHT = 300Const FW_NORMAL = 400Const FW_MEDIUM = 500Const FW_SEMIBOLD = 600Const FW_BOLD = 700Const FW_EXTRABOLD = 800Const FW_HEAVY = 900Const FW_BLACK = FW_HEAVYConst FW_DEMIBOLD = FW_SEMIBOLDConst FW_REGULAR = FW_NORMALConst FW_ULTRABOLD = FW_EXTRABOLDConst FW_ULTRALIGHT = FW_EXTRALIGHT'used with fdwCharSetConst ANSI_CHARSET = 0Const DEFAULT_CHARSET = 1Const SYMBOL_CHARSET = 2Const SHIFTJIS_CHARSET = 128Const HANGEUL_CHARSET = 129Const CHINESEBIG5_CHARSET = 136Const OEM_CHARSET = 255'used with fdwOutputPrecisionConst OUT_CHARACTER_PRECIS = 2Const OUT_DEFAULT_PRECIS = 0Const OUT_DEVICE_PRECIS = 5'used with fdwClipPrecisionConst CLIP_DEFAULT_PRECIS = 0Const CLIP_CHARACTER_PRECIS = 1Const CLIP_STROKE_PRECIS = 2'used with fdwQualityConst DEFAULT_QUALITY = 0Const DRAFT_QUALITY = 1Const PROOF_QUALITY = 2'used with fdwPitchAndFamilyConst DEFAULT_PITCH = 0Const FIXED_PITCH = 1Const VARIABLE_PITCH = 2'used with SetBkModeConst OPAQUE = 2Const TRANSPARENT = 1Const LOGPIXELSY = 90Const COLOR_WINDOW = 5Const Message = "Hello !"Private Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As LongPrivate Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As LongPrivate Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As LongPrivate Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As LongPrivate Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As LongPrivate Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As LongPrivate Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As LongPrivate Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As LongPrivate Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal nHeight As Long, ByVal nWidth As Long, ByVal nEscapement As Long, ByVal nOrientation As Long, ByVal fnWeight As Long, ByVal fdwItalic As Boolean, ByVal fdwUnderline As Boolean, ByVal fdwStrikeOut As Boolean, ByVal fdwCharSet As Long, ByVal fdwOutputPrecision As Long, ByVal fdwClipPrecision As Long, ByVal fdwQuality As Long, ByVal fdwPitchAndFamily As Long, ByVal lpszFace As String) As LongPrivate Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As LongPrivate Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As LongPrivate Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As LongPrivate Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As LongPrivate Declare Function GetSysColorBrush Lib "user32" (ByVal nIndex As Long) As LongPrivate Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As LongPrivate 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 LongDim mDC As Long, mBitmap As LongPrivate Sub Form_Click() Unload MeEnd SubPrivate Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net Dim mRGN As Long, Cnt As Long, mBrush As Long, R As RECT 'Create a device context, compatible with the screen mDC = CreateCompatibleDC(GetDC(0)) 'Create a bitmap, compatible with the screen mBitmap = CreateCompatibleBitmap(GetDC(0), Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY) 'Select the bitmap nito the device context SelectObject mDC, mBitmap 'Set the bitmap's backmode to transparent SetBkMode mDC, TRANSPARENT 'Set the rectangles' values SetRect R, 0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY 'Fill the rect with the default window-color FillRect mDC, R, GetSysColorBrush(COLOR_WINDOW) For Cnt = 0 To 350 Step 30 'Select the new font into the form's device context and delete the old font DeleteObject SelectObject(mDC, CreateMyFont(24, Cnt)) 'Print some text TextOut mDC, (Me.Width / Screen.TwipsPerPixelX) / 2, (Me.Height / Screen.TwipsPerPixelY) / 2, Message, Len(Message) Next Cnt 'Create an elliptical region mRGN = CreateEllipticRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY) 'Set the window region SetWindowRgn Me.hWnd, mRGN, True 'delete our elliptical region DeleteObject mRGNEnd SubFunction CreateMyFont(nSize As Integer, nDegrees As Long) As Long 'Create a specified font CreateMyFont = CreateFont(-MulDiv(nSize, GetDeviceCaps(GetDC(0), LOGPIXELSY), 72), 0, nDegrees * 10, 0, FW_NORMAL, False, False, False, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH, "Times New Roman")End FunctionPrivate Sub Form_Paint() 'Copy the picture to the form BitBlt Me.hdc, 0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, mDC, 0, 0, vbSrcCopyEnd SubPrivate Sub Form_Unload(Cancel As Integer) 'clean up DeleteDC mDC DeleteObject mBitmapEnd Sub
[解决办法]
太多的消息反而看的糊里糊涂,这个函数我也是实验了好多次,才会用一点
给你个代码
Call BitBlt(Picture1.Hdc, 0, 0, 70, 22, cHdc, 86, 284, SRCCOPY)
第一个参数是要把图片复制到Picture1的句柄
第二,三个参数是复制到Picture1的位置,一般都是0,0
第四,五个参数是要复制的图片的宽和高
第六个参数是要从哪个地方去复制,我这里是整个屏幕的句柄
cHdc = GetDC(0)这是获取整个屏幕句柄的语句
第七,八个参数是整个屏幕的哪个坐标位开始复制
最后一个Public Const SRCCOPY = &HCC0020
[解决办法]
PS :最后一个参数直接传递vbsrccopy即可,连常数定义都省下了。