Reputation: 4849
I have a project where I want to display a combo to show dropdown list of directory listing like dialog boxes does.
there is a Win32 API
int DlgDirListComboBox(
LPTSTR lpPathSpec,
int nIDComboBox,
int nIDStaticPath,
UINT nFileType
);
and its c# version (thanks to pInvoke.net)
[DllImport("user32.dll")]
static extern int DlgDirListComboBox(IntPtr hDlg, StringBuilder lpPathSpec,
int nIDComboBox, int nIDStaticPath, uint uFiletype);
but I can't figure out what value should I pass in for nIDComboBox
parameter (I tried and handle
do not work here!)
Upvotes: 0
Views: 180
Reputation: 10619
nIDComboBox
should be the Win32 Control ID of the combobox. You can get it with another P/Invoke call by passing the control's Handle
:
[DllImport("user32.dll")]
static extern int GetDlgCtrlID(IntPtr hWnd);
But you can also list the directories without resorting to P/Invoke by using Directory.GetDirectories
Upvotes: 1