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

Je n'arrive pas à récupérer dans un champ image un fichier BITMAP sto=
cké 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,hImageLogo)
// 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, hImageLogo=
, 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
cké 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,hImageLogo)
// 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, hImageLogo=
, 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+ +