Moving a run-time generated ComboBox on a form
-
I'm trying to move a run-time generated ComboBox on a form, so I want to give the user the possibility to change the position of the ComboBox. For a TextBox control, I've solved the problem getting the control in drag state on MouseDown event.(Q103062 in MSDN). The code looks like this: MyTextBox.Drag 1 The problem is the a TextBox has the events MouseDown and MouseUp, while the ComboBox hasn't. Please someone help me with an idea?
-
I'm trying to move a run-time generated ComboBox on a form, so I want to give the user the possibility to change the position of the ComboBox. For a TextBox control, I've solved the problem getting the control in drag state on MouseDown event.(Q103062 in MSDN). The code looks like this: MyTextBox.Drag 1 The problem is the a TextBox has the events MouseDown and MouseUp, while the ComboBox hasn't. Please someone help me with an idea?
I think you are going to have to build your own message handler for WM_LMOUSEDOWN and WM_LMOUSEUP on your ComboBox. You can refer to MSDN article Q170570 on how to do it. I was able move ComboBox on the form, but it is going to behave different depending on the Style property of your ComboBox. If your combo is a "Dropdown List" it will work just fine. If your combo is a "Dropdown Combo" you will be able to drag it only by the border or dropdown arrow. If you set your style to be a "Simple Combo" you will only be able to drag it by the border. In the case of "Simple Combo" and "DropDown Combo" when user clicks in the area of the combo box where he/she can type you do not recieve WM_LBUTTONDOWN message. That is probably why they did not expose MouseDown and MouseUp events in the first place. Well, this is all I can come up with right now. I hope this info will help you.