Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a problem with scrollbars

Status
Not open for further replies.

dcgsmix

Programmer
Dec 20, 2001
35
IL
Hey, ppl!

how do i use scrollbars?

what i want is, say that i have 100 controls, arranged in a grid. but it takes all the screen if i'm using even 1280x1024 resolution. so i want to place one rectangle in a small dialog, that will show only 10 controls. and then i can scroll them.

go to the image URL that i uploaded to see an example:

Thanks a lot!!!
Daniel
 
OK, say your dialog can display three rows of controls at a time. You'd do this to calculate how many rows of controls there are (Adding one for the remainder if needed):
Code:
iNumRows = (iNumControls / 3) + ((0 == iNumControls % 3) ? 0 : 1);
You then set the scroll bar's max value to the number of rows minus the number displayed, with a minimum of 0:
Code:
iScrollMax = ((0 < iNumRows - 3) ? 0 : iNumRows - 3);

Whenever the user moves the scrollbar you use the scrollbar value as the starting row, and repaint controls starting from that position:
Code:
for (j = iStartRow; j < iStartRow + 3; j++) {
   for (i = 0; i < 3; i++) {
      RepaintAControl((j * 3) + i);
   }
}

Hope this helps.
Chip H.
 
Thanks,
But i already know what to, i just needed a help fast but then i discovered that myself.

Thanks anyway
Daniel Cohen Gindi
dcgsmix@gmx.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top