Probléme de compilation

makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006 - 24 mai 2006 à 13:02
 yoyo269 - 25 mai 2006 à 11:10
Bonjour a tous

j'ai cette source pour ouvrire mon bmp mais a cette ligne il y a une ereure:

DrawState(hdc,NULL,NULL,(long)hBmp,NULL,10,10,0,0,DST_BITMAP);

[Warning] passing arg 5 of `DrawStateA' makes integer from pointer without a cast

je ne comprend pas ,merci de votre aide
voila la source entiere:

LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{


switch (uMsg)
{

case WM_PAINT :
{
HBITMAP hBmp;
HDC hdc;
PAINTSTRUCT ps;

hBmp=LoadImage(NULL,"image.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);

hdc = BeginPaint(hwnd, &ps);

DrawState(hdc,NULL,NULL,(long)hBmp,NULL,10,10,0,0,DST_BITMAP);

EndPaint(hwnd, &ps);

DeleteObject(hBmp);

return 0;
}

case WM_DESTROY:
PostQuitMessage(0);
return 0;

default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}

23 réponses

vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
24 mai 2006 à 13:11
Déja c'est un warning, donc pas une erreur, ca n'empêche pas que la compilation se termine.
Je pense que si tu remplaces NULL par 0, tu n'aura plus ce warning
(si NULL est défini pas (void*)0, il essaie de recaster ça en int, donc il me un warning car c'est un pointeur)
0
cs_magma Messages postés 198 Date d'inscription vendredi 4 avril 2003 Statut Membre Dernière intervention 18 mars 2011
24 mai 2006 à 13:18
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 13:19
non j'ais plus le warning mais a la place ca fait ceci:

[Linker error] undefined reference to `DeleteObject@4'
0
cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 2
24 mai 2006 à 13:22
linker avec gdi32
if(!Meilleur("Joky")) return ERREUR;<
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 13:29
toujour le warning avec ceci

DrawState(hdc,0,0,(long)hBmp,NULL,10,10,0,0,DST_BITMAP);
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
24 mai 2006 à 13:39
DrawState(hdc,0,0,(long)hBmp,0,10,10,0,0,DST_BITMAP);

et pour le DeleteObject:
ajouter -lgdi32 au options du linker
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 13:45
ca ma fait ca

`lgdi32' undeclared (first use in this function)
0
cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 2
24 mai 2006 à 13:47
Allez moi je quitte ce post lol
if(!Meilleur("Joky")) return ERREUR;<
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
24 mai 2006 à 13:49
euh... oui, faut pas mettre ca dans ton code, mais dans les options de ton editeur de liens
Sous Dev-C++: Projet>Options du projet>Paramètres, et la tu tapes -lgdi32 dans la case Editeur de liens
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 13:52
ok merci

j'ai du mal c'est mon premier programe
0
cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 2
24 mai 2006 à 13:58
Ben pour un premier programme tu penches pas vers le plus facile aussi...

if(!Meilleur("Joky")) return ERREUR;<
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 13:59
ca me fait ceci maintenan

invalid conversion from `void*' to `HBITMAP__*'
0
cs_magma Messages postés 198 Date d'inscription vendredi 4 avril 2003 Statut Membre Dernière intervention 18 mars 2011
24 mai 2006 à 14:00
Sous DevCpp, inutile de linker gdi32
mais il faut sélectionner le type d'application: Win32 GUI
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 14:06
le type d'application est bon pourtant
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 14:40
persone ne c'est comment faire


invalid conversion from `void*' to `HBITMAP__*'
0
cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 2
24 mai 2006 à 14:48
hBmp = (HBITMAP)LoadImage(...)

if(!Meilleur("Joky")) return ERREUR;<
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 14:53
ca marche nikel en C mais pas en C++
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 14:56
ca marche merci beaucoup
0
makina0711 Messages postés 41 Date d'inscription dimanche 30 avril 2006 Statut Membre Dernière intervention 24 mai 2006
24 mai 2006 à 17:08
#include <windows.h>

HINSTANCE hinst;

LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);



int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wc;

hinst = hinstance;

wc.style = 0;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = NULL;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MaWinClass";

if(!RegisterClass(&wc)) return FALSE;

hwnd = CreateWindow("MaWinClass", "Dessiner", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 280, 240,
NULL, NULL, hinstance, NULL);
if (!hwnd) return FALSE;

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);


while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{


switch (uMsg)
{

case WM_PAINT :
{
HBITMAP hBmp;
HDC hdc;
PAINTSTRUCT ps;

hBmp = (HBITMAP)LoadImage(NULL,"image.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);

hdc = BeginPaint(hwnd, &ps);

DrawState(hdc,0,0,(long)hBmp,0,0,0,0,0,DST_BITMAP);

EndPaint(hwnd, &ps);

DeleteObject(hBmp);

return 0;
}

case WM_DESTROY:
PostQuitMessage(0);
return 0;

default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
24 mai 2006 à 17:12
C'est dommage de faire ton LoadImage à chaque fois que tu dessine ta fenêtre (WM_PAINT est un message qui est recu très souvent).
Le mieux est d'avoir une variable global contenant la bitmap. Tu l'ouvre à la création de la fenêtre (LoadImage) et tu la libère à la destruction (DeleteObject)
0
Rejoignez-nous