[RESOLVED] Statusbar-update while mouse in CDialogbar?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 26

Thread: [RESOLVED] Statusbar-update while mouse in CDialogbar?

  1. #1
    Join Date
    Jul 2001
    Posts
    293

    [RESOLVED] Statusbar-update while mouse in CDialogbar?

    Hello,

    I have the following problem:
    my mainframe-window in a MDI-app has a CDialogbar.
    Everytime the mouse moves over a control in this dialogbar the status bar is updated by a text.
    The app craps the text from the ressource strings that has the same ID than the dialogbar-control, randomly.
    I do not want this.
    How can I avoid this?

    thx.

    Ralf

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,610

    Re: Statusbar-update while mouse in CDialogbar?

    Perhaps, you could handle yourself WM_SETMESSAGESTRING in the CMainFrame class rather the use default handler CFrameWnd::OnSetMessageString?
    More info in http://msdn.microsoft.com/en-us/magazine/cc301407.aspx beginning with the question
    I have an app that has a dynamically changing menu item. I can use CCmdUI::SetText("Menu Text") to change the menu text, but how do I dynamically change the tooltip/status bar text?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2001
    Posts
    293

    Re: Statusbar-update while mouse in CDialogbar?

    Hello Victor,

    yes, I know that.
    But the problem is: how do I know who sends the message?
    I only do not want to show the MessageStrings from my CDialogbar; all other messages should be shown.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,610

    Re: Statusbar-update while mouse in CDialogbar?

    Then try to override CControlBar::SetStatusText
    Victor Nijegorodov

  5. #5
    Join Date
    Jul 2001
    Posts
    293

    Re: Statusbar-update while mouse in CDialogbar?

    Quote Originally Posted by VictorN View Post
    Then try to override CControlBar::SetStatusText
    do you have a documentation of this function?

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,610

    Re: Statusbar-update while mouse in CDialogbar?

    No, but is not so complicated. Just look at this implementation in ..\src\mfc\barcore.cpp
    Victor Nijegorodov

  7. #7
    Join Date
    Jul 2001
    Posts
    293

    Re: Statusbar-update while mouse in CDialogbar?

    I defined SetStatusText in my Cdialogbar-class.
    BUt it is not called.

    BOOL SetStatusText(int n);

    Any ideas?

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,610

    Re: Statusbar-update while mouse in CDialogbar?

    The signature you have used is wrong!
    Why dod you invent your own signatures rather than look at the one MSFT had implemented?
    Just have a look at the CControlBar declaration in the afxext.h:
    Code:
    	virtual BOOL SetStatusText(INT_PTR nHit);
    #ifdef _WIN64
            /* 
            Initial releases of 64 bit MFC had SetStatusText(int), same size as
            32 bit MFC. Since this function is virtual, it could be overridden.
    
            Future overriders of SetStatusText should do so by overriding the
            INT_PTR version. But this extra function will allow 64 bit code ported
            from MFC70 to continue to work correctly.
            */
    	virtual BOOL SetStatusText(int nHit);
    #endif
    Victor Nijegorodov

  9. #9
    Join Date
    Jul 2001
    Posts
    293

    Re: Statusbar-update while mouse in CDialogbar?

    sorry, in vc6 it is defined like:
    virtual BOOL SetStatusText(int nHit);

    and it is also not called with
    virtual BOOL SetStatusText(INT_PTR nHit);

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,610

    Re: Statusbar-update while mouse in CDialogbar?

    Quote Originally Posted by Ralf Schneider View Post
    sorry, in vc6 it is defined like:
    virtual BOOL SetStatusText(int nHit);
    You had to mention in your OP that you still use a 17 years old IDE!

    Quote Originally Posted by Ralf Schneider View Post
    it is also not called with
    virtual BOOL SetStatusText(INT_PTR nHit);
    In the VC++6.0 it should be declared as
    Code:
    virtual BOOL SetStatusText(int nHit);
    Victor Nijegorodov

  11. #11
    Join Date
    Jul 2001
    Posts
    293

    Re: Statusbar-update while mouse in CDialogbar?

    Quote Originally Posted by VictorN View Post
    In the VC++6.0 it should be declared as
    Code:
    virtual BOOL SetStatusText(int nHit);
    yes, and I declared it the same way in my class as I told you before:
    BOOL SetStatusText(int n);

    Anyway, is there something wrong which I did not see?

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,610

    Re: Statusbar-update while mouse in CDialogbar?

    Yes it is. But I have no idea what since you do not show your code.
    I just have tested with a simple MDI with CToolBar derived class in which I overridden this
    Code:
    BOOL SetStatusText(int n);
    This override is called when I move mouse over the toolbar.
    Victor Nijegorodov

  13. #13
    Join Date
    Jul 2001
    Posts
    293

    Re: Statusbar-update while mouse in CDialogbar?

    this is the class declaration with the test-function:
    it is never called.
    Code:
    class CGleisBar : public CDialogBar
    {
    // Construction
    public:
    	CGleisBar();   // standard constructor
    
        BOOL Create( CWnd* pParentWnd, UINT nIDTemplate, UINT nStyle,
                     UINT nID, BOOL = TRUE);
    
    // Attributes
    protected:
        CSize m_sizeDocked;
        CSize m_sizeFloating;
        BOOL m_bChangeDockedSize;   // Indicates whether to keep
    ...
    
    public:
    // Dialog Data
    ...
    
    // Overrides
    	// ClassWizard generated virtual function overrides
    	//{{AFX_VIRTUAL(CGleisBar)
    	protected:
    	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    	//}}AFX_VIRTUAL
    	virtual BOOL SetStatusText(INT_PTR nHit)
    		{MessageBeep(-1);return FALSE;}
    
    // Implementation
    protected:
    ...
    
    };

  14. #14
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,610

    Re: Statusbar-update while mouse in CDialogbar?

    1. Why do you declare it as
    Code:
    virtual BOOL SetStatusText(INT_PTR nHit)
    rather than
    Code:
    virtual BOOL SetStatusText(int nHit)
    in VC++6.0?

    2. How did you test whether it was called? Did you set a breakpoint within SetStatusText() implementation?
    Victor Nijegorodov

  15. #15
    Join Date
    Jul 2001
    Posts
    293

    Re: Statusbar-update while mouse in CDialogbar?

    I tested it with both: "INT_PTR" and "int".
    I tested it with a breakpoint and with the MessageBeep-Sound (see my code) which not appears!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center