Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Each Child Window, update a control property

Status
Not open for further replies.

scarfhead

Programmer
Joined
Sep 12, 2001
Messages
60
Location
US
I've got an MDI application that uses MapObjects maps in each child form. I want to take the Extent of the Map on the Active Child and apply it to the maps on all child forms. This amounts to setting a property on a control on every MDI child.

I'm at a loss as to how to approach this, though. I've got my Dan Appleman's VB Programmer's Guide to the Win32 API by my side and still I'm mistified.

Can anybody get me started?

Thanks,

scarfhead
 
I'm getting the handles for each child window, but I can't seem to get a window to be Active to where the MDI form recognizes it as the ActiveForm. I guess I am setting the Active Window, but not the Active Form. Shouldn't there be a Children collection under the MDI or something?

The code is on the MDI form. Here's what I've got so far:

Private Sub SynchPlans()
Dim rect As MapObjects2.Rectangle
Dim CurrhWnd As Long
Dim i As Long

'Get the extent of the map in the active window
Set rect = ActiveForm.MapPlanDisplay.Extent

'Apply that extent to the maps in all other child windows
CurrhWnd = GetWindow(Me.ActiveForm.hWnd, GW_HWNDFIRST)
While CurrhWnd <> 0
CurrhWnd = GetWindow(CurrhWnd, GW_HWNDNEXT)
SetActiveWindow CurrhWnd
SetFocusAPI CurrhWnd
Me.ActiveForm.SetFocus
Set ActiveForm.MapPlanDisplay.Extent = rect
Wend
End Sub

still working on it...
 
New approach.
I have a collection on the MDI Parent form.
Each time I add a new child, I add (a reference to) it to the collection. Then I can use this code to set all the maps to the same extent. No API calls necessary.

Private Sub SynchPlans()
Dim rect As MapObjects2.Rectangle
Dim frm As frmViewerChild
Dim i As Long

Set rect = ActiveForm.MapPlanDisplay.Extent
For i = 1 To m_Col.Count
Set frm = m_Col(i)
frm.SetFocus
Set ActiveForm.MapPlanDisplay.Extent = rect
Next i
End Sub

so nevermind
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top