1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
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;
} |
Partager