.NET CF sets "DroppedDown" for combobox

I want to open combobox from my program in a mobile program (.net cf 3.5).

but there is no such property as cmbBox.DroppedDown in a compact structure Using the WinCE ComboBox DroppedDown property (.NET CF 2.0) But I do not want to get the current state, but set it.

How to do it?

+4
source share
3 answers

You can use the same approach as in the specified article and send a message to it.

Instead, use const int CB_SHOWDROPDOWN = 0x14F for your message.

From this reference sample, the bit was changed:

 Message.Create(comboBox.Handle, CB_SHOWDROPDOWN , (IntPtr)1, IntPtr.Zero); // to open Message.Create(comboBox.Handle, CB_SHOWDROPDOWN , (IntPtr)0, IntPtr.Zero); // to close 
+4
source

Use the message CB_SHOWDROPDOWN = 0x014F :

  public const int CB_GETDROPPEDSTATE = 0x0157; public static bool GetDroppedDown(ComboBox comboBox) { Message comboBoxDroppedMsg = Message.Create(comboBox.Handle, CB_GETDROPPEDSTATE, IntPtr.Zero, IntPtr.Zero); MessageWindow.SendMessage(ref comboBoxDroppedMsg); return comboBoxDroppedMsg.Result != IntPtr.Zero; } public const int CB_SHOWDROPDOWN = 0x014F; public static bool ToogleDropDown(ComboBox comboBox) { int expand = GetDroppedDown(comboBox) ? 0 : 1; int size = Marshal.SizeOf(new Int32()); IntPtr pBool = Marshal.AllocHGlobal(size); Marshal.WriteInt32(pBool, 0, expand); // last parameter 0 (FALSE), 1 (TRUE) Message comboBoxDroppedMsg = Message.Create(comboBox.Handle, CB_SHOWDROPDOWN, pBool, IntPtr.Zero); MessageWindow.SendMessage(ref comboBoxDroppedMsg); Marshal.FreeHGlobal(pBool); return comboBoxDroppedMsg.Result != IntPtr.Zero; } 
+7
source

slightly improved:

 public bool ToogleDropDown() { int expand = GetDroppedDown() ? 0 : 1; //int size = Marshal.SizeOf(new Int32()); //IntPtr pBool = Marshal.AllocHGlobal(size); //Marshal.WriteInt32(pBool, 0, expand); // last parameter 0 (FALSE), 1 (TRUE) Message comboBoxDroppedMsg = Message.Create(this.Handle, CB_SHOWDROPDOWN, (IntPtr)expand, IntPtr.Zero); MessageWindow.SendMessage(ref comboBoxDroppedMsg); //Marshal.FreeHGlobal(pBool); return comboBoxDroppedMsg.Result != IntPtr.Zero; } 
0
source

Source: https://habr.com/ru/post/1469480/


All Articles