Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. message handling for a popup window

message handling for a popup window

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    misha_grewal
    wrote on last edited by
    #1

    I create a list box as a popup window with parent as NONE and display it below a combo box. (This is imitation of intellisearch IE or IAutoComplete in WTL) The creation of the listbox looks like this CMyComboBox::CreateListbox() { BOOL bRet = _list.CreateEx(0, _T("ComboLBox"), _T(""), WS_POPUP | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_NOTIFY, clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height(), this->GetSafeHwnd(), //this is the combobox control's hwnd// NULL, NULL); } I display this listbox when user starts typing some text in the combobox. I add the filtered strings as per the text to this listbox. There are two problems 1. I am trapping all the messages send to Listbox in its windowproc. I find that the first time I display this listbox, I am able to see LBN_SELCHANGE (or other listbox specific messages) being trapped in Windowproc. But they are sent only once. The next time when I try to change any selection, LBN_SELCHANGE is not sent/trapped (I don't know where this message goes). Although the basic messages - LBUTTON_DOWN/UP, KEY_DOWN/UP are being sent to the Listbox. I intend to write something like below, but LBN_SELCHANGE is caught only once. LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case LBN_SELCHANGE: { //Send this message to the combobox with the selected text // as argument }break; Does the question make sense? or its too vague? :~ 2. I need to find a decent way to send the listbox messages to the combobox. Since the combobox is not at all related to Listbox here, I may have to resort to registering a callback in the Listbox to handle the messages. Is there any other way to handle the messages? Thanks first of all for reading the question. Many many thanks if you got some answers

    Evil triumphs when good people sit quiet...

    R 1 Reply Last reply
    0
    • M misha_grewal

      I create a list box as a popup window with parent as NONE and display it below a combo box. (This is imitation of intellisearch IE or IAutoComplete in WTL) The creation of the listbox looks like this CMyComboBox::CreateListbox() { BOOL bRet = _list.CreateEx(0, _T("ComboLBox"), _T(""), WS_POPUP | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_NOTIFY, clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height(), this->GetSafeHwnd(), //this is the combobox control's hwnd// NULL, NULL); } I display this listbox when user starts typing some text in the combobox. I add the filtered strings as per the text to this listbox. There are two problems 1. I am trapping all the messages send to Listbox in its windowproc. I find that the first time I display this listbox, I am able to see LBN_SELCHANGE (or other listbox specific messages) being trapped in Windowproc. But they are sent only once. The next time when I try to change any selection, LBN_SELCHANGE is not sent/trapped (I don't know where this message goes). Although the basic messages - LBUTTON_DOWN/UP, KEY_DOWN/UP are being sent to the Listbox. I intend to write something like below, but LBN_SELCHANGE is caught only once. LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case LBN_SELCHANGE: { //Send this message to the combobox with the selected text // as argument }break; Does the question make sense? or its too vague? :~ 2. I need to find a decent way to send the listbox messages to the combobox. Since the combobox is not at all related to Listbox here, I may have to resort to registering a callback in the Listbox to handle the messages. Is there any other way to handle the messages? Thanks first of all for reading the question. Many many thanks if you got some answers

      Evil triumphs when good people sit quiet...

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #2

      misha_grewal wrote:

      LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case LBN_SELCHANGE: {

      [LBN_SELCHANGE^] is a notification message sent through WM_COMMAND message. Correct it and check, later we discuss for the decent way.

      misha_grewal wrote:

      But they are sent only once

      Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.

      modified on Monday, April 28, 2008 10:35 AM

      M 1 Reply Last reply
      0
      • R Rajkumar R

        misha_grewal wrote:

        LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case LBN_SELCHANGE: {

        [LBN_SELCHANGE^] is a notification message sent through WM_COMMAND message. Correct it and check, later we discuss for the decent way.

        misha_grewal wrote:

        But they are sent only once

        Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.

        modified on Monday, April 28, 2008 10:35 AM

        M Offline
        M Offline
        misha_grewal
        wrote on last edited by
        #3

        Thanks a ton..

        Rajkumar R wrote:

        Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.

        Yes, I think thats what I was catching.. The windowproc of the list box is getting all the WM messages like WM_KEYDOWN or LBUTTONUP. But a message like LBN_SELCHANGE is never caught in windowproc. why is it so? WM_COMMAND is sent to a parent of a window and the wparam has the message id. In this case, the list box doesn't have any parent as such, so you never receive WM_COMMAND messages

        Evil triumphs when good people sit quiet...

        R 1 Reply Last reply
        0
        • M misha_grewal

          Thanks a ton..

          Rajkumar R wrote:

          Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.

          Yes, I think thats what I was catching.. The windowproc of the list box is getting all the WM messages like WM_KEYDOWN or LBUTTONUP. But a message like LBN_SELCHANGE is never caught in windowproc. why is it so? WM_COMMAND is sent to a parent of a window and the wparam has the message id. In this case, the list box doesn't have any parent as such, so you never receive WM_COMMAND messages

          Evil triumphs when good people sit quiet...

          R Offline
          R Offline
          Rajkumar R
          wrote on last edited by
          #4

          misha_grewal wrote:

          the list box doesn't have any parent as such

          ComboBox is the parent which you already set in CreateEx and get Notified since you set WM_NOTIFY, Any way since you are using MFC use ON_CONTROL_REFLECT to get the notification to the ListBox itself, Add handler to ListBox class to allow wizard to put ON_CONTROL_REFLECT macros.

          modified on Tuesday, April 29, 2008 5:00 AM

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups