Archived

This topic is now archived and is closed to further replies.

savagerx

A scroll bar mystery

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
"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

Share this post


Link to post
Share on other sites
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;
}
}

Share this post


Link to post
Share on other sites