Click here to Skip to main content
15,914,323 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: vc++ 6--add member function, using macros Pin
Nish Nishant2-Mar-03 13:05
sitebuilderNish Nishant2-Mar-03 13:05 
GeneralRe: vc++ 6--add member function, using macros Pin
7stud2-Mar-03 15:20
7stud2-Mar-03 15:20 
GeneralRe: vc++ 6--add member function, using macros Pin
Christian Graus2-Mar-03 15:25
protectorChristian Graus2-Mar-03 15:25 
GeneralRe: vc++ 6--add member function, using macros Pin
7stud2-Mar-03 16:01
7stud2-Mar-03 16:01 
GeneralProblem with Radio Buttons Pin
Ph@ntom2-Mar-03 8:48
Ph@ntom2-Mar-03 8:48 
GeneralRe: Problem with Radio Buttons Pin
Chris Losinger2-Mar-03 9:23
professionalChris Losinger2-Mar-03 9:23 
GeneralRe: Problem with Radio Buttons Pin
Big Art2-Mar-03 9:39
Big Art2-Mar-03 9:39 
GeneralScroll Bar does NOT work... Pin
Jakob Bysewski2-Mar-03 7:09
Jakob Bysewski2-Mar-03 7:09 
Hi,
I'm programming some years, but I just started with the MFC. So I downloaded the Undo/Redo Demo, which helped me a lot. Now I tried to implement Scroll Bars. The vertical one does exactly what it should, but the horizontal one, em
In debug Mode (VC++ 6.0) the following happens:
At first everything works fine, both scroll bars work. When I try to create a new, or to open an existing document I get an "Debug Assertion Failed!" Error for File: wincore.cpp Line: 628

If I compile this as release I am able to create a new, or to open an existing document, but the horizontal scroll bar gets invisible.
I know its there; when I drag it it is visible. When I resize the window it gets visible,too. But after the next repaint of the window it disappears. The code for the vertical and the horizontal bar is exactly the same, but one bar works and the other...

I used the following code:
8< out of my View class definition
...
CScrollBar m_wndVScrollBar;
CScrollBar m_wndHScrollBar;
...
>8

8< And these are my scrlling functions

void CUndo_Redo_DemoView::OnInitialUpdate()
{
m_wndVScrollBar.Create(WS_CHILD|SBS_VERT,CRect(0,0,0,0),this,0x0000);
m_wndHScrollBar.Create(WS_CHILD|SBS_HORZ,CRect(0,0,0,0),this,0x0000);

CRect rc;
GetClientRect(rc);

// Fake a size message
OnSize(0,rc.Width(),rc.Height());
};

void CUndo_Redo_DemoView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);


if (::IsWindow(m_wndVScrollBar.m_hWnd))
{
RECT tmpRect;
CWnd::GetClientRect(&tmpRect);

int nLeft = cx - 20;
int nTop = 0;
int nRight = cx;
int nBottom = tmpRect.bottom-20;

SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE;
si.nMin = 0;
si.nMax = 1000;
si.nPage = 50;

// Position Scroll Bar
CRect rect(nLeft, nTop, nRight, nBottom);
m_wndVScrollBar.SetScrollInfo(&si,TRUE);
m_wndVScrollBar.MoveWindow(rect);

if (UINT(si.nMax) < si.nPage)
m_wndVScrollBar.ShowScrollBar(FALSE);
else
m_wndVScrollBar.ShowScrollBar(TRUE);

}

if (::IsWindow(m_wndHScrollBar.m_hWnd))
{
RECT tmpRect;
CWnd::GetClientRect(&tmpRect);

int nLeft = 0;
int nTop = tmpRect.bottom-20;
int nRight = cx-20;
int nBottom = tmpRect.bottom;

SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE;
si.nMin = 0;
si.nMax = 1000;
si.nPage = 50;

// Position Scroll Bar
CRect rect(nLeft, nTop, nRight, nBottom);
m_wndHScrollBar.SetScrollInfo(&si,TRUE);
m_wndHScrollBar.MoveWindow(rect);

if (UINT(si.nMax) < si.nPage)
m_wndHScrollBar.ShowScrollBar(FALSE);
else
m_wndHScrollBar.ShowScrollBar(TRUE);

}
}

int CUndo_Redo_DemoView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
if (zDelta > 0)
SendMessage(WM_VSCROLL,SB_PAGEUP,0);

if (zDelta < 0)
SendMessage(WM_VSCROLL,SB_PAGEDOWN,0);


