Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Active control
Message
From
28/10/1998 19:38:45
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00151923
Message ID:
00152047
Views:
26
>>>>>>>>>Is there a way to click on a toolbar and have it know and be able to access the last active control? And a way to enable or disable a toolbar depending on what control is active?
>>>>>>>>>
>>>>>>>>>Basically, I want to put in the gotfocus something to turn the toolbar on, then while you're in that control, the toolbar can control its properties, and then in the lostfocus the toolbar gets disabled.
>>>>>>>>>
>>>>>>>>>How do I do this?
>>>>>>>>>
>>>>>>>>>Thanks,
>>>>>>>>>
>>>>>>>>>-Michelle
>>>>>>>>
>>>>>>>>Basically, you do exactly what you said:
>>>>>>>>***Control.GotFocus event
>>>>>>>>oApp.tbMain.SetAll("Enabled",.F.,"CommandButton")
>>>>>>>>***Control.LostFocus event
>>>>>>>>oApp.tbMain.SetAll("Enabled",.T.,"CommandButton")
>>>>>>>>You may also diversify this code, if, for example, some buttons were already disabled before control got focus.
>>>>>>>
>>>>>>>
>>>>>>>Hmmm... Back to needing an application object again... Any other way to talk to the toolbar? And what about the toolbar talking to the control?
>>>>>>>
>>>>>>>Thanks,
>>>>>>>
>>>>>>>-Michelle
>>>>>>
>>>>>>If you want to disable buttons when some control gets focus, then logically this control should talk to toolbar and not otherwise. Opposite way of commincation will still involve tracing application hierarchy, but if you particularly don't like it, there is another way. You can always loop through _SCREEN.Forms collection, find the necessary form there and call it using the same collection.
>>>>>
>>>>>
>>>>>Yes, for disabling the toolbar when the control loses focus, it makes sense that the control talk to the toolbar. But there were two parts to my question. I also want to know how the toolbar can manipulate the properties of the control.
>>>>>
>>>>>It's not that I don't like the idea of an application object, I just don't like the idea of having to make an application all the time. I just run the forms straight from VFP, so there's no application to have an object.
>>>>>
>>>>>Thanks,
>>>>>
>>>>>-Michelle
>>>>
>>>>You don't need in 'application'. I meant custom object which is usually called oApp (or goApp in some versions:). As I said, it's not a requirement to have it in your design, because you may use _SCREEN.Forms collection. For example, you want to call FrmEdit.txtName control outside 'frmEdit' form. Then you can do following:
>>>>
>>>>For Each oForm In _SCREEN.Forms
>>>> IF UPPER(oForm.Name)=="FRMEDIT"
>>>>  oForm.txtName.Backcolor=12345
>>>> ENDIF
>>>>Endfor
>>>>
>>>
>>>Ok, I got one-way communication going. :)
>>>
>>>Now how do I click on a button on a toolbar and have it do something to the active control? Or maybe "last active" would be more accurate, since the toolbar button would now be the active one.
>>>
>>>Thanks,
>>>
>>>-Michelle
>>
>>You can add
>>Thisform.LastActiveControl=This
>>to each control GotFocus event, or use subclassing here.
>>Don't forget to set This.LastActiveControl=.NULL. in Form.Destroy event
>
>
>So from the toolbar I do _SCREEN.ActiveForm.LastActiveControl.FontBold = .T.?
>
>Or does the toolbar become the active form? I'm sorry if I'm being dense here, but what I really need is the object hierarchy path to the property of the control to put in the CLICK() of the toolbar button.
>
>Thanks,
>
>-Michelle

You can call ActiveForm, because toolbar doesn't take focus. But for OO sake, try to do it in generic way, i.e. find form you really want to find and provide communication to this form.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform