Re: Re: CWindowImpl and dynamically created button
Root Null <imperialgeniusx-/[email protected]>
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <[email protected]> |
Thanks for the replies: I'm using Remote Spy (this application is on Windows Mobile, actually) and it confirms that clicking on the button does not generate any messages in ANY windows in the application. I will build out an app that isolates the behavior I'm seeing on the desktop platform and post a link to that once I'm done (or if it doesn't have the same problem!). --- On Wed, 10/21/09, domehead100 <[email protected]> wrote: > From: domehead100 <[email protected]> > Subject: [wtl] Re: CWindowImpl and dynamically created button > To: [email protected] > Date: Wednesday, October 21, 2009, 9:20 AM > As Jim, said, a small code sample or > sample project would be helpful. > > With the freezes, it sounds like something is definitely > not right :o). > > How do you know the button is not sending messages? > Are you using Spy++? If that doesn't work for you, there are > some fairly easy ways to hook SendMessage calls and log them > in your debug build, for example, using the Detours library > from Microsoft. > > --- In [email protected], > Root Null <imperialgeniusx@...> wrote: > > > > Mike, > > thanks for the response: I am > creating (4) inside of (2), but setting (3) to be its > parent. I'm looking for just regular run of the mill button > behavior: when I click on the button it should switch > colors/behave like a button/generate WM_COMMAND messages to > someone (ANYONE will do), but none of those happen at all. > > > > To further complicate things, I've been getting these > periodic application freezes: the app simply stops > responding to clicks or scrolls or menu requests. About 1 > out of every 3 times, it recovers after 10 to 20 seconds. > Other times I have to force kill the debugging session. I'm > assuming both of these are somehow related and there's > something foolish I'm doing, but I'm at a bit of a loss. I'm > largely a Java person or old style Win32, and this WTL thing > is new for me. > > > > Imp. > > > > --- On Tue, 10/20/09, domehead100 > <domehead100@...> wrote: > > > > > From: domehead100 <domehead100@...> > > > Subject: [wtl] Re: CWindowImpl and dynamically > created button > > > To: [email protected] > > > Date: Tuesday, October 20, 2009, 11:57 AM > > > 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 > > > > > > > > > mailto:[email protected] > > > > > > > > > > > > > > > > ------------------------------------ > > Yahoo! Groups Links > > > mailto:[email protected] > > > ------------------------------------ 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/