In the VB program, change the COMBO control read-only attribute style value by code.

zhaozj2021-02-17  54

In the VB program, if you use the following statement to dynamically create a COMBO control

DIM WITHEVENTS CMBDROPLIST AS ComboBox ... Set CMBDroplist = controls.add ("vb.comboBox", "cMBDroplist"), the STYLE value of the Combo control is 1 (VBComBodropDown drop-down combo box, including a drop-down list and a text box . You can select it from the list or in the text box), if you want to change the value of Style 2 (VBComBodrop-DownList 2 drop-down list. This style only allows you to select from the drop-down list)

Through statement combo1.style = 2, because Style is read-only attribute. In order to break through this restriction, I use the SPY weapon to reconnaissance for the combo control of two different style values, and found two different places.

1. When the COMBO control style is 1-vbcomBodropDown, the Styles = & H54010242 of the Combo control window, while the STYLE value of the Combo control is 2-vbcomBodrop-Downlist, the Styles = & H54010243

2

I first try to change the Styles value of the Combo control window with the API function.

Call setWindowlong (Combo1.hwnd, GWL_Style, & H54010243)

See if there is any change in the COMBO control, and the result is expected.

I will try to kill the EDIT window in the Combo control with the API function, yeah ~~~, success

Here is my implementation code:

转载请注明原文地址:https://www.9cbs.com/read-29274.html

New Post(0)