Bonjour,
Comment initialiser "m_ofn.lpstrInitialDir" afin que la fenetre CFileDialog s'ouvre sur le poste de travail??
Thieum
Bonjour,
Comment initialiser "m_ofn.lpstrInitialDir" afin que la fenetre CFileDialog s'ouvre sur le poste de travail??
Thieum
Dans ton cas, ce n'est pas le répertoire de l'utilisateur courant que tu veux, mais le bureau. donc au lieu de CSIDL_PERSONAL, tu utiliseras CSIDL_COMMON_DESKTOPDIRECTORYlpstrInitialDir
Pointer to a string that specifies the initial file directory.
Windows NT 5.0 and later; Windows 98 and later:
If lpstrInitalDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
If lpstrInitalDir is NULL and the current directory does not contain any files of the specified filter types, the initial directory is the personal files directory of the current user. To specify the current user's personal files directory as the initial directory, set lpstrInitialDir to the path returned by calling theSHGetSpecialFolderLocation function with the CSIDL_PERSONAL flag.
Earlier versions of Windows and Windows NT:
If lpstrInitalDir is NULL, the initial directory is the current directory.
nFolder
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 WINSHELLAPI HRESULT WINAPI SHGetSpecialFolderLocation( HWND hwndOwner, int nFolder, LPITEMIDLIST *ppidl );
Value specifying the folder for which to retrieve the location. This parameter can be one of the following values:
CSIDL_COMMON_DESKTOPDIRECTORY File system directory that contains files and folders that appear on the desktop for all users
Ok,
avec le code suivant ca marche:
sauf que là, la fenetre s'ouvre sur le bureau hors je souhaite qu'elle s'ouvre sur le poste de travail. j'ai essayer avec CSIDL_DRIVES mais le chemin retrouner est null.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 LPTSTR szPath = ""; SHGetSpecialFolderPath(hWndMain, szPath, CSIDL_DESKTOPDIRECTORY , true); AfxMessageBox(szPath); Dialog.m_ofn.lpstrInitialDir = szPath;
donc comment faire pour avoir le chemin du poste de travail??
C'est un répertoire virtuel, il existe nul part sur le disque. C'est pour ça que SHGetSpecialFolderPath échoue. Je ne pense pas que ce que tu souhaites soit possible, avec CFileDialog.
C'est faisable avec SHBrowseForFolder, mais c'est une dialogue moins sympa...
Ok, bon ben tant pis, neanmoins merci de vos reponses...
Que la force soit avec vous...
Thieum
Partager