News: Check out our online Video Tutorials ! http://www.youtube.com/user/ComputerWorkshopSoft
TO REGISTER on Forum, contact tech support: http://cwsof.com/support.html
 
Pages: [1]   Go Down
  Print  
Author Topic: Toggle EDIT property on Textbox  (Read 410 times)
Chris Burgess
EZGUI SLL Beta
Full Member
*
Posts: 157


View Profile
« on: May 23, 2012, 01:03:55 AM »

How can I (or is it even possible to) toggle the E (edit) property of a textbox created with EZ_Text?

We have a series of them on a form, and only want to enable them for editing in response to user input.

For example, if a user is in years 8 or 9, the line:

EZ_Text %MAIN_TEXTTN, 2, 7, 30, 2, "Mr Montgomery", "CEF"

is read only, but editable if they are in years 10, 12, or 12.

Disabling the control does not achieve what we need to, as the years 8/9 users still need to copy (Ctrl-C or right mouse button) the contents of the control.

It's going to be way too messy having a slightly different version of the app for each class (would need about 25 or 30 sub-versions).

We also can't enable / disable edit when the form is created, as users are not permitted to exit the app.
The next user supplies their name in a textbox after the previous user has saved their own data with a "save it now" button.

Depending on the user name supplied (the app looks up their year level from a CSV data file) the textbox may need to either editable or read-only.

Possible?

Chris




Logged
Chris Boss
Administrator
Hero Member
*****
Posts: 1800


View Profile
« Reply #1 on: May 23, 2012, 06:54:06 AM »

Code:
SUB EZ_SetReadOnly(BYVAL FormName$, BYVAL ControlID&, BYVAL TFlag&)
     IF TFlag&<>0 THEN
          EZ_SendMessage FormName$, ControlID&,&HCF, 1,0    ' %EM_SETREADONLY message
     ELSE
          EZ_SendMessage FormName$, ControlID&,&HCF, 0,0    ' %EM_SETREADONLY message
     END IF
END SUB


Logged
Chris Burgess
EZGUI SLL Beta
Full Member
*
Posts: 157


View Profile
« Reply #2 on: May 23, 2012, 11:09:57 PM »

Thanks for that, all working now.

Logged
Dan Gin zel
EZGUI SLL Beta
Sr. Member
*
Posts: 265


View Profile WWW
« Reply #3 on: May 24, 2012, 08:56:01 PM »

That's a nice one that should go in the code clips...
Logged

http://www.thecomputerarchive.com Preserving the history of companies that advanced the computer revolution
Chris Boss
Administrator
Hero Member
*****
Posts: 1800


View Profile
« Reply #4 on: May 24, 2012, 10:30:21 PM »

It is good to note that when a control (window class) is created (CreateWindowEx) is has certain window styles used (EZGUI converts its control properties to the appropriate window style).

The API provides the SetWindowLong function which can be used to modify certain attributes of a window class, including the original window styles. The problem with changing window styles after a control is created is that some window style changes my not be tolerated.

This is why one must check the API docs to see which window styles (aka. EZGUI properties) can be changed after a control si created. Some styles can not be changes, which is why EZGUI does not have a set of commands for changing most of the control proeprties. It just isn't done that way.

Fortunately some controls have messages instead for handling such window style changes. In this case the message I used on the code above is the proper way to change the window style after the contorl is created.

The point of this is that, EZGUI does not provide commands to change the majority of the window styles, since many are not supposed to be changed afterwards.

Fortunately in this case, there is a message provided designed to handle this one specific change.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: