Advertisement

A scroll bar mystery

Started by May 03, 2002 10:38 AM
3 comments, last by savagerx 22 years, 7 months ago
Hi, I''ve been trying to work with this scroll bar but it seems that it does not repaint properly ie. all I get are scrabbled letters. I have hereby attached my WM_PAINT for advice.
  
case WM_PAINT:
    si.cbSize = sizeof(si);
    si.fMask = SIF_POS;
    GetScrollInfo(hwnd,SB_VERT,&si);
    iVScrollPos = si.nPos;
    si.cbSize = sizeof(si);
    si.fMask = SIF_POS;
    GetScrollInfo(hwnd,SB_HORZ,&si);
    iHScrollPos = si.nPos;

    hdc = BeginPaint(hwnd,&ps);
    iPaintBeg = min(NUMLINES-1,iVScrollPos + 
                   (ps.rcPaint.top/icychar));
    iPaintEnd = max(0,iVScrollPos + (ps.rcPaint.bottom/icychar));

    for(i=iPaintBeg;i<=iPaintEnd;i++)
    {
	x = (icxchar * (1-iHScrollPos));
	y = (icychar * (i-iVScrollPos));
	TextOut(hdc,x,y,SYSMET2[i].szTag,
                lstrlen(SYSMET2[i].szTag));
	TextOut(hdc,(x+(icxcap*20)),y,SYSMET2[i].szDescription,
                    lstrlen(SYSMET2[i].szDescription));
	SetTextAlign(hdc,TA_TOP|TA_RIGHT);
	TextOut(hdc,(x+(icxcap*20)+(icxchar*40)),y,szBuffer,
                     wsprintf(szBuffer,"%5d",
                     GetSystemMetrics(SYSMET2[i].nIndex)));
	SetTextAlign(hdc,TA_TOP|TA_LEFT);
    }
    EndPaint(hwnd,&ps);
    return 0;
  
A thousand thanks in advance
The road may be long, wind may be rough. But with a will at heart, all shall begone. ~savage chant
???
Advertisement
rrrrriiigghtt.. (Dr. Evil voice )

---------------------------------------------------------------------------------------------------------------------------------------
"With my feet upon the ground I move myeslf between the sounds and open wide to suck it in, I feel it move across my skin. I''m reaching up and reaching out. I''m reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one''s been. We''ll ride the spiral to the end and may just go where no one''s been." - TOOL
---------------------------------------------------------------------------------------------------------------------------------------
[TheBlackJester]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

"Savagerx", do you make an effort to look for answers yourself @ MSDN? Even though this is a beginner section, it does not mean that you can get easy answers without breaking a sweat. Go work for it!

MSDN offers quite a number of valuable information for Windows Programming.


ANNOY
An explanation of what this code does, what your problem is, and some comments in the code will be really helpful.

I see that you declare all your local variables outside of switch. Do you know you can do the following:

  switch (...){    case 1:    {        int var = 2;        ...;        break;    }    case 2:    {        int yet_another_var = 3;        ...;        break;    }}  
---visit #directxdev on afternet <- not just for directx, despite the name

This topic is closed to new replies.

Advertisement