Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
ReadOnly
I am tring to call Form_Services.SetWindowReadOnly.
The problem I am having is with EditLines that have been subclassed.
The section in question is
Options are still able to be selected and the user can then save the record when prompted at exit so not exactly a Read Only.
Turning off the Subclassing altogether in the form's Create to test and then just do a straight Set_Property(Control, "ENABLED", Yes$) in SetWindowReadOnly is more the behavior I was after.
So I thought I would be smart and unsubclass it programatically and then try the straight disable but with no luck (it didnt seem to unsubclass)
What am I doing wrong?
The problem I am having is with EditLines that have been subclassed.
The section in question is
Equate WM_SETREADONLY$ to 207
Case Type EQ "EDITBOX" OR Type EQ "EDITFIELD"
hwndEdit = Get_Property(Control, "HANDLE")
Send_Message(hwndEdit, WM_SETREADONLY$, Yes$, 0)
Options are still able to be selected and the user can then save the record when prompted at exit so not exactly a Read Only.
Turning off the Subclassing altogether in the form's Create to test and then just do a straight Set_Property(Control, "ENABLED", Yes$) in SetWindowReadOnly is more the behavior I was after.
So I thought I would be smart and unsubclass it programatically and then try the straight disable but with no luck (it didnt seem to unsubclass)
Equate SubClass$ to @Window:".OLE_SUBCLASS"
Send_Message(SubClass$, "OLE.Unsubclass", Control)
Set_Property(Control, "ENABLED", No$)
What am I doing wrong?
Comments
Maybe the Universe was just waiting to nudge me ;-)
I must be doing something wrong. I have tried to both disable the option as you noted, as well as removing the button alogether.
Equate SubClass$ to @Window:".OLE_SUBCLASS" Convert "." to ";" in Control Set_Property(SubClass$, "OLE.OptionButton[":Control:"]", No$) Set_Property(SubClass$, "OLE.OptionEnabled[":Control:"]", No$)
So I tested with disabling the field alogether
Set_Property(Control, "ENABLED", No$)
However, this works (just not wanted)
Set_Property(Control, "VISIBLE", No$)
Not sure if it matters but I am using the latest Controls but a super old FrameWork.
Subclass = Form_Services("FindSubclassControl", @Window) Convert "." to ";" in Control Set_Property(Subclass<1>, "OLE.OptionEnabled[":Control:"]", No$)
After I started to respond with negative results and scrrenshotsI actually took a second and re-read your post and actually consider what it meant. I am glad I did because you were spot on!
The SubClass control at this point thanks to the Equate is "FW_MAIN.OLE_SUBCLASS".
Setting a variable to WINDOW:".OLE_SUBCLASS" for my call made all the difference. I started to see some expected results.
I will note, however, that the OptionEnabled documentation notes "Normally, option buttons take on the enabled state of the EDITLINE control.". I took this to mean if the Control was disabled then the Option was disabled by default. I have not found that to be the case but then again, maybe that is why @DonBakke pointed me to OptionEnabled. Even when I disabled the Control the Option Buttons were still active so doing both gets the result I was after.
Now all I have to do is work out how I can get this to work for multi-instance forms since the WINDOW variable does not have the Instance ID and, as noted, @WINDOW is FW_MAIN at this point.
That does seem ambiguous, but I took it to mean that this is the normal desired behavior but sometimes a developer might want the edit line to be set differently than the option button. Hence, the need for this property. Perhaps Kevin (the engineer for this feature) meant it differently and we have a feature that doesn't work fully as expected.
This has me confused. Do you not put subclass controls on the individual forms?
I absolultey have the Subclass on the individual Form.
I debugged at the same point in Form_Services as Frank and at that stage my @Window is FW_MAIN and the Window variable is the Form Name (excluding the InstanceID). I was hoping for something like DBW_FORMNAME*2
I havent yet had a chance to look upstream from that to see how it is getting to that point.
Form_Services("SetWindowReadOnly", @Window)
If I launch multiple instances of the window, it works out fine, as @Window being passed in has the instance id. Form Services will also try to figure out the window if the passed in window parameter is blank. So, somewhere is either passing in a non-instanced window variable, or a null is being passed in and Form Services is taking its best guess.Thanks for that feedback. It gave me a thought...
We are also launching from the Ribbon so I did a bit of a trace.
It appears we are using Command_Services.Execute as a core of our security integration.
After launching the MDIChild the service does this check:
// [SRPFW-211] Read Only If ExecuteProcedure _eqc "Child Window" or ExecuteProcedure _eqc "Window" then If CommandAccess _eqc "Read Only" then Form_Services("SetWindowReadOnly", ExecuteParam) end end
Unfortunately ExecuteParam was taken from this so has no instance ID:
CommandRec = SRP_HashTable("Get", CommandsHandle@, Command)
However, if I take the response from the Start_MDIChild, which contains the instanceID, to use as the ExcuteParam instead for a Child Window, it now behaves as expected!