return CView::OnMouseWheel(nFlags, zDelta, pt);
}

void CUndo_Redo_DemoView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{

SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
m_wndVScrollBar.GetScrollInfo(&si);

switch (nSBCode)
{
case SB_TOP:
si.nPos = si.nMin;
break;
case SB_BOTTOM:
si.nPos = si.nMax;
break;
case SB_LINEDOWN:
si.nPos += 1;
break;
case SB_LINEUP:
si.nPos -= 1;
break;
case SB_PAGEUP:
si.nPos -= si.nPage;
break;
case SB_PAGEDOWN:
si.nPos += si.nPage;
break;
case SB_THUMBTRACK:
si.nPos = si.nTrackPos;
break;
}

si.fMask = SIF_POS;
m_wndVScrollBar.SetScrollInfo(&si,TRUE);
Invalidate();


CView::OnVScroll(nSBCode, nPos, pScrollBar);
}

void CUndo_Redo_DemoView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{

SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
m_wndHScrollBar.GetScrollInfo(&si);

switch (nSBCode)
{
case SB_LEFT:
si.nPos = si.nMin;
break;
case SB_RIGHT:
si.nPos = si.nMax;
break;
case SB_LINERIGHT:
si.nPos += 1;
break;
case SB_LINELEFT:
si.nPos -= 1;
break;
case SB_PAGERIGHT:
si.nPos -= si.nPage;
break;
case SB_PAGELEFT:
si.nPos += si.nPage;
break;
case SB_THUMBTRACK:
si.nPos = si.nTrackPos;
break;
}

si.fMask = SIF_POS;
m_wndHScrollBar.SetScrollInfo(&si,TRUE);
Invalidate();


CView::OnHScroll(nSBCode, nPos, pScrollBar);
}

>8

Thank you for reading this, I'm sure it's all my fault, but I'm just learning Wink | ;)

Greetings,
Jakob Bysewski

Build a system that even a fool can use, and only a fool will use it.
GeneralRe: Scroll Bar does NOT work... Pin
PJ Arends2-Mar-03 8:23
professionalPJ Arends2-Mar-03 8:23 
GeneralRe: Scroll Bar does NOT work... Pin
Jakob Bysewski2-Mar-03 10:11
Jakob Bysewski2-Mar-03 10:11 
QuestionHow to disable a control Pin
George Paris2-Mar-03 5:41
sussGeorge Paris2-Mar-03 5:41 
AnswerRe: How to disable a control Pin
NormDroid2-Mar-03 6:20
professionalNormDroid2-Mar-03 6:20 
GeneralNeed Add-In Wizard or sample code for visual c++.net Pin
Pepper232-Mar-03 5:14
Pepper232-Mar-03 5:14 
QuestionCSocket is bad? Pin
User 66582-Mar-03 4:53
User 66582-Mar-03 4:53 
AnswerRe: CSocket is bad? Pin
valikac2-Mar-03 7:57
valikac2-Mar-03 7:57 
QuestionHowto draw text in rectangle ? Pin
bumper2-Mar-03 4:29
bumper2-Mar-03 4:29 
AnswerRe: Howto draw text in rectangle ? Pin
NormDroid2-Mar-03 4:36
professionalNormDroid2-Mar-03 4:36 
GeneralRe: Howto draw text in rectangle ? Pin
bumper2-Mar-03 4:48
bumper2-Mar-03 4:48 
AnswerRe: Howto draw text in rectangle ? Pin
Michael Dunn2-Mar-03 5:24
sitebuilderMichael Dunn2-Mar-03 5:24 
GeneralRe: Howto draw text in rectangle ? Pin
bumper2-Mar-03 7:59
bumper2-Mar-03 7:59 
AnswerRe: Howto draw text in rectangle ? Pin
PJ Arends2-Mar-03 9:06
professionalPJ Arends2-Mar-03 9:06 
AnswerRe: Howto draw text in rectangle ? Pin
PJ Arends2-Mar-03 9:17
professionalPJ Arends2-Mar-03 9:17 
GeneralAnti-aliased line with GDI Pin
bumper2-Mar-03 4:21
bumper2-Mar-03 4:21 
GeneralRe: Anti-aliased line with GDI Pin
Anders Molin2-Mar-03 4:40
professionalAnders Molin2-Mar-03 4:40 
GeneralRe: Anti-aliased line with GDI Pin
bumper2-Mar-03 4:44
bumper2-Mar-03 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.