Eddie Shipman
asked on
Iterating Treeview in SHBrowseForFolder Dialog.
I need to remove non-fixed drives in a SHBrowseForFolder dialog. I am passing the handle
to the treeview from an EnumChildProc that is called in the BrowseDialogCallBack.
type
Params = packed record
LocalDrives: bool;
pidlRoot: PItemIDList;
BffInitialized: bool;
hWndTreeCtrl: hwnd;
hWndEditCtrl: hwnd;
InitialFolder: pchar;
SelectedItem: htreeitem;
SelectedPath: array[0..MAX_PATH] of char;
end;
var
BffParams: Params;
procedure TVLocalDrives (hwnd: hwnd);
var
hti, child: htreeitem;
htiText: array[0..MAX_PATH] of char;
TVI: tagTVItem;
Count, DriveType: uint;
begin
hti := TreeView_GetRoot(BffParams .hWndTreeC trl);
TVI.mask := TVIF_HANDLE or TVIF_TEXT or TVIF_CHILDREN or TVIF_STATE or TVIF_PARAM;
TVI.hItem := hti;
TVI.pszText := htiText;
TVI.cchTextMax := MAX_PATH;
TreeView_GetItem(BffParams .hWndTreeC trl, TVI);
child := TreeView_GetChild(BffParam s.hWndTree Ctrl, hti);
//Build TreeViewItem Structure used to retrieve text of selected item.
TVI.mask := TVIF_HANDLE or TVIF_TEXT or TVIF_CHILDREN or TVIF_STATE or TVIF_PARAM;
TVI.hItem := child;
TVI.pszText := htiText;
TVI.cchTextMax := MAX_PATH;
TreeView_GetItem(BffParams .hWndTreeC trl, TVI);
While hti <> nil do
begin
TVI.hItem := hti;
TreeView_GetItem(BffParams .hWndTreeC trl, TVI);
DriveType := GetDriveType(pchar(leftstr (string(TV I.pszText) ,3)));
if DriveType <> DRIVE_FIXED then
begin
//TreeView_DeleteItem(BffP arams.hWnd TreeCtrl, TVI.hItem);
end;
hti := TreeView_GetNextItem(BffPa rams.hWndT reeCtrl, TVI.hItem, TVGN_NEXT);
end;
end;
This isn't working, the call:
child := TreeView_GetChild(BffParam s.hWndTree Ctrl, hti);
does not return a child.
I have verified that the the Root is 'My Computer'.
Does it look like I'm doing anything else wrong?
to the treeview from an EnumChildProc that is called in the BrowseDialogCallBack.
type
Params = packed record
LocalDrives: bool;
pidlRoot: PItemIDList;
BffInitialized: bool;
hWndTreeCtrl: hwnd;
hWndEditCtrl: hwnd;
InitialFolder: pchar;
SelectedItem: htreeitem;
SelectedPath: array[0..MAX_PATH] of char;
end;
var
BffParams: Params;
procedure TVLocalDrives (hwnd: hwnd);
var
hti, child: htreeitem;
htiText: array[0..MAX_PATH] of char;
TVI: tagTVItem;
Count, DriveType: uint;
begin
hti := TreeView_GetRoot(BffParams
TVI.mask := TVIF_HANDLE or TVIF_TEXT or TVIF_CHILDREN or TVIF_STATE or TVIF_PARAM;
TVI.hItem := hti;
TVI.pszText := htiText;
TVI.cchTextMax := MAX_PATH;
TreeView_GetItem(BffParams
child := TreeView_GetChild(BffParam
//Build TreeViewItem Structure used to retrieve text of selected item.
TVI.mask := TVIF_HANDLE or TVIF_TEXT or TVIF_CHILDREN or TVIF_STATE or TVIF_PARAM;
TVI.hItem := child;
TVI.pszText := htiText;
TVI.cchTextMax := MAX_PATH;
TreeView_GetItem(BffParams
While hti <> nil do
begin
TVI.hItem := hti;
TreeView_GetItem(BffParams
DriveType := GetDriveType(pchar(leftstr
if DriveType <> DRIVE_FIXED then
begin
//TreeView_DeleteItem(BffP
end;
hti := TreeView_GetNextItem(BffPa
end;
end;
This isn't working, the call:
child := TreeView_GetChild(BffParam
does not return a child.
I have verified that the the Root is 'My Computer'.
Does it look like I'm doing anything else wrong?
ASKER
The TreeView_GetItem macro modifies the TVI parameter and returns
a BOOLEAN.
a BOOLEAN.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try to change
TreeView_GetItem(BffParams
to
hti := TreeView_GetItem(BffParams
Regards,
Tomas Helgi