Re: Scrolling?



Hello Robby,

Try to override the WM_CTLCOLOR. Hopefully it should solve the problem.

Regards
Sanjeev

"Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:72084A36-FEB0-409B-93F1-8447D0C169FD@xxxxxxxxxxxxxxxx
Hi,

I have been doing extensive VC++ programming, however I find myself
learning
eVC++ where I find there are some slight differences.

If I want to scroll some text in my client area, I would do it one way
with
the traditional WM_VSCROLL to get the user's scroll bar clicking and then
scrolling the window down a line, followed by an UpdateWindow. And
thereafter, WM_PAINT would re-paint the lines required.

This worked fine. Meaning no flickering and was constantly erasing the
client area after every scroll so the next text would be re-drawn in a
clean
slate , sort of speak!

However I tried doing thids in eVC, and it doesn't quit work as well!
I replaced the following lines from VC++:
===================================================
ScrollWindow(hwnd,0,cyChar *(iCurentThumbPos - si.nPos),NULL,NULL);
UpdateWindow(hWnd);
===================================================

with the following eVC++ command:
===================================================
ScrollWindowEx(hWnd, 0, cyChar * (iVertPos - si.nPos),(CONST RECT *) NULL,
(CONST RECT *) NULL, (HRGN) NULL, (LPRECT) NULL,SW_INVALIDATE);

UpdateWindow(hWnd);
===================================================
However, somehow the client area doesn't fully erase the previous scrolled
text.

EXAMPLE: Suppose I had to display 3 text items in my screen... here is a
sample :

wordA
wordAB
wordABC

If I scroll up, we get:

wordAB
wordABC

right...!

So If I re-scroll back down I go back to:

wordAB //its like as if the old 'B' stayed there????
wordAB
wordABC

To get rid of this problem I have to put an InvalidateRect command in
WM_PAINT, however this causes an irritable flicker!

Here is the core portion of my code in eVC++:
===============================================
case WM_VSCROLL:

//Get scroll info
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
GetScrollInfo (hWnd,SB_VERT,&si);
// Save current position
iVertPos = si.nPos;

switch (LOWORD (wParam))
{
case SB_LINEUP:
si.nPos -= 1;
break;
case SB_LINEDOWN:
si.nPos += 1;
break;
default:
break;
}

si.fMask = SIF_POS;
SetScrollInfo(hWnd,SB_VERT,&si,TRUE);
GetScrollInfo(hWnd,SB_VERT,&si);

if(si.nPos != iVertPos)
{
ScrollWindowEx(hWnd, 0, cyChar * (iVertPos - si.nPos),(CONST RECT *) NULL,
(CONST RECT *) NULL, (HRGN) NULL, (LPRECT) NULL,SW_INVALIDATE);

UpdateWindow(hWnd);
}
return 0;

case WM_PAINT:
//InvalidateRect(hWnd,NULL,TRUE); //It works but creates a flicker!!!

hdc = BeginPaint (hWnd,&ps);

si.cbSize = sizeof(si);
si.fMask = SIF_POS;
GetScrollInfo (hWnd,SB_VERT,&si);

iVertPos = si.nPos;

iPaintBeg = max(0,iVertPos);
iPaintEnd = min(NUMLINES - 1,iVertPos + ps.rcPaint.bottom / cyChar);

for(i = iPaintBeg; i <= iPaintEnd;i++)
{
y = cyChar * (i - iVertPos);

ExtTextOut (hdc,0,y, ETO_CLIPPED, NULL,sysmetrics[i].szLabel,
lstrlen(sysmetrics[i].szLabel),NULL);

}
EndPaint (hWnd, &ps);
return 0;

===============================================

I don't know what else to try, does anyone see something wrong with this
setup?

I feel frustrated because the things I am used to doing in VC++, I sort of
can't do them anymore In eVC++. Its like I am slightly re-learning the
mechanics of the language.

Anyways, If anyone can help me with this, it would be very appreciated!

Thankyou for all sugestions and comments!

--
Best regards
Robert


.



Relevant Pages

  • Re: Scrolling?
    ... If I want to scroll some text in my client area, I would do it one way ... WM_PAINT would re-paint the lines required. ... However I tried doing thids in eVC, and it doesn't quit work as well! ... wordAB ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Scrolling?
    ... I think this handler has been replaced with seperate messages for each type ... You see, I am testing this in emulation mode, so I think that the flickering ... If I want to scroll some text in my client area, I would do it one way ... wordAB ...
    (microsoft.public.windowsce.embedded.vc)
  • Scrolling?
    ... eVC++ where I find there are some slight differences. ... the traditional WM_VSCROLL to get the user's scroll bar clicking and then ... However I tried doing thids in eVC, and it doesn't quit work as well! ... wordAB ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Scrolling?
    ... If I want to scroll some text in my client area, I would do it one way ... However I tried doing thids in eVC, and it doesn't quit work as well! ... wordAB ... if(si.nPos!= iVertPos) ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Scrolling?
    ... If I want to scroll some text in my client area, I would do it one way ... WM_PAINT would re-paint the lines required. ... However I tried doing thids in eVC, and it doesn't quit work as well! ... wordAB ...
    (microsoft.public.windowsce.embedded.vc)