Re: CWindowImpl and dynamically created button

"domehead100" <[email protected]>
Newsgroups gmane.comp.windows.wtl
Message-ID <[email protected]>
Are you creating (4) inside of (2), even though (4) is a child of (3)?
wnd.Create(_display->m_hWnd, rc, _T("TEST"), WS_CHILD|WS_VISIBLE,0,ID_TEST_ACTION);

(noting _display->m_hWnd)

Anyway, the button will send messages to it's parent.  The parent is apparently _display.  Are you looking for the messages in _display's message map?  If you're looking for them in (2)'s message map, they won't be sent to (2) but rather to (3)(_display) since that it the button's parent.

~Mike




--- In [email protected], "imperialgeniusx" <imperialgeniusx@...> wrote:
>
> Hi all,
>   I'm new to WTL and implementing custom controls and have been having some difficulty with what SHOULD be a pretty straightforward thing: adding a button to a CWindowImpl and then having the button respond to clicks and generate events. For some reason, this simply doesn't happen.
> 
>  The basic hierarchy I have is
> 
> CFrameWindowImpl
>   CWindowImpl (1)
>     CWindowImpl (2)
>       CButton (4)
>     CButton (3)
> 
> The numbers reflect the order things are created: everything is dynamically created, and (2) and (3) are created at the same time as children of (1), and (4) is created on demand later on as a child of (2).
> 
> When I display (1) and click on (3), I get WM_COMMAND messages. When I click on (2) anywhere other than the drawing area of (4), I get WM_LBUTTONDOWN and WM_LBUTTONUP messages. (4) is correctly drawn: I get WM_PAINT messages and the button appears in the CWindowImpl area correctly. However when I click on (4) I get nothing: no WM_LBUTTONDOWN, WM_LBUTTONUP or anything of that ilk.
> 
> (2) is created using the following code:
> 
> CVerticalLayout * _display = new CVerticalLayout(m_hWnd, IDC_DETAILS_LAYOUT);
> 
>  where CVerticalLayout is based on CWindowImpl. The constructor for CVerticalLayout does this:
> 
> this->Create(parent, NULL, L"VerticalLayout", WS_CHILD|WS_VISIBLE|WS_TABSTOP,0,uID);
> 
> and uses the following declarations/message map
> 
> DECLARE_WND_SUPERCLASS(_T("VerticalLayout"), GetWndClassName())
> BEGIN_MSG_MAP(CVerticalLayout)
> 	MESSAGE_HANDLER(WM_CREATE, OnCreate)
> 	MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
> 	MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
> 	MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
> END_MSG_MAP()
> 
> (3) is created using the following code:
> 
> CButton _action;
> _action.Create(this->m_hWnd,NULL, szDownload, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,0,ID_DETAILS_ACTION);
> 
> and (4) is created using this:
> 
> RECT rc;
> rc.top = 0; rc.bottom = 30; rc.left = 0; rc.right = 150;
> CButton wnd;
> wnd.Create(_display->m_hWnd, rc, _T("TEST"), WS_CHILD|WS_VISIBLE,0,ID_TEST_ACTION);
> 
>   Is this something that anyone else has seen before, or is there a magic setting somewhere I need to deploy to make this do the right thing? I thought that if (3) works then (4) should just work, but this doesn't seem to be the case. I don't even get the default button action when clicked. I get absolutely nothing. I've looked at this using Spy and it confirms that no messages are being sent to any of the windows in the application when I hover over the button's paint area and click, but messages are sent when I click anywhere else on the application.
> 
>   Thanks,
>   Imp.
>




------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.