M
Michael Meier
Hi
I'm writing a program for PocketPcs.
Since I want a ComboBox to automatically open when the user presses a key
I'm using the attached code.
Unfortunately the CB_GETDROPPEDSTATE message always returns 0, so the
program is unable to check if the
ComboBox is already opened or not. If the ComboBox is already opened, and
another CB_SHOWDROPDOWN
is send, the text in the ComboBox is overwritten by the newly pressed key.
Is there a possibility to get CB_GETDROPPEDSTATE working?
private void testfield__KeyUp(object sender, KeyEventArgs e) {
const int CB_SHOWDROPDOWN = 0x14F;
const int CB_GETDROPPEDSTATE = 0x157;
IntPtr hwnd = GlobalFunctions.getHwnd(this.testfield);
if (GlobalFunctions.SendMessage(hwnd, CB_GETDROPPEDSTATE, 0, 0) ==
IntPtr.Zero) {
GlobalFunctions.SendMessage(hwnd, CB_SHOWDROPDOWN, 1, 0);
}
}
[DllImport("coredll.dll"]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam,
int lParam);
[DllImport("CoreDll.dll")]
extern private static IntPtr GetCapture();
public static IntPtr getHwnd(Control ctrl) {
ctrl.Capture = true;
IntPtr tmp = GetCapture();
ctrl.Capture = false;
return tmp;
}
I'm writing a program for PocketPcs.
Since I want a ComboBox to automatically open when the user presses a key
I'm using the attached code.
Unfortunately the CB_GETDROPPEDSTATE message always returns 0, so the
program is unable to check if the
ComboBox is already opened or not. If the ComboBox is already opened, and
another CB_SHOWDROPDOWN
is send, the text in the ComboBox is overwritten by the newly pressed key.
Is there a possibility to get CB_GETDROPPEDSTATE working?
private void testfield__KeyUp(object sender, KeyEventArgs e) {
const int CB_SHOWDROPDOWN = 0x14F;
const int CB_GETDROPPEDSTATE = 0x157;
IntPtr hwnd = GlobalFunctions.getHwnd(this.testfield);
if (GlobalFunctions.SendMessage(hwnd, CB_GETDROPPEDSTATE, 0, 0) ==
IntPtr.Zero) {
GlobalFunctions.SendMessage(hwnd, CB_SHOWDROPDOWN, 1, 0);
}
}
[DllImport("coredll.dll"]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam,
int lParam);
[DllImport("CoreDll.dll")]
extern private static IntPtr GetCapture();
public static IntPtr getHwnd(Control ctrl) {
ctrl.Capture = true;
IntPtr tmp = GetCapture();
ctrl.Capture = false;
return tmp;
}