Click here to Skip to main content
16,006,348 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWorkspace idiocy Pin
Anonymous12-Nov-02 0:29
Anonymous12-Nov-02 0:29 
Generalcontrol box and menues Pin
emrosa12-Nov-02 0:26
emrosa12-Nov-02 0:26 
GeneralRe: control box and menues Pin
Maximilien12-Nov-02 2:41
Maximilien12-Nov-02 2:41 
GeneralCP code snippets reusing question Pin
pitch bender12-Nov-02 0:19
susspitch bender12-Nov-02 0:19 
GeneralRe: CP code snippets reusing question Pin
benjymous12-Nov-02 1:02
benjymous12-Nov-02 1:02 
GeneralHelp! about PreTranslateMessage in a COM DLL Pin
Simon.W11-Nov-02 23:52
Simon.W11-Nov-02 23:52 
GeneralRe: Help! about PreTranslateMessage in a COM DLL Pin
dabs12-Nov-02 2:20
dabs12-Nov-02 2:20 
GeneralScrollbar looses grip Pin
Daffy d.11-Nov-02 23:48
Daffy d.11-Nov-02 23:48 
Hi there!

I’m currently playing with a PICO scope. (it’s a small parallel port oscilloscope that runs at 20KHz max.)
I’m trying to make a custom graphical interface showing the results acquired from the scope (was hoping to use it in a dynamometer project I was planning) . This part of the deal runs great. But I wanted to add a horizontal scroll bar to make navigation trough the data easier. So l borrowed from Roger Allens tutorial. On scrollbars (http://www.codeproject.com/miscctrl/Scrollbar.asp) And everything works almost according to plan. Unfortunately I’m using a quite large data buffer. -16 KB to 512 KB. Ant that’s where things get strange. It seems that things behave quite normal when I’m below 32KB.
But as soon as I get above 32 KB the scrollbar position returns to 0 and starts counting over - When using “SB_THUMBTRACK” and “SB_THUMBPOSITION”
But behaves normal (counts and scrolls all the way up to 512KB) when using all the other “positioning” options (like SB_PAGE & SB_LINE)

The problem looks like the variable holding the bar position has a max of 32768 and than turns over to 0. (but only when dragging the bar) That would be a 16 bit signed variable. But the SCROLLINFO.nPos which I use is a int so that shouldn’t be the problem.

My code is as I said pulled more or less directly from Rogers tutorial and looks like this :

// m_datasize is the size of the collected data 16 KB to 512 KB.

int i_CurPos = GetScrollPos(SB_HORZ);
int iPrevPos = i_CurPos;

CRect myRect;

GetClientRect(&myRect);

switch(nSBCode)
{
case SB_LEFT: i_CurPos = 0;
break;

case SB_RIGHT: i_CurPos = GetDocument()->m_datasize;
break;

case SB_LINELEFT: i_CurPos = max(i_CurPos -6, 0);
break;

case SB_LINERIGHT: i_CurPos = min(i_CurPos + 6,(GetDocument()->m_datasize+
myRect.Width() - 110));
break;

case SB_PAGELEFT: i_CurPos = max(i_CurPos - myRect.Width(), 0);
break;

case SB_PAGERIGHT: i_CurPos = min(i_CurPos + myRect.Width(), (GetDocument()- \
>m_datasize + myRect.Width() - 110)); //- myRect.Width()-1));
break;

// The part that doesn’t work

case SB_THUMBTRACK:
case SB_THUMBPOSITION: i_CurPos = nPos ;
break;
// The part that doesn’t work

}
SetScrollPos(SB_HORZ, i_CurPos);
ScrollWindow(iPrevPos - i_CurPos, 0) ;

A bit messy but hopefully readable Wink | ;)
GeneralRe: Scrollbar looses grip Pin
Daffy d.11-Nov-02 23:57
Daffy d.11-Nov-02 23:57 
GeneralC#-dialog in a VC-Project Pin
deafpat11-Nov-02 23:47
deafpat11-Nov-02 23:47 
GeneralRandom Numbers Pin
Josus11-Nov-02 23:33
Josus11-Nov-02 23:33 
GeneralRe: Random Numbers Pin
tongc11-Nov-02 23:45
tongc11-Nov-02 23:45 
GeneralRe: Random Numbers Pin
Daffy d.12-Nov-02 0:15
Daffy d.12-Nov-02 0:15 
GeneralRe: Random Numbers Pin
Josus12-Nov-02 0:43
Josus12-Nov-02 0:43 
Questionhow to refresh the contents in a treeview? Pin
jack111-Nov-02 23:27
jack111-Nov-02 23:27 
AnswerRe: how to refresh the contents in a treeview? Pin
Paul Ingles11-Nov-02 23:35
Paul Ingles11-Nov-02 23:35 
Generalcode project search bar! How??/ Pin
tongc11-Nov-02 23:12
tongc11-Nov-02 23:12 
GeneralRe: code project search bar! How??/ Pin
Michael Dunn12-Nov-02 4:52
sitebuilderMichael Dunn12-Nov-02 4:52 
GeneralRe: code project search bar! How??/ Pin
tongc12-Nov-02 22:15
tongc12-Nov-02 22:15 
GeneralPutting a main Menu in a Dialog Box Pin
GurGur11-Nov-02 22:52
GurGur11-Nov-02 22:52 
GeneralRe: Putting a main Menu in a Dialog Box Pin
567890123412-Nov-02 4:13
567890123412-Nov-02 4:13 
GeneralRe: Putting a main Menu in a Dialog Box Pin
Nitron12-Nov-02 4:19
Nitron12-Nov-02 4:19 
GeneralRe: Putting a main Menu in a Dialog Box Pin
GurGur12-Nov-02 4:56
GurGur12-Nov-02 4:56 
GeneralRe: Putting a main Menu in a Dialog Box Pin
Nitron12-Nov-02 7:34
Nitron12-Nov-02 7:34 
General#import directive Pin
devvvy11-Nov-02 22:01
devvvy11-Nov-02 22:01 

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.