Boite de dialog d'impression qui ne veut pas s'afficher

hrp Messages postés 24 Date d'inscription mardi 18 janvier 2005 Statut Membre Dernière intervention 17 juin 2006 - 26 janv. 2005 à 14:39
racpp Messages postés 1909 Date d'inscription vendredi 18 juin 2004 Statut Modérateur Dernière intervention 14 novembre 2014 - 27 janv. 2005 à 05:03
pourquoi ce code n'affiche-t-il pas la boite de dialog d'impression?

//---------------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
PRINTDLG pd;
HWND hwnd;


// Initialize PRINTDLG
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.hwndOwner = hwnd;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_RETURNIC;
pd.nCopies = 1;
pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;


PrintDlg(&pd);
DWORD dw = CommDlgExtendedError();



return 0;
}
//---------------------------------------------------------------------------

huw

7 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
26 janv. 2005 à 14:58
init ton: HWND hwnd = 0;
verif que le compilo a bien insere le code, voyant que ça ne fait rien, il peut tres bien l'avoir zappé.

ciao...
BruNews, MVP VC++
0
hrp Messages postés 24 Date d'inscription mardi 18 janvier 2005 Statut Membre Dernière intervention 17 juin 2006
26 janv. 2005 à 15:06
j'ai initialiser mon hwnd à 0. j'ai lancer mon prog pas à pas et après l'execution de la ligne "HWND hwnd = 0;
", la variable hwnd = NULL. bref la boite de dialog ne s'affiche toujours pas

huw
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
26 janv. 2005 à 15:13
et PrintDlg(&pd); est bien appelé ?

ciao...
BruNews, MVP VC++
0
hrp Messages postés 24 Date d'inscription mardi 18 janvier 2005 Statut Membre Dernière intervention 17 juin 2006
26 janv. 2005 à 15:25
je pense oui, je ne comprend pas pourquoi elle la fonction PrintDlg() ne serait pas bien appelée.

j'ai tenté de récupérer l'erreur retournée, voilà le code (me revoie toujour "CDERR_STRUCTSIZE" or pd.lStructSize=68):

//---------------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{


PRINTDLG pd;
HWND hwnd;
hwnd = 0;


// Initialize PRINTDLG
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.hwndOwner = hwnd;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_RETURNIC;
pd.nCopies = 1;
pd.nFromPage = 1;
pd.nToPage = 1;
pd.nMinPage = 1;
pd.nMaxPage = 1;


PrintDlg(&pd);
DWORD dw = CommDlgExtendedError();


char* temp;


switch(dw)
{
case CDERR_DIALOGFAILURE : temp = "CDERR_DIALOGFAILURE";
case CDERR_FINDRESFAILURE : temp = "CDERR_FINDRESFAILURE";
case CDERR_INITIALIZATION : temp = "CDERR_INITIALIZATION";
case CDERR_LOADRESFAILURE : temp = "CDERR_LOADRESFAILURE";
case CDERR_LOADSTRFAILURE : temp = "CDERR_LOADSTRFAILURE";
case CDERR_LOCKRESFAILURE : temp = "CDERR_LOCKRESFAILURE";
case CDERR_MEMALLOCFAILURE : temp = "CDERR_MEMALLOCFAILURE";
case CDERR_MEMLOCKFAILURE : temp = "CDERR_MEMLOCKFAILURE";
case CDERR_NOHINSTANCE : temp = "CDERR_NOHINSTANCE";
case CDERR_NOHOOK : temp = "CDERR_NOHOOK";
case CDERR_NOTEMPLATE : temp = "CDERR_NOTEMPLATE";
case CDERR_REGISTERMSGFAIL : temp = "CDERR_REGISTERMSGFAIL";
case CDERR_STRUCTSIZE : temp = "CDERR_STRUCTSIZE";
}


MessageBox(NULL, temp, "error", MB_OK);


return 0;
}
//---------------------------------------------------------------------------

huw
0

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

Posez votre question
ymca2003 Messages postés 2070 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 3 juillet 2006 7
26 janv. 2005 à 16:07
faudrai aussi mettre un break à la fin des case sinon tu aura toujours le même message (le dernier de la liste).
0
hrp Messages postés 24 Date d'inscription mardi 18 janvier 2005 Statut Membre Dernière intervention 17 juin 2006
26 janv. 2005 à 16:14
ok c'est fait (merci)


malheureusement mon problème n'est toujours pas résolu :( -> message afficher "CDERR_STRUCTSIZE"


voilà mon code (en entier):


//---------------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
PRINTDLG pd;
HWND hwnd;
hwnd = 0;


// Initialize PRINTDLG
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.hwndOwner = hwnd;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_RETURNIC;
pd.nCopies = 1;
pd.nFromPage = 1;
pd.nToPage = 1;
pd.nMinPage = 1;
pd.nMaxPage = 1;


PrintDlg(&pd);
DWORD dw = CommDlgExtendedError();


switch(dw)
{
case CDERR_DIALOGFAILURE : MessageBox(NULL, "CDERR_DIALOGFAILURE", "error", MB_OK); break;
case CDERR_FINDRESFAILURE : MessageBox(NULL, "CDERR_FINDRESFAILURE", "error", MB_OK); break;
case CDERR_INITIALIZATION : MessageBox(NULL, "CDERR_INITIALIZATION", "error", MB_OK); break;
case CDERR_LOADRESFAILURE : MessageBox(NULL, "CDERR_LOADRESFAILURE", "error", MB_OK); break;
case CDERR_LOADSTRFAILURE : MessageBox(NULL, "CDERR_LOADSTRFAILURE", "error", MB_OK); break;
case CDERR_LOCKRESFAILURE : MessageBox(NULL, "CDERR_LOCKRESFAILURE", "error", MB_OK); break;
case CDERR_MEMALLOCFAILURE : MessageBox(NULL, "CDERR_MEMALLOCFAILURE", "error", MB_OK); break;
case CDERR_MEMLOCKFAILURE : MessageBox(NULL, "CDERR_MEMLOCKFAILURE", "error", MB_OK); break;
case CDERR_NOHINSTANCE : MessageBox(NULL, "CDERR_NOHINSTANCE", "error", MB_OK); break;
case CDERR_NOHOOK : MessageBox(NULL, "CDERR_NOHOOK", "error", MB_OK); break;
case CDERR_NOTEMPLATE : MessageBox(NULL, "CDERR_NOTEMPLATE", "error", MB_OK); break;
case CDERR_REGISTERMSGFAIL : MessageBox(NULL, "CDERR_REGISTERMSGFAIL", "error", MB_OK); break;
case CDERR_STRUCTSIZE : MessageBox(NULL, "CDERR_STRUCTSIZE", "error", MB_OK); break;
}
return 0;
}
//---------------------------------------------------------------------------



huw
0
racpp Messages postés 1909 Date d'inscription vendredi 18 juin 2004 Statut Modérateur Dernière intervention 14 novembre 2014 17
27 janv. 2005 à 05:03
Salut,

Je viens de tester ton code et ça affiche bien la boite de dialogue
d'impression. Le problème est surement ailleurs. Vérifie ton système et
assure-toi que le pilote de l'imprimante est bien installé.
0
Rejoignez-nous