Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[WD17] Charger une image BITMAP (présent dans un fichier ressource DLL) dans un champ image

1 réponse
Avatar
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

Merci pour vos r=E9ponses

1 réponse

Avatar
JY B
Le mardi 9 avril 2013 10:39:46 UTC+2, JY B a écrit :
Je n'arrive pas à récupérer dans un champ image un fichier BITMAP s tocké dans une DLL. Voici le code :



PROCEDURE ChargeLogo(sFenetre est une chaine)



RECT est une structure

cg est un entier système

ch est un entier système

cd est un entier système

cb est un entier système

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

hImageLogo est un entier sans signe

hImageLogo1 est un entier sans signe

sLogo est une chaîne

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



SI ChampExiste(sFenetre+".Img_Logo") ALORS

iInstanceDLL=ChargeDLL(fRepExe+"MaDll.dll")

sLogo = "IMGLOGO02"

iPtr = &slogo

LoadBitmapA est une Description d'API

LoadBitmapA.NomDLL = "user32.dll"

LoadBitmapA.NomFonction = "LoadBitmapA"

LoadBitmapA.Paramètre[1].Type = apiEntierSystème // hInstance

LoadBitmapA.Paramètre[2].Type = apiEntierSystème // lpBitmapName

LoadBitmapA.TypeRetour = apiEntierSystème

hImageLogo = API(LoadBitmapA,iInstanceDLL ,iPtr)



{sFenetre+".Img_Logo",indChamp}..AffichageActif = Faux

lImg est un entier = {sFenetre+".Img_Logo",indChamp}..Largeur

hImg est une entier = {sFenetre+".Img_Logo",indChamp}..Hauteur

Hdc = dDébutDessin({sFenetre+".Img_Logo",indChamp})



// Prototype de la fonction : CreateCompatibleDC(HDC)

CreateCompatibleDC est une Description d'API

CreateCompatibleDC.NomDLL = "gdi32.dll"

CreateCompatibleDC.NomFonction = "CreateCompatibleDC"

CreateCompatibleDC.Paramètre[1].Type = apiEntierSystème // HDC

hdcMem est un Entier sans signe = api(createcompatibledc,hdc)



// Prototype de la fonction : SelectObject(HDC, HGDIOBJ);

SelectObject est une Description d'API

SelectObject.NomDLL = "gdi32.dll"

SelectObject.NomFonction = "SelectObject"

SelectObject.Paramètre[1].Type = apiEntierSystème // HDC

SelectObject.Paramètre[2].Type = apiEntierSystème // HGDIOBJ

hdOld est un Entier sans signe = API(SelectObject,hdcScreen,hImageLog o)



// Prototype de la fonction : GetObjectA(HGDIOBJ, int, LPVOID);

bm est un BITMAP

GetObjectA est une Description d'API// la fonction:HANDLE WINAPI

GetObjectA.NomDLL = "gdi32.dll"

GetObjectA.NomFonction = "GetObjectA"

GetObjectA.Paramètre[1].Type = apiEntierSystème // HGDIOBJ

GetObjectA.Paramètre[2].Type = apiEntier_4 // int

GetObjectA.Paramètre[3].Type = apiEntierSystème // LPVOID

iError = API(GetObjectA,hImageLogo,Dimension(bm),&bm)

{sFenetre+".Img_Logo",indChamp}..Largeur = bm.bmWidth

{sFenetre+".Img_Logo",indChamp}..Hauteur = bm.bmHeight



// fonction : BitBlt(HDC, int, int, int, int, HDC, int, int, DWORD);

BitBlt est une Description d'API

BitBlt.NomDLL = "gdi32.dll"

BitBlt.NomFonction = "BitBlt"

BitBlt.Paramètre[1].Type = apiEntierSystème // HDC

BitBlt.Paramètre[2].Type = apiEntier_4 // int

BitBlt.Paramètre[3].Type = apiEntier_4 // int

BitBlt.Paramètre[4].Type = apiEntier_4 // int

BitBlt.Paramètre[5].Type = apiEntier_4 // int

BitBlt.Paramètre[6].Type = apiEntierSystème // HDC

BitBlt.Paramètre[7].Type = apiEntier_4 // int

BitBlt.Paramètre[8].Type = apiEntier_4 // int

BitBlt.Paramètre[9].Type = apiEntier_4 // DWORD

iError = API(BitBlt,hBitmap, 0, 0, bm.bmWidth, bm.bmHeight, hImageLo go, 0, 0, 0xCC0020)



ierror = API(SelectObject,hdcScreen,hdOld)



// Prototype de la fonction : DeleteDC(HDC)

DeleteDC est une Description d'API

DeleteDC.NomDLL = "gdi32.dll"

DeleteDC.NomFonction = "DeleteDC"

DeleteDC.Paramètre[1].Type = apiEntierSystème // HDC

DeleteDC(hdcMem)

iError = API(DeleteDC,hdcScreen)



{sFenetre+".Img_Logo",indChamp}..AffichageActif = Vrai

MultitâcheRepeint()

FIN



==> Aucune erreur mais mon image ne s'affiche pas

Problème le device context image windev est-il le même que le DC WIN 32



Merci pour vos réponses



Je précise que j'arrive à lire le fichier ressource (.dll) en win 32 c+ +