
help me to begin in API Windows programming
Take a look at this code:
'Declare this in the general section of your form
Const IMAGE_BITMAP = &O0
Const LR_LOADFROMFILE = 16
Const LR_CREATEDIBSECTION = 8192
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
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 CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long)
As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal
hObject As Long) As Long
Private 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 Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal
hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As
Long
'And use this code to load a bitmap and copy it to the form
Dim hBitmap As Long, lBMDC As Long, sBitmapInfo As BITMAP
'Load the bitmap
hBitmap = LoadImage(0, "C:\MyFile.bmp", IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE Or LR_CREATEDIBSECTION)
'make sure the call succeeded
If (hBitmap = 0) Then
MsgBox "Error, Unable To Load Bitmap", vbOKOnly, "Bitmap Load Error"
Exit Sub
End If
'Create new Device Context
lBMDC = CreateCompatibleDC(0)
'make sure the call succeeded
If (lBMDC = 0) Then
MsgBox "Error, Unable To Create Device Context", vbOKOnly, "Device
Context Error"
Exit Sub
End If
'attach the bitmap to the device context just created
SelectObject lBMDC, hBitmap
'get the information about this image
GetObject hBitmap, Len(sBitmapInfo), sBitmapInfo
'Copy the bitmap to the form
BitBlt Me.hdc, 0, 0, sBitmapInfo.bmWidth, sBitmapInfo.bmHeight, lBMDC,
0, 0, vbSrcCopy
Just change the "C:\MyFile.bmp" to the file you want.
If you want to know more about API, just visit the API-section on our
homepage.
HTH,
Pieter Philippaerts,
http://www.*-*-*.com/
Quote:
>I'm a beginner in programme API window with
Visual Basic, I want for
beginning
>read a bitmap and displace in on the screen. It s very simple. If anyone
can
>help me !
>And where I can to find the list and explanation of graphics API windows ?
>Thanks.