PDA

Click to See Complete Forum and Search --> : activeform/MDI problem


Dec 10th, 1999, 06:17 PM
richard has a question:
I am using VB 5. I am writing a text editor with an MDI form. On that form is a comdo box with a list of fonts. Child forms are created at runtime, so the only way i have of identifying the current form is the activeform property. I want Activeform.text1.font.name = combo1.text. (text1 is a rich text box). However, as soon as i click on the combo, the focus is lost. I have no way of identifying the current form, i was wondering prehaps a tag - i can't give them an index, and all forms share the same name.
People say use a variable, but what can it store? please give me some code to fix the problem.
Thanx

Gerald
Dec 10th, 1999, 10:26 PM
Richard,

Use a global variable in a module as a reference to the currently active MDI child form...


Public gfrmActiveForm as Form


Then add this code to the Activate event of each MDI child form...


Set gfrmActiveForm = Me


Also add this code to the Unload event of each MDI child form...


Set gfrmActiveForm = Nothing


Then reference the active form using your global variable...


If Not gfrmActiveForm Is Nothing then
gfrmActiveForm.Text1.Font.Name = Combo1.Text
End If


Hope this solves your problem, Gerald M.


[This message has been edited by Gerald (edited 12-11-1999).]

[This message has been edited by Gerald (edited 12-11-1999).]

Dec 11th, 1999, 11:44 AM
thanx alot it really helped