Click here to Skip to main content
15,889,863 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help - CString::LoadString(nID) is using the wrong resource handle! Pin
Chris Losinger30-Jun-01 8:19
professionalChris Losinger30-Jun-01 8:19 
GeneralRe: Help - CString::LoadString(nID) is using the wrong resource handle! Pin
James Millson30-Jun-01 14:53
James Millson30-Jun-01 14:53 
GeneralSimple ActiveX question ... Pin
Hadi Rezaee30-Jun-01 7:03
Hadi Rezaee30-Jun-01 7:03 
GeneralDLL IsWindow assert Pin
Peter Marino30-Jun-01 6:58
Peter Marino30-Jun-01 6:58 
GeneralRe: DLL IsWindow assert Pin
Mike Nordell30-Jun-01 8:02
Mike Nordell30-Jun-01 8:02 
GeneralRe: DLL IsWindow assert Pin
Peter Marino30-Jun-01 8:23
Peter Marino30-Jun-01 8:23 
GeneralScrolling problems Pin
SinclairE30-Jun-01 5:47
SinclairE30-Jun-01 5:47 
GeneralRe: Scrolling problems Pin
Julien1-Jul-01 15:32
Julien1-Jul-01 15:32 
If you create a new dialog (ie: wizard), delete all the gadgets from it then go it its properties and turn on vertical scrolling. You will need to play with the SCROLLINFO structure (add a member of new dialog class).

eg:
CDialogContainer::OnInitDialog()
{
CDialog::OnInitDialog();

m_pScrollInfo = new SCROLLINFO;
m_pScrollInfo->cbSize = sizeof(SCROLLINFO);
m_pScrollInfo->fMask = SIF_ALL;
m_pScrollInfo->nMin = 0;
m_pScrollInfo->nMax = 100;
m_pScrollInfo->nPage = 10;
m_pScrollInfo->nPos = 0;
m_pScrollInfo->nTrackPos= 0;

this->SetScrollWindow();

...
}

You will also need :

// ----------------------------------------------------------------------------
// Method: OnVScroll
//
// Abstract: Maintains the scroll bar.
// Called automatically from the scrollbar events
// Also called manually to update the scrollbar after changes.
//
// Arguments:
//
// UINT nSBCode : The Scroll type
// UINT nPos : For ScrollType SB_THUMBPOSITION nPos is the new position
// CScrollBar* pScrollBar : Ignored (usually NULL anyway)
//
// ----------------------------------------------------------------------------
void CDialogContainer::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
RECT rectClient;
int iButtonIncrement;
int iPageIncrement;
int iScrollAmount = 0;

//////////////////////////////////////////////////////////////
// Not interested in ENDSCROLL events.
//////////////////////////////////////////////////////////////
if (SB_ENDSCROLL == nSBCode)
return;

//////////////////////////////////////////////////////////////
// If we get events which would cause the scrolling to leave
// the range then just return.
// ie: Pressing the scrollup when its already up.
//////////////////////////////////////////////////////////////
if ( (m_pScrollInfo->nPos <= m_pScrollInfo->nMin) && (nSBCode == SB_LINEUP) )
return;
if ( (m_pScrollInfo->nPos <= m_pScrollInfo->nMin) && (nSBCode == SB_PAGEUP) )
return;
if ( (m_pScrollInfo->nPos >= m_pScrollInfo->nMax) && (nSBCode == SB_LINEDOWN) )
return;
if ( (m_pScrollInfo->nPos >= m_pScrollInfo->nMax) && (nSBCode == SB_PAGEDOWN) )
return;

this->m_vectorCDialogAddress[0]->GetClientRect(&rectClient);
iButtonIncrement = (rectClient.bottom - rectClient.top)/4;
iPageIncrement = (rectClient.bottom - rectClient.top);

switch (nSBCode)
{
case SB_LINEUP:
iScrollAmount = -iButtonIncrement;
break ;

case SB_LINEDOWN:
iScrollAmount = iButtonIncrement;
break ;

case SB_PAGEUP:
iScrollAmount = -iPageIncrement;
break ;

case SB_PAGEDOWN:
iScrollAmount = iPageIncrement;
break ;

case SB_THUMBPOSITION:
case SB_THUMBTRACK:
{
if (nPos > m_pScrollInfo->nMax)
nPos = m_pScrollInfo->nMax;
if (nPos < m_pScrollInfo->nMin)
nPos = m_pScrollInfo->nMin;
iScrollAmount = nPos-m_pScrollInfo->nPos;
}
break;
}

if ( (SB_LINEDOWN == nSBCode || nSBCode == SB_PAGEDOWN) &&
(m_pScrollInfo->nPos + iScrollAmount > (m_pScrollInfo->nMax - m_pScrollInfo->nPage)) )
{
//////////////////////////////////////////////////////////////
// Round off the last piece to the leftover amount
//////////////////////////////////////////////////////////////
iScrollAmount = (m_pScrollInfo->nMax - m_pScrollInfo->nPage - m_pScrollInfo->nPos);
}

if ( (SB_LINEUP == nSBCode || nSBCode == SB_PAGEUP) &&
(m_pScrollInfo->nPos + iScrollAmount < m_pScrollInfo->nMin) )
{
//////////////////////////////////////////////////////////////
// Round off the last piece to the leftover amount
//////////////////////////////////////////////////////////////
iScrollAmount = (m_pScrollInfo->nMin - m_pScrollInfo->nPos);
}

