Print Page | Close Window

How can I detect, if the Form is changed?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=19535
Printed Date: 07 July 2024 at 8:09pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How can I detect, if the Form is changed?
Posted By: Jebo
Subject: How can I detect, if the Form is changed?
Date Posted: 29 February 2012 at 5:59am
Hello,

for TabWorkspace in CommandBars the SelectedChanged-Events fires too early (it fires before the ActiveForm of MDI-Application was changed!) and the "Form_Activate" Event from VB fires too late (the Form is already visible Confused).

So HOW PLEASE can I detect, what Form will open, if the user clicks on a Tab? Ouch



-------------
[Sig removed by Admin: Signature can't exceed 40GB]



Replies:
Posted By: Jebo
Date Posted: 03 March 2012 at 4:57am
Any help please?

-------------
[Sig removed by Admin: Signature can't exceed 40GB]


Posted By: Jebo
Date Posted: 08 March 2012 at 7:36am
HELLOOOOOO? CJ-Team!?


-------------
[Sig removed by Admin: Signature can't exceed 40GB]


Posted By: SuperMario
Date Posted: 09 March 2012 at 9:48am
I don't understand the problem, SelectedChanged is exactly what you want.  You can grab Item.Handle in this event to get object displayed in the tab.  I modified the Commandbars MDI Sample:

Private Sub Workspace_SelectedChanged(ByVal Item As XtremeCommandBars.ITabControlItem)

On Error Resume Next
    
    Dim x As frmDocument
    Dim i As Long

    For i = Forms.Count - 1 To 0 Step -1
        If Forms(i).hwnd = Item.Handle Then
            Set x = Forms(i)
            
            If Item.Index Mod 2 Then
                x.rtfText.BackColor = vbRed
                x.rtfText.Text = "hello"
            Else
                x.rtfText.BackColor = vbBlue
                x.rtfText.Text = "good bye"
            End If
        End If
    Next

    Debug.Print "Workspace_SelectedChanged. Item.Caption = " & Item.Caption
    
End Sub


Posted By: Jebo
Date Posted: 09 March 2012 at 10:09am
But this is exactly the problem. Why do you call this event "SelectedChanged" and not "SelectChange"?

And WHY I must do a slow "For...Each" Loop to find the "SELECTED" form?

Your "way" I already use (but I was shure, there is a better way instead for this "workaround"). Geek


-------------
[Sig removed by Admin: Signature can't exceed 40GB]


Posted By: SuperMario
Date Posted: 09 March 2012 at 10:42am
I'm sorry, I don't know what else to tell you.  First this is a tab workspace event, so it fires when the tab is selected has changed (it provides reference to the newly selected tab).

How is this slow?  You would run out of memory before you could have enough forms open to effect performance.  This is a simple comparison.

Since you can attach many different things to the tab, how can we know what it will be?  Providing the handle is the only thing we can do.

Aside from you not liking the name of the event, what do you suggest we change?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net