|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
pascal bosquet
|
Nov 26, 2004 - 1:57 AM
|
Hello there,
I’m new to prof-uis(freeware) and mfc, so my question will surely be easy for you ;) I’d like to display a picture in a CExtControlBar and being able to scroll if the picture is too big. For this i’ve a class which inherit from CExtScrollWnd. Your articles mention that for using a CExtScrollWnd i have to create my bars myself and set their parents to the CExtScrollWnd. So here come my problem. I’ve overloaded the Create function CExtScrollWnd so i can create my 2 bars. But the troubles is that the CWnd:Create() will call the GetScrollBarCtrl() which are not created yet. So my app crash. But how can i create the Bars if the parent doesn’t exist yet, and how can i create the the CExtScrollWnd if the bars doesn’t exist yet ? i’m confused. I don’t see how i can solve this
thanks in advance for your clues
Pascal
BOOL CBankPanel::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { BOOL ret;
if(!CWnd::Create( lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext)) { ASSERT(FALSE); return FALSE; }
// create the bars if(!m_HBar.Create(SBS_HORZ | SBS_TOPALIGN | WS_CHILD, CRect(5, 5, 100, 30), this,10000)) { ASSERT(FALSE); return FALSE; }
if(!m_VBar.Create(SBS_VERT | SBS_LEFTALIGN | WS_CHILD, CRect(5, 5, 100, 30), this,10001)) { ASSERT(FALSE); return FALSE; }
return TRUE; }
CScrollBar* CBankPanel::GetScrollBarCtrl(int nBar) const { if(nBar==SB_HORZ) return (CScrollBar*)&m_HBar; else return (CScrollBar*)&m_VBar; }
|
|
Technical Support
|
Nov 26, 2004 - 11:19 AM
|
At least the CBankPanel::GetScrollBarCtrl method should look like this:CScrollBar * CBankPanel::GetScrollBarCtrl(int nBar) const
{
if(nBar==SB_HORZ)
return (CScrollBar*) ( (m_HBar.GetSafeHwnd() != NULL) ? (&m_HBar) : NULL );
else
return (CScrollBar*) ( (m_VBar.GetSafeHwnd() != NULL) ? (&m_VBar) : NULL );
} If the problem persists, send us your project so that we can help you.
|
|