m_pScrollInfo->nPos += iScrollAmount;
this->ScrollWindow(0,-iScrollAmount); // opposite direction on scroll bar!
this->SetScrollInfo(SB_VERT,m_pScrollInfo,TRUE);
}

BOOL CDialogContainer::OnCommand(WPARAM wParam, LPARAM lParam)
{
//////////////////////////////////////////////////////////////
// Prevent Enter and ESC from closing the control.
//////////////////////////////////////////////////////////////
if (wParam == IDOK)
return FALSE;
if (wParam == IDCANCEL)
return FALSE;

return CDialog::OnCommand(wParam, lParam);
}

//////////////////////////////////////////////////////////////
// iIndex of -1 means preserve the position.
//////////////////////////////////////////////////////////////
void CDialogContainer::SetScrollWindow(int iIndex)
{
RECT rectClient ;
RECT rectDialogRect;
int iHeight;
int iScrollPos;

iScrollPos = m_pScrollInfo->nPos;
m_pScrollInfo->nPos = 0;
this->SetScrollInfo(SB_VERT,m_pScrollInfo,FALSE);
this->GetClientRect(&rectClient);

for (int i=0;i<m_vectorcdialogaddress.size();++i)
{
="" m_vectorcdialogaddress[i]-="">GetClientRect(&rectDialogRect);
iHeight = rectDialogRect.bottom - rectDialogRect.top;
rectDialogRect.top = (iHeight * i);
rectDialogRect.bottom = rectDialogRect.top + iHeight;
m_vectorCDialogAddress[i]->MoveWindow(&rectDialogRect);
m_vectorCDialogAddress[i]->ShowWindow(SW_SHOW);
}

int iRangeMax = (iHeight*m_vectorCDialogAddress.size());
if (iRangeMax <= (rectClient.bottom - rectClient.top))
{
this->EnableScrollBar(SB_VERT,ESB_DISABLE_BOTH);
iRangeMax = 0;
}
else
{
this->EnableScrollBar(SB_VERT,ESB_ENABLE_BOTH);
}

m_pScrollInfo->nPos = 0; // As we are going to SCROLL to where we want.
m_pScrollInfo->nMax = iRangeMax; // Total Height
m_pScrollInfo->nPage = (rectClient.bottom - rectClient.top); // Visable Height

this->SetScrollInfo(SB_VERT,m_pScrollInfo,FALSE);

//////////////////////////////////////////////////////////////
// Explicit scroll to the supplied entry.
//////////////////////////////////////////////////////////////
if (iIndex != -1)
this->OnVScroll(SB_THUMBPOSITION,iIndex*iHeight,NULL);

this->ShowScrollBar(SB_VERT,TRUE);
}

Julien.
GeneralRe: Scrolling problems Pin
SinclairE3-Jul-01 6:57
SinclairE3-Jul-01 6:57 
GeneralGDI painting on top of all other's control Pin
30-Jun-01 3:21
suss30-Jun-01 3:21 
QuestionIs it Possible to do graphics in Console Window? Pin
Sangeetha30-Jun-01 1:54
Sangeetha30-Jun-01 1:54 
AnswerRe: Is it Possible to do graphics in Console Window? Pin
Hadi Rezaee30-Jun-01 6:57
Hadi Rezaee30-Jun-01 6:57 
GeneralRe: Is it Possible to do graphics in Console Window? Pin
Chris Losinger30-Jun-01 7:38
professionalChris Losinger30-Jun-01 7:38 
GeneralWTL and Splitters Pin
Alpesh30-Jun-01 0:53
Alpesh30-Jun-01 0:53 
GeneralProgrammatically sending mails Pin
Vikash Dubey30-Jun-01 0:17
Vikash Dubey30-Jun-01 0:17 
GeneralRe: Programmatically sending mails Pin
Alpesh30-Jun-01 0:57
Alpesh30-Jun-01 0:57 
GeneralRe: Programmatically sending mails Pin
NullStream30-Jun-01 21:52
NullStream30-Jun-01 21:52 
GeneralCStatusBar member function problem! Pin
Rickard Andersson2029-Jun-01 23:25
Rickard Andersson2029-Jun-01 23:25 
GeneralRe: CStatusBar member function problem! Pin
Michael Martin30-Jun-01 0:14
professionalMichael Martin30-Jun-01 0:14 
QuestionHow can I use LockWorkStation? Pin
29-Jun-01 22:28
suss29-Jun-01 22:28 
AnswerRe: How can I use LockWorkStation? Pin
29-Jun-01 23:28
suss29-Jun-01 23:28 
GeneralAn edit problem... Pin
29-Jun-01 23:31
suss29-Jun-01 23:31 
GeneralBut I am really stupid Pin
29-Jun-01 23:32
suss29-Jun-01 23:32 
GeneralAbout ActiveX Print! Pin
29-Jun-01 17:59
suss29-Jun-01 17:59 
GeneralRe: About ActiveX Print! Pin
Hadi Rezaee30-Jun-01 2:23
Hadi Rezaee30-Jun-01 2:23 

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.