Re: Unable to unset WS_VISIBLE flag for some win32lib controls
- Posted by LarryMiller Jun 05, 2009
- 1049 views
I have checked the flags in the win32lib constants file. All flags seem to be bits in a 4 byte field; if I add these up for RichEdit, I get #54A1A044 (as expressed in hexadecimal, same as win32lib constants). The WS_VISIBLE is defined as #10000000. If I subtract that from #54A1A044, I get #44A1A044. Trying to set the flags then without using bit twiddling functions:
mycontrol = create(RichEdit,"",owningwindow,10,10,20,80,#54A1A044)
works as expected, but changing that to #44A1A044 does not. Is there something so obvious that I am not seeing it..? Possibly I am completely off course?
Regards Alan
In Win32Lib the style flags used by a control are the defaults or'd with those you specify. This is very convenient because you need only specify those you wish to add. Unsetting a default flag isn't so commonly used and not as convenient to do. One way is to specify the flags as a one element sequence - {flags}. This will completely override the defaults and you must specify all necessary flags. For many controls this is not very convenient. If this needs to be done often you could define a variable or preferably constant with these flags. The usual method is simply to define the control as usual and then setVisible(control, 0). This makes it clear that the control will be initially hidden.