Solved

popup menu on the combobox

Posted on 1997-07-13
2
382 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 103
cat dog challenge 18 124
Expand data scrubbing tool 13 32
pre4 challenge 19 100
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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