Print Page | Close Window

Question about comboboxes on toolbars

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=657
Printed Date: 24 December 2024 at 7:44am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Question about comboboxes on toolbars
Posted By: Ark42
Subject: Question about comboboxes on toolbars
Date 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() ?




Replies:
Posted By: Oleg
Date 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



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