Newsgroup: it.comp.lang.visual-basic
Titolo: Di nuovo il BITMAP...URGENTE

L'istruzione Loadpicture funziona se ho un contenitore OLE nella
form....purtroppo nel mio caso non esiste...allora qualcuno mi sa dire il
motivo per cui il seguente non funziona???
Qualcuno puo' darmi anche valide alternative....lo scopo e' quello di dare
in uscita una "semplice" immagine BMP.
Vi metto il codice che ho scritto ma che non funziona:
Const SRCCOPY = &HCC0020 '(DWORD) dest = source
Private Type POINTAPI
    X As Integer
    Y As Integer
End Type
Private Type BITMAP
    bmType As Integer
    bmWidth As Integer
    bmHeight As Integer
    bmWidthBytes As Integer
    bmPlanes As String * 1
    bmBitsPixel As String * 1
    bmBits As Long
End Type
Private Type WNDCLASS
    style As Integer
    lpfnWndProc As Long 'Note: address of function here
    cbClsExtra As Integer
    cbWndExtra As Integer
    hInstance As Integer
    hIcon As Integer
    hCursor As Integer
    hbrBackground As Integer
    lpszMenuName As Long    'Resource ID or far pointer to name
    lpszClassName As Long   'Far pointer to name
End Type
Private Declare Function BitBlt% Lib "GDI32" (ByVal hDestDC%, ByVal X%,
ByVal Y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal
YSrc%, ByVal dwRop&)
Private Declare Function CreateCompatibleDC% Lib "GDI32" (ByVal hdc%)
Private Declare Function GetObjectAPI% Lib "GDI32" Alias "GetObjectA" (ByVal
hObject%, ByVal ncount%, ByVal lpObject&)
Private Declare Function SelectObject% Lib "GDI32" (ByVal hdc%, ByVal
hObject%)
Private Declare Function SetMapMode% Lib "GDI32" (ByVal hdc%, ByVal
nMapMode%)
Private Declare Function DPtoLP% Lib "GDI32" (ByVal hdc%, lpPoints As
POINTAPI, ByVal ncount%)
Private Declare Function DeleteDC% Lib "GDI32" (ByVal hdc%)
Private Declare Function GetMapMode% Lib "GDI32" (ByVal hdc%)
Private Declare Function SizeofResource% Lib "Kernel32" (ByVal hInstance%,
ByVal hResInfo%)
Private Declare Function GetDC% Lib "User32" (ByVal hwnd%)
Private Declare Function LoadBitmap% Lib "User32" Alias "LoadBitmapA" (ByVal
hInstance%, ByVal lpBitmapName As Any)
Private Declare Function LoadBitmapBystring% Lib "User32" Alias
"LoadBitmapA" (ByVal hInstance%, ByVal lpBitmapName$)
Private Sub Command1_Click()
Dim hwnd As Integer
    Dim r As Integer
    Dim hObject As Integer
    Dim hdcMem As Integer
    Dim hdc As Integer
    Dim hInst As Integer
    Dim Poub As Integer
    Dim bm As BITMAP
    Dim ncount As Integer
    Dim ptSize As POINTAPI
    Dim ptOrg As POINTAPI
    hdc = GetDC%(hwnd)
    hdcMem = CreateCompatibleDC%(hdc)
    'r% = hdcMem
    'MsgBox "le hdc est :" & r%, ebOKonly, "titre"
    hInst = 1
    'hObject% = 2
    'hObject% = LoadBitmapBystring%(hInst, "c:\windows\gattino.bmp")
    hObject% = LoadBitmap%(hInst, "c:\windows\gattino.bmp")
    'r% = hInst
    'MsgBox hObject%
    'MsgBox "le hinst est :" & r%, ebOKonly, "titre"
    'r% = hObject%
    'MsgBox "le hobject est :" & r%, ebOKonly, "titre"
    Poub = SelectObject%(hdcMem, hObject%)
    Poub = SetMapMode%(hdcMem, GetMapMode(hdc))
    Poub = GetObjectAPI%(hObject%, 19, hObject%)
    'ptSize.X = bm.bmWidth
    ' ptSize.Y = bm.bmHeight
    ptSize.X = 450
    ptSize.Y = 400
    'r% = ptSize.X
    'MsgBox "le ptSize est :" & r%, ebOKonly, "titre"
    Poub = DPtoLP%(hdc, ptSize, 1)
    ptOrg.X = 150
    ptOrg.Y = 160
    Poub = DPtoLP%(hdcMem, ptOrg, 1)
    Poub = BitBlt%(hdc, 110, 110, ptSize.X, ptSize.Y, hdcMem, ptOrg.X,
ptOrg.Y, SRCCOPY)
    Poub = DeleteDC%(hdcMem)
End Sub
Grazie a tutti.
Max

Forse mi sono perso qualcosa di precedente, ma sto provando a capire quello
che devi fare.
1) le dichiarazioni a 32 bit dovrebbero far riferimento a Long e non ad
Integer,
2) LoadPicture solo con contenitore OLE???
3) hWnd è un form?
4) Che significa deve dare in uscita un bitmap? immagino tu debba
visualizzare un bitmap sul form.
Se il tuo problema è quello di inserire un Bitmap in un form MDI dovrei
avere il codice da qualche parte... Se invece stai programmando in VBA o
Access non saprei che fare.
Fabio Guerrazzi