Author |
Topic: Changing the style of a dialog control (Read 3222 times) |
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Changing the style of a dialog control
« Reply #5 on: Jun 15th, 2013, 4:53pm » |
|
on Jun 15th, 2013, 2:47pm, Matt wrote:| I'm sorry, but where does it state that? |
|
Compare, for example, the description of the ES_LOWERCASE and ES_READONLY styles. Under ES_LOWERCASE it says this: "To change this style after the control has been created, use SetWindowLong" and under ES_READONLY it says this: "To change this style after the control has been created, use the EM_SETREADONLY message".
Now whilst I willingly concede that the ES_READONLY text doesn't actually say not to use SetWindowLong, the fact that it tells you to use EM_SETREADONLY (and doesn't mention SetWindowLong at all) is a pretty clear indication that it should be done in a specific way.
Quote:| There's no memory leakage, so I can't see how this might be a problem. |
|
Windows is a very complex Operating System, with subtle and frequently non-obvious interactions between its components. It's impossible to deduce, from the limited information available from MSDN, whether doing something contrary to the recommendations will be acceptable or not. It's best to assume it isn't.
To me it's a 'no brainer'; MSDN tells you that to change the Read Only status of an edit control (after it is created) you should send it an EM_SETREADONLY message. On the page to which I linked, the EM_SETREADONLY text is a hyperlink to this page:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb761655.aspx
There the messages you need to send are described in great detail, corresponding to these BBC BASIC statements:
Code:SYS "SendMessage", hEditControl%, EM_SETREADONLY, 1, 0 : REM Set Read Only state
SYS "SendMessage", hEditControl%, EM_SETREADONLY, 0, 0 : REM Clear Read Only state Richard.
|
| « Last Edit: Jun 15th, 2013, 7:38pm by admin » |
Logged
|
|
|
|
Matt
Developer
member is offline


Gender: 
Posts: 210
|
 |
Re: Changing the style of a dialog control
« Reply #6 on: Jun 15th, 2013, 7:41pm » |
|
on Jun 15th, 2013, 4:53pm, Richard Russell wrote:| To me it's a 'no brainer' |
|
I wish it was that easy for me.
Quote:There the details of the messages you need to send are listed in great detail, corresponding to these BBC BASIC statements:
Code:SYS "SendMessage", hEditControl%, EM_SETREADONLY, 1, 0 : REM Set Read Only state
SYS "SendMessage", hEditControl%, EM_SETREADONLY, 0, 0 : REM Clear Read Only state Richard. |
|
Thanks. Now all I have to do is find a way of making comboboxes and buttons(incl. radio buttons and checkboxes) RO as well.
Matt
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Changing the style of a dialog control
« Reply #7 on: Jun 15th, 2013, 10:12pm » |
|
on Jun 15th, 2013, 7:41pm, Matt wrote:| I wish it was that easy for me. |
|
If you are not familiar with the SendMessage function then you really shouldn't be attempting to program the Windows API. Spend some time learning the basics, then come back to the task.
Quote:| Now all I have to do is find a way of making comboboxes and buttons(incl. radio buttons and checkboxes) RO as well. |
|
Since you can't ever 'write' to buttons, there's no concept of them being 'read only'! As far as comboboxes are concerned, a 'read only' combobox would simply be a List Box (remember that a combobox is a combination of a text box - which you can write to - and a list box - which you can't)!
Richard.
|
| « Last Edit: Jun 15th, 2013, 10:33pm by admin » |
Logged
|
|
|
|
|