OPENFILENAME

cs_mat74 Messages postés 241 Date d'inscription dimanche 10 août 2003 Statut Membre Dernière intervention 16 juin 2010 - 1 févr. 2006 à 18:40
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019 - 1 févr. 2006 à 19:15
salut à tous,

voila je voudrais ouvrir une boite dialogue pour enregistrer un fichier, récupérer la valeur de type, et rajouter un bouton suivant la valeur de type.
j'utilise OPENFILNAME avec un CALLBACK mais je sais pas trop comment gérer le CALLBACK. Es-ce que quelqu'un connait un exemple ou pourrai m'expliquer ?



,
----

UINT_PTR CALLBACK OFNHookProc(HWND hdlg,UINT uiMsg,WPARAM wParam,LPARAM lParam)
{
LPOFNOTIFY lpOfNotify;
switch (uiMsg)
{
case CDN_TYPECHANGE:
{
lpOfNotify = (LPOFNOTIFY) lParam;
char msg[1024];
sprintf (msg,"%d",lpOfNotify->hdr.idFrom);
SetWindowText (hWnd_global,msg);
return false;
}
default:
return false;
}
}

BOOL Explorer_Fichier (HWND hWnd,char *type,char *nom_fichier,char *nom_fenetre,char *filtre)
{
// on met tte la chaine nom_fichier à 0
memset (nom_fichier,0,sizeof(nom_fichier));
// la classe à passer en param
OPENFILENAME ofn;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = 0;
ofn.lpstrFilter = filtre;
ofn.lpstrFile = nom_fichier;
ofn.lpstrCustomFilter= 0;
ofn.lpstrFileTitle = 0;
ofn.nFileExtension = 0;
ofn.nFileOffset = 0;
ofn.lCustData = 0;
ofn.lpTemplateName = 0;
ofn.lpstrInitialDir = 0;
ofn.lpstrDefExt = 0;
ofn.lpfnHook = 0;
ofn.nFileExtension = 0;
ofn.nFileExtension = 0;
ofn.nMaxCustFilter = 0;
ofn.nMaxFileTitle = 0;
ofn.nFilterIndex = 1;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = nom_fenetre;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;

BOOL ret;
if (!strcmp(type,"charger"))
ret = GetOpenFileName (&ofn);
else if (!strcmp(type,"enregistrer"))
{
ofn.lpfnHook = (LPCCHOOKPROC)OFNHookProc;
// ofn.lpTemplateName = MAKEINTRESOURCE(IDD_CHARGER_RAW);
ofn.Flags |= OFN_ENABLEHOOK|OFN_EXPLORER/*|OFN_ENABLETEMPLATE*/;
ret = GetSaveFileName (&ofn);
}
else
ret = false;
return ret;
}

1 réponse

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
1 févr. 2006 à 19:15
Exemple de OFNHookProc() ici:
SELECTEUR IMAGE + APERCU (WIN32)
http://www.cppfrance.com/code.aspx?id=10644

ciao...
http://dev.winsysdev.com
BruNews, MVP VC++
0
Rejoignez-nous