Solved

popup menu on the combobox

Posted on 1997-07-13
2
377 Views
Last Modified: 2013-11-20


 Dear Jaba,

 everything seems to work fine, except the fact that the function EnumChildWindows() can retrieve either the entry field part of the combo or the listbox part of it. I wanted the popup to be sensitive only to the entry field part, how can I get the window class for the particular window retrieved? I'm not relying on GetStyle(), I want to check if the window is an entry field.
0
Comment
Question by:login
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
jaba earned 10 total points
ID: 1302556
Well. To do field sensitive popup menu you need subclass lisbox  arriving from combobox too. You can do this by following steps.
First , you need make class CMyListBox derived from CListBox. In this class you need dispatch OnRButtonDown. In last answer i advise to send WM_RBUTTONDOWN from edit control to combobox. In this case , to separate WM_RBUTTONDOW from listbox and edit you need uto use flag in static variable or, may be, use registred message instead of WM_RBUTTONDOWN .

Well , continue. Now we need dispatch event of lisbox appearing. You can do it :
BOOL CMyComboBox::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* lpResult)
{
    if(message == WM_COMMAND){
        if(HIWORD(lParam) == CBN_DROPDOWN){
            ASSERT(wParam == (UINT) GetDlgCtrlID() && LOWORD(lParam) == (UINT) m_hWnd);
            PostMessage(msgGetComboLBox);
/* I am posting user registred message to myself , This is signal  to subclass lisbox */

        } else if(HIWORD(lParam) == CBN_CLOSEUP){
            ASSERT(wParam == (UINT) GetDlgCtrlID() && LOWORD(lParam) == (UINT) m_hWnd);
            m_ComboList.DetachWindow();
        }
    }
    return CComboBox::OnChildNotify(message, wParam, lParam, lpResult);
}

When dispatching this signal message
LRESULT CMyComboBox::OnGetComboLBox(WPARAM, LPARAM)
{
    ASSERT(m_ComboList.m_hWnd == NULL);
    VERIFY(m_ComboList.SubclassWindow(::FindWindow("ComboLBox", NULL)));
/* !!!!!! Look to this . There is only ONE lisbox arriveed from combobox in System !!!! */
    return 0;
}

After this you have 2 subclassed subitems of combobox and you can separate rbuttondown from they

                       
0
 
LVL 3

Expert Comment

by:jaba
ID: 1302557
Hmm, what about accept or reject this answer :-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now