chetan verma <[EMAIL PROTECTED]> wrote:                               
 
 chetan verma <[EMAIL PROTECTED]> wrote:                               
  
  Mickey Mathieson <[EMAIL PROTECTED]> wrote:                               
   --- chetan verma <[EMAIL PROTECTED]>
   wrote:
   
   > hi,
   > I am trying to create a "drop down tree" control
   > similar to "drop down list" (or combobox). I have
   > derived my class from CComboBox and have a CTreeCtrl
   > object in my derived class. What I am trying to do
   > is draw my tree over the dropped down list box.
   > Everything works fine except the scroll bar.
   > After I make my tree visible I call SetCapture to
   > capture all the mouse inputs (Two reasons to do so:
   > 1] I need to know if user clicked outside tree so
   > that i can make the tree invisible 2] The dropped
   > down list of the combo box does the same thing so,
   > to make sure that messages are sent to tree instead
   > of the list control.)
   > But After calling this the scroll bar in the tree
   > doesn't works. I can scroll using the mouse wheel
   > but scroll bar doesn't responds.
   > If you know how to handle this please help me.
   > If you have any doubts please let me know.
   > 
   > 
   > Following are the functions called to show/hide the
   > tree
   > 
   >
   
//=============================================================================
   > void uiTreeComboBox::show_drop_down(CRect*
   > dropped_rect)
   > {
   >   InterceptParentWndProc();  //function to subclass
   > parent window to capture the messages sent by
   > combobox to its parent
   >   display_tree(dropped_rect); //dropped rect is the
   > rect of the dropped down list
   >   dropped_state = utTRUE;
   >   m_treectrl.Invalidate();
   >   Invalidate();
   >   ::SetCapture(m_treectrl.GetSafeHwnd()); 
   > }
   > 
   > 
   >
   
//=============================================================================
   > void uiTreeComboBox::hide_drop_down()
   > {
   >   dropped_state = utFALSE;
   >   ::ReleaseCapture();
   >   m_treectrl.ShowWindow(SW_HIDE);
   >   UnInterceptWndProc(); 
   >   Invalidate();
   >  }
   > 
   The mouse capture should only be set when the mouse
   leaves the drop down (treecntl).
   
   Check out the messages WM_MOUSELEAVE and WM_MOUSENTER.
   
   When the WM_MOUSELEAVE is sent turn on the mouse
   capture. When WM_MOUSEENTER is sent turn off the mouse
   capture.
   
   Mickey M.
   Construction Partner Inc.
   http://www.constructionpartner.com
    
  
  Thanks Mickey for your help. I tried doing this but it did not help. After I 
capture mouse i don't get the mouse leave message. And also after releasing i 
am not getting any mouse move messages until i click on the tree window.
  Is there any way to get the handle of the scroll bar in the tree window. What 
I am thinking is to post the message to scroll bar whenever i get mouse move or 
mouse click messages.
  
  Thanks and regards
  chetan
  
 
 Hi,
 I also tried something like this:
 Besides doing with the tree what i have to, i am also checking for the window 
on which the mouse actually moved or the click event occurred, by getting its 
handle using function, ::WindowFromPoint() and i am posting the message to that 
window also after converting the co-ordinates. But everything other except 
scrollbar seems to work fine. The other buttons are getting highlighted, 
behaving as they should when mouse moves over them, but the scroll bar doesn't 
responds.
 On having a close look in the debugger i found that when i click on the 
scrollbar the handle i get is of the tree itself.
 If you have any suggestions please help.
 
 //=============================================================================
 LRESULT CALLBACK uiTreeComboBox::tree_wnd_proc(
   HWND hWnd,
   UINT nMsg,
   WPARAM wParam,
   LPARAM lParam
 )
 {
 
 CPoint point;
   point.x = GET_X_LPARAM(lParam);
   point.y = GET_Y_LPARAM(lParam);
 
 CRect dropped_rect;
   CRect combo_rect;
   m_activecombo->GetWindowRect(&combo_rect);
   
   
   if(nMsg == WM_MOUSEMOVE) {
     m_activecombo->OnTreeMouseMove(hWnd, wParam, lParam);
   }
 
 if(nMsg == WM_LBUTTONDOWN || nMsg == WM_MOUSEMOVE) {
     CPoint point2 = point;
     m_activecombo->m_treectrl.ClientToScreen(&point2);
     HWND hwnd = ::WindowFromPoint(point2);
     CWnd* cwnd = CWnd::FromHandle(hwnd);
     cwnd->ScreenToClient(&point2);
     LPARAM lp = MAKELPARAM(point2.x, point2.y);
     if(hwnd != hWnd && hwnd != m_activecombo->GetSafeHwnd()) {
       ::PostMessage(hwnd,nMsg,wParam,lp);
     }
   }
 ...
 ...
 }
 Thanks and regards
 chetan
 

Hi,
Finally, I solved the problem. I am posting what i did, just in case if its 
useful for anyone:
The function where i am handling the messages recieved by the tree, i get the 
information about the tree' vertical scroll bar. If the message is mouse move 
or lbuttondown and there is a scrollbar in the tree (i.e info.rgstate[0]==0) 
Then i am checking if the point (of mouse move or lbuttondown event) is in the 
scrollbar's rectangle; if it is, then send a WM_NCxxx message to the tree 
itself.
I don't know why but the tree window loses its mouse capture on sending the 
message so had to make a call to setcapture to get the capture back.
If anyone knows a cleaner solution to this please let me know.

  SCROLLBARINFO info;
  info.cbSize = sizeof(info);
  m_activecombo->m_treectrl.GetScrollBarInfo(OBJID_VSCROLL, &info);

  if(nMsg==WM_MOUSEMOVE && info.rgstate[0] == 0) {
    CRect scroll_rect = info.rcScrollBar;
    CPoint point2 = point;
    m_activecombo->m_treectrl.ClientToScreen(&point2);
    if(scroll_rect.PtInRect(point2)) {
      UINT new_msg = WM_NCMOUSEMOVE;
      LPARAM lp = MAKELPARAM(point2.x, point2.y);
      WPARAM wp = HTVSCROLL;
      ::SendMessage(hWnd,new_msg,wp,lp);
      ::SetCapture(m_activecombo->m_treectrl.GetSafeHwnd());
    }
  }


  if(nMsg==WM_LBUTTONDOWN && info.rgstate[0] == 0) {
    CRect scroll_rect = info.rcScrollBar;
    CPoint point2 = point;
    m_activecombo->m_treectrl.ClientToScreen(&point2);
    if(scroll_rect.PtInRect(point2)) {
      UINT new_msg = WM_NCLBUTTONDOWN;
      LPARAM lp = MAKELPARAM(point2.x, point2.y);
      WPARAM wp = HTVSCROLL;
      ::SendMessage(hWnd,new_msg,wp,lp);
      ::SetCapture(m_activecombo->m_treectrl.GetSafeHwnd());
    }
  }

Thanks and regards
chetan.

 





       
---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.

[Non-text portions of this message have been removed]

Reply via email to