Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Combo Box event

Posted on 1999-08-02
3
Medium Priority
?
392 Views
Last Modified: 2013-11-20
Hi,

I've managed to get a combo box along with some icons ala a toolbar. My question is, what do I add to my MESSAGE_MAP in order to detect a change in the combo box selection? See my code below. I believe that IDW_COMBO is what I key off of but I don't know what the ON_COMMAND_??? or ON_UPDATE_??? or whatever should look like.

Thanks!

Dave P

      if (!m_wndStyleBar.Create(this, WS_CHILD|WS_VISIBLE|CBRS_TOP|
                  CBRS_TOOLTIPS|CBRS_FLYBY, IDW_STYLES_35MM) ||
            !m_wndStyleBar.LoadBitmap(IDB_TOOLBAR_123) ||
            !m_wndStyleBar.SetButtons(shockDesign, sizeof(shockDesign)/sizeof(UINT)))
      {
            TRACE0("Failed to create stylebar\n");
            return FALSE;       // fail to create
      }

      // Create the combo box
      m_wndStyleBar.SetButtonInfo(0, IDW_COMBO, TBBS_SEPARATOR, 100);

      // Design guide advises 12 pixel gap between combos and buttons
      m_wndStyleBar.SetButtonInfo(1, ID_SEPARATOR, TBBS_SEPARATOR, 12);
      CRect rect;
      m_wndStyleBar.GetItemRect(0, &rect);
      rect.top = 3;
      rect.bottom = rect.top + nDropHeight;
      if (!m_wndStyleBar.m_comboBox.Create(
                  CBS_DROPDOWNLIST|WS_VISIBLE|WS_TABSTOP,
                  rect, &m_wndStyleBar, IDW_COMBO))
      {
            TRACE0("Failed to create combo-box\n");
            return FALSE;
      }

      //  Fill the combo box

<snip>
0
Comment
Question by:dave_p
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 400 total points
ID: 1312365
Add these message map entries in your class for tool bar with combo box..


// Source File ..
BEGIN_MESSAGE_MAP(CToolBarWithCombo, CToolBar)
ON_CBN_CHANGE(IDW_COMBO, OnSelChangeComboBox)
ON_UPDATE_COMMANd_UI(IDW_COMBO, OnUpdateComboBox)
End_MESSAGE_MAP


// Header file..
afx_msg void OnSelChangeComboBox ();
afx_msg void OnUpdateComboBox (CCmdUi *pCmdUI);

Let me know if yu have any questions ...

Cheers!
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1312366
oops...mistake ..

1.the UPDATE message needs to be added to class which is handling the combo box selection message, not in the toolbar class. It can be Doc/View/Frame .. etc..

e.g. If you are handling the combo box messages in Document then you will add it there..

BEGIN_MESSAGE_MAP (cMyDoc, CDocument)
ON_UPDATE_COMMAND_UI(IDW_COMBO, OnUpdateComboBox)
ENd_MESSAGE_MAP

2.The toolbar derived class will first handle the CBN_SELCHANGE message and post a WM_COMMAND message for the frame work. Then the class which is handling the messages for this combo box will recieve it and process accordingly ..



Good Luck!

0
 

Author Comment

by:dave_p
ID: 1312367
Thanks you very much for your reply. It works great. I do have a followup
question just so I understand what's going on:

ON_CBN_CHANGE(IDW_COMBO, OnSelChangeComboBox)
ON_UPDATE_COMMANd_UI(IDW_COMBO, OnUpdateComboBox)

Actually it is ON_CBN_SELCHANGE but I figured that out with your
help. What is the ON_UPDATE_COMMAND_UI for?
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question