Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting read only properties of controls added at runtime 1

Status
Not open for further replies.

ianbm

Programmer
Jan 3, 2002
3
0
0
GB
I'm creating forms at runtime by added controls to the controls collection, I need a multiline text box but cannot set this property once the control is created, as it is read only, the same applies to many other properties of other controls.
I could create a user control with this already set and add an instance of that, but that has annoying overheads of wrapping all the methods and events, and to create user controls with all the permuatations of read only properties for all the instrinsic controls would be unrealistic.
 
The reason that some attributes of controls are read only at run time is a consequence of the underlying way that they are created (a call to CreateWindow, or possibly CreateWindowEx). Certain parameters provided to these calls, namely various styles (the WS_ constants) define the way that window (or, in VB parlance, control) appears and behaves.

Once the window/control is created, then, as far as VB is concerned those styles are fixed in stone, i.e a readonly property.

Fortunately, there is a way around this. Try investigating the SetWindowLog API call, which allows you to modify an already existing window's style settings.
 
Thanks, I'll look into that, I had a feeling API calls would come in to somewhere, in the short term I've found that the MS Forms 2.0 controls collection has a textbox with a writable multiline property, and a listbox that's a little more flexible at runtime.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top