Sending CB_GETDROPPEDSTATE to a Combobox always returns zero

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;
}
 
A

Alex Yakhnin

Take a look at this old thread:

http://groups.google.com/group/micr...box+compact+framework&rnum=7#12a6a4d762842887

--
Alex Yakhnin, Device Application Developer MVP
http://blog.opennetcf.org/ayakhnin

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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top