Re: Catching messages of dynamically created CStatic members
Hi Joseph,
I know I could use a scroll bar, but for reasons I don't need to
explain (and that includes that I'm working under WinCE), I need to use
two CStatics. You say: "the confusion arose because you talk about two
custom controls". No, I never talked about two custom controls, I only
talked about one that contains two CStatic controls. I'm not deriving
anything from CStatic, I just create them dinamically and call
SetBitmap. That's it.
class CMyCustomCtl : public CWnd
{
private:
CStatic m_static1;
CStatic m_static2;
CRect CalcRectUp() const;
CRect CalcRectDown() const;
protected:
DECLARE_MESSAGE_MAP();
public:
BOOL Create(CRect& rect, CWnd* pParent, UINT nID)
{
BOOL bRet;
bRet = CWnd::Create(_T("MyCustomCtrl"), _T(""),
WS_VISIBLE | WS_CHILD, rect, pParent, nID);
m_lblArrowUp.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_BITMAP |
SS_NOTIFY,
CalcRectUp(), this, IDC_ARROWUP);
m_lblArrowDown.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_BITMAP |
SS_NOTIFY,
CalcRectDown(), this, IDC_ARROWDOWN);
return bRet;
}
};
Concerning about the scrollbar, it isn't enough to just create a
CScrollBar, because there are many features needed in the application
that WinCE does not support in its controls, and I have to simulate
them.
Finally, the wrong thing was that I was missing the SS_NOTIFY style
while creating the CStatic's.
Thanks for your time and comments.
Regards,
Fernando.
Joseph M. Newcomer wrote:
BUt you could put a scrollbar inside a custom control trivially; just create it as the
child control of your custom control!
The confusion arose because you talk about two custom controls, and two controls derived
from CStatic, and the association seemed to be 1:1.
But if you need a scrollbar, just create it as a child control of your custom control, and
in your custom control put the message map entries to handle it. Unless you need some
weird size control, this should work fine. If you need some weird size control that can't
be created from CScrollBar, then you can make the controls child controls of hte custom
control, and siblings of the other controls inside the static control. If you only need
an up/down control, just use an up/down control, which you can resize to the size you
need. Note that the dialog editor has some weird behavior in terms of sizing, so when
I've done this, I have to resize the control at runtime.
joe
On 10 Jul 2006 09:29:58 -0700, "fernando.a.gomez.f@gmail.com"
<fernando.a.gomez.f@gmail.com> wrote:
Hi Joseph,
thanks for your interest.
First, I need them to be created dynamically because they represent the
up and down arrow of a custom scrollbar within a custom control.
Second, yes, I didn't specify the SS_NOTIFY, that was the mistake
indeed.
Next, either I explained myself wrong or you didn't understand. I never
said I want some controls derived from CStatic, I said I'm creating a
custom control, derived from CWnd as any other custom control, that has
two members of type CStatic. I didn't show message map entries because
there was no need to.
Thanks again for your comments.
Regards,
FG.
Joseph M. Newcomer wrote:
If it has two members, why bother to create them dynamically?
Note that you have not specifed SS_NOTIFY, so these static controls (they are not pure
CWnd-derived as you suggest) will not generate any notifications at all.
You have not shown any message map entries; you would need to create message map entries.
Because you are deriving from CStatic, the messages you can get are limited. Another
solution would be to simply put a scrollbar control in as the child of your control.
joe
On 7 Jul 2006 09:47:03 -0700, "fernando.a.gomez.f@gmail.com"
<fernando.a.gomez.f@gmail.com> wrote:
Hi fellows. I have a CWnd-derived class that has two CStatic members,
that are created dynamically.
My question is simple: What must I do in order to receive messages of
such members?
This CWnd-derived class is for creating a custom control. This control
needs vertical scrollbar, so I'm using two bitmaps, one as de up arrow
and the other as the down arrow. I already placed them, now I need to
receive the notification (the click notification).
// in the header
CStatic m_lblArrowUp;
CStatic m_lblArrowDown;
// in the Create method
m_lblArrowUp.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_BITMAP, rectUp,
this, IDC_ARROWUP);
m_lblArrowDown.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_BITMAP,
rectDown, this, IDC_ARROWDOWN);
m_lblArrowUp.SetBitmap(LoadBitmap(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_VERTICLE_SCROLLBAR_UPARROW)));
m_lblArrowDown.SetBitmap(LoadBitmap(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_VERTICLE_SCROLLBAR_DOWNARROW)));
Any clue will be really appreciated.
Regards,
FG.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm