Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Question about comboboxes on toolbars
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Question about comboboxes on toolbars

 Post Reply Post Reply
Author
Message
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Topic: Question about comboboxes on toolbars
    Posted: 25 April 2004 at 5:25pm

Here is some condensed code from my program:


    ON_XTP_EXECUTE(ID_VIEW_ZOOM, OnViewZoom)
    ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM, OnUpdateViewZoom)



void CPicView::OnViewZoom(NMHDR* pNMHDR, LRESULT* pResult)
{
    NMXTPCONTROL *tagNMCONTROL = (NMXTPCONTROL *)pNMHDR;
    CXTPControlComboBox *pControl = reinterpret_cast<CXTPControlComboBox *>(tagNMCONTROL->pControl);
    ::SetZoom(pControl->GetEditText());
    *pResult = TRUE;
}

void CPicView::OnUpdateViewZoom(CCmdUI* pCmdUI)
{
    CXTPControlComboBox *pControl = reinterpret_cast<CXTPControlComboBox *>(CXTPControl::FromUI(pCmdUI));

    if( ::ShouldBeEnabled ) {
        pCmdUI->Enable();
        if( GetFocus() != pControl->GetEditCtrl() ) {
            CString str = ::GetZoom();
           
            if( pControl->GetEditText() != str ) {
                pControl->GetEditCtrl()->SetWindowText(str);
            }
        }
    } else {
        pControl->GetEditCtrl()->SetWindowText("");
    }
}


Now, my question is why do I have to use GetEditCtrl()->SetWindowText() instead of just SetEditText() ?  Calling GetEditText() seems to work just fine to retrieve it, but using SetEditText() causes all kinds of problems, particularly when I have two of the same control on the toolbar and want them to always be in sync, and when switching back and forth between two open MDI windows both using this view, and thus the zoom combo on the toolbar should reflect the active MDI window's view.
I think I finally got the code working, using the GetEditCtrl()->SetWindowText() but I really want to know if I am using the combobox in the proper way, and why can't I use SetEditText() ?

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 05 May 2004 at 11:48pm

Agree, it was problem in SetEditText. fixed now.

Your solution is good too.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.094 seconds.