[WD17] Charger une image BITMAP (présent dans un fichier ressource DLL) dans un champ image
1 réponse
burlot.jeanyves
Je n'arrive pas =E0 r=E9cup=E9rer dans un champ image un fichier BITMAP sto=
ck=E9 dans une DLL. Voici le code :
PROCEDURE ChargeLogo(sFenetre est une chaine)
RECT est une structure
cg est un entier syst=E8me
ch est un entier syst=E8me
cd est un entier syst=E8me
cb est un entier syst=E8me
FIN
BITMAP est une structure
bmType est un entier
bmWidth est un entier
bmHeight est un entier
bmWidthBytes est un entier
bmPlanes est une entier sur 2 octet
bmBitsPixel est une entier sur 2 octet
LPVOID est un entier sans signe
FIN
PAINTSTRUCT est une structure
hdc est un entier sans signe
fErase est un entier
rcPaint est un RECT
fRestore est un entier
fIncUpdate est un entier
rgbReserved est un tableau fixe de 32 entiers sans signe
FIN
iError est un entier=20
hImageLogo est un entier sans signe
hImageLogo1 est un entier sans signe
sLogo est une cha=EEne
iPtr est un entier sans signe
iError est un entier sans signe
hwnd est un entier sans signe
hdc est un entier sans signe
iInstanceDLL est un entier sans signe=20
SI ChampExiste(sFenetre+".Img_Logo") ALORS
iInstanceDLL=3DChargeDLL(fRepExe+"\MaDll.dll")
sLogo =3D "IMGLOGO02"
iPtr =3D &slogo
LoadBitmapA est une Description d'API
LoadBitmapA.NomDLL =3D "user32.dll"
LoadBitmapA.NomFonction =3D "LoadBitmapA"
LoadBitmapA.Param=E8tre[1].Type =3D apiEntierSyst=E8me // hInstance
LoadBitmapA.Param=E8tre[2].Type =3D apiEntierSyst=E8me // lpBitmapName
LoadBitmapA.TypeRetour =3D apiEntierSyst=E8me
hImageLogo =3D API(LoadBitmapA,iInstanceDLL ,iPtr)
{sFenetre+".Img_Logo",indChamp}..AffichageActif =3D Faux
lImg est un entier =3D {sFenetre+".Img_Logo",indChamp}..Largeur
hImg est une entier =3D {sFenetre+".Img_Logo",indChamp}..Hauteur
Hdc =3D dD=E9butDessin({sFenetre+".Img_Logo",indChamp})
// Prototype de la fonction : CreateCompatibleDC(HDC)
CreateCompatibleDC est une Description d'API
CreateCompatibleDC.NomDLL =3D "gdi32.dll"
CreateCompatibleDC.NomFonction =3D "CreateCompatibleDC"
CreateCompatibleDC.Param=E8tre[1].Type =3D apiEntierSyst=E8me // HDC
hdcMem est un Entier sans signe =3D api(createcompatibledc,hdc)
// Prototype de la fonction : SelectObject(HDC, HGDIOBJ);
SelectObject est une Description d'API
SelectObject.NomDLL =3D "gdi32.dll"
SelectObject.NomFonction =3D "SelectObject"
SelectObject.Param=E8tre[1].Type =3D apiEntierSyst=E8me // HDC
SelectObject.Param=E8tre[2].Type =3D apiEntierSyst=E8me // HGDIOBJ
hdOld est un Entier sans signe =3D API(SelectObject,hdcScreen,hImageLogo)
// Prototype de la fonction : GetObjectA(HGDIOBJ, int, LPVOID);
bm est un BITMAP
GetObjectA est une Description d'API// la fonction:HANDLE WINAPI =20
GetObjectA.NomDLL =3D "gdi32.dll"
GetObjectA.NomFonction =3D "GetObjectA"
GetObjectA.Param=E8tre[1].Type =3D apiEntierSyst=E8me // HGDIOBJ
GetObjectA.Param=E8tre[2].Type =3D apiEntier_4 // int
GetObjectA.Param=E8tre[3].Type =3D apiEntierSyst=E8me // LPVOID=09
iError =3D API(GetObjectA,hImageLogo,Dimension(bm),&bm)
{sFenetre+".Img_Logo",indChamp}..Largeur =3D bm.bmWidth
{sFenetre+".Img_Logo",indChamp}..Hauteur =3D bm.bmHeight
=09
// fonction : BitBlt(HDC, int, int, int, int, HDC, int, int, DWORD);
BitBlt est une Description d'API
BitBlt.NomDLL =3D "gdi32.dll"
BitBlt.NomFonction =3D "BitBlt"
BitBlt.Param=E8tre[1].Type =3D apiEntierSyst=E8me // HDC
BitBlt.Param=E8tre[2].Type =3D apiEntier_4 // int
BitBlt.Param=E8tre[3].Type =3D apiEntier_4 // int
BitBlt.Param=E8tre[4].Type =3D apiEntier_4 // int
BitBlt.Param=E8tre[5].Type =3D apiEntier_4 // int
BitBlt.Param=E8tre[6].Type =3D apiEntierSyst=E8me // HDC
BitBlt.Param=E8tre[7].Type =3D apiEntier_4 // int
BitBlt.Param=E8tre[8].Type =3D apiEntier_4 // int
BitBlt.Param=E8tre[9].Type =3D apiEntier_4 // DWORD=09
iError =3D API(BitBlt,hBitmap, 0, 0, bm.bmWidth, bm.bmHeight, hImageLogo=
, 0, 0, 0xCC0020)
ierror =3D API(SelectObject,hdcScreen,hdOld)
// Prototype de la fonction : DeleteDC(HDC)
DeleteDC est une Description d'API
DeleteDC.NomDLL =3D "gdi32.dll"
DeleteDC.NomFonction =3D "DeleteDC"
DeleteDC.Param=E8tre[1].Type =3D apiEntierSyst=E8me // HDC =20
DeleteDC(hdcMem)
iError =3D API(DeleteDC,hdcScreen)
{sFenetre+".Img_Logo",indChamp}..AffichageActif =3D Vrai
Multit=E2cheRepeint() =09
FIN
=3D=3D> Aucune erreur mais mon image ne s'affiche pas
Probl=E8me le device context image windev est-il le m=EAme que le DC WIN 32