API(Win32)入門/フォルダ指定ダイアグラム
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
''[[FrontPage]]''
* フォルダ指定ダイアグラムの使用 [#ke409d04]
ファイルでなく、フォルダを選択するダイアグラムを使用する。~
** 制約 [#m00946ea]
.NET関数・MFCを使用しないこと。~
~
&color(#FF0000,){以下のソースファイルは、ファイルハンドル...
プリプロセッサ部は参考までに
#include <shlobj.h> ...
#include <stdio.h> ...
...
#define RET_OK 0 ...
#define RET_NG -1 ...
...
char FolderDlg( HWND hWnd, TCHAR* de_folderName ) ...
{ ...
LPMALLOC lpMalloc = NULL; ...
if( !SUCCEEDED(SHGetMalloc( &lpMalloc ) ) ) ...
{ ...
return ( RET_NG ); ...
} ...
...
char di_folderName[_MAX_PATH]; ...
BROWSEINFO info = { 0 }; ...
info.hwndOwner = hWnd; ...
info.pidlRoot = CSIDL_DESKTOP; ...
info.pszDisplayName = di_folderName; ...
info.lpszTitle = "StyleMod"; ...
info.ulFlags = BIF_EDITBOX | BIF_STATUSTEXT |...
BIF_RETURNONLYFSDIRS | BIF_R...
info.lpfn = FDlgProc; ...
...
LPITEMIDLIST itemList = SHBrowseForFolder( &info )...
if( NULL == itemList ) ...
{ ...
lpMalloc->Release(); ...
return(RET_NG); ...
} ...
...
char lName[_MAX_PATH]; ...
if( SHGetPathFromIDList( itemList, lName ) ) ...
{ ...
snprintf( de_folderName, strlen(lName), lName );...
} ...
else ...
{ ...
return ( RET_NG ); ...
// snprintf(de_folderName, strlen(di_folderName), d...
} ...
...
lpMalloc->Free( itemList ); ...
lpMalloc->Release(); ...
...
return ( RET_OK ); ...
}
int CALLBACK FDlgProc(HWND hwnd, UINT msg, LPARAM lP...
{ ...
switch(msg){ ...
case BFFM_INITIALIZED: ...
break; ...
...
case BFFM_SELCHANGED: ...
{ ...
char selected[MAX_PATH]; ...
...
if( SHGetPathFromIDList( ( LPITEMIDLIST ) lP...
{ ...
SendMessage( hwnd, BFFM_SETSTATUSTEXT, 0...
} ...
else ...
{ ...
EnableWindow( GetDlgItem( hwnd, IDOK ), ...
break; ...
} ...
} ...
} ...
...
return ( RET_OK ); ...
}
*** 参考ページ [#qe4eb22a]
http://kwi.cocolog-nifty.com/blog/2006/03/bcb_case_83d1.h...
終了行:
''[[FrontPage]]''
* フォルダ指定ダイアグラムの使用 [#ke409d04]
ファイルでなく、フォルダを選択するダイアグラムを使用する。~
** 制約 [#m00946ea]
.NET関数・MFCを使用しないこと。~
~
&color(#FF0000,){以下のソースファイルは、ファイルハンドル...
プリプロセッサ部は参考までに
#include <shlobj.h> ...
#include <stdio.h> ...
...
#define RET_OK 0 ...
#define RET_NG -1 ...
...
char FolderDlg( HWND hWnd, TCHAR* de_folderName ) ...
{ ...
LPMALLOC lpMalloc = NULL; ...
if( !SUCCEEDED(SHGetMalloc( &lpMalloc ) ) ) ...
{ ...
return ( RET_NG ); ...
} ...
...
char di_folderName[_MAX_PATH]; ...
BROWSEINFO info = { 0 }; ...
info.hwndOwner = hWnd; ...
info.pidlRoot = CSIDL_DESKTOP; ...
info.pszDisplayName = di_folderName; ...
info.lpszTitle = "StyleMod"; ...
info.ulFlags = BIF_EDITBOX | BIF_STATUSTEXT |...
BIF_RETURNONLYFSDIRS | BIF_R...
info.lpfn = FDlgProc; ...
...
LPITEMIDLIST itemList = SHBrowseForFolder( &info )...
if( NULL == itemList ) ...
{ ...
lpMalloc->Release(); ...
return(RET_NG); ...
} ...
...
char lName[_MAX_PATH]; ...
if( SHGetPathFromIDList( itemList, lName ) ) ...
{ ...
snprintf( de_folderName, strlen(lName), lName );...
} ...
else ...
{ ...
return ( RET_NG ); ...
// snprintf(de_folderName, strlen(di_folderName), d...
} ...
...
lpMalloc->Free( itemList ); ...
lpMalloc->Release(); ...
...
return ( RET_OK ); ...
}
int CALLBACK FDlgProc(HWND hwnd, UINT msg, LPARAM lP...
{ ...
switch(msg){ ...
case BFFM_INITIALIZED: ...
break; ...
...
case BFFM_SELCHANGED: ...
{ ...
char selected[MAX_PATH]; ...
...
if( SHGetPathFromIDList( ( LPITEMIDLIST ) lP...
{ ...
SendMessage( hwnd, BFFM_SETSTATUSTEXT, 0...
} ...
else ...
{ ...
EnableWindow( GetDlgItem( hwnd, IDOK ), ...
break; ...
} ...
} ...
} ...
...
return ( RET_OK ); ...
}
*** 参考ページ [#qe4eb22a]
http://kwi.cocolog-nifty.com/blog/2006/03/bcb_case_83d1.h...
ページ名: