Jump to content
  • Advertisement
Sign in to follow this  
GuitarPlayer0912

Scrollbars don't do anything

This topic is 4360 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a level editor in c++ for my new 2d tile-based RPG. I've gotten to the part where I'm testing my child windows (one displays the map, the other displays the selectable tiles) by drawing bitmaps on them. I've added a vertical scrollbar to the tile selector window, and a horizontal and vertical one to the map viewer window. I thought that whenever the tiles being drawn rendered past the window boundaries, the scrollbar would let me view the bitmaps that went off. The scrollbars do nothing though. They are there but when I click and drag them, they snap back to their original spot and the window stays where it was. Here's an example.
// Tile selector window client area is 600 pixels high

void fnTileWndPaint(HDC hDC){ // Sandwiched between BeginPaint() and EndPaint()
  RECT rc;
  int xPos, yPos;

  GetClientRect(hTileWnd, &rc);
  xPos = (rc.right / 2) - 16; // centers the tiles (32 x 32)
  yPos = 16; // looks like a good spot to start the tiles off at
  
  for(int i = 0; i < 25; i++){ // for testing purposes
    pBitmap[0]->fnDraw(hDC, xPos, yPos); // Don't worry, this function works. It's part of my cBitmap class. It just draws the bitmap to a Device context and then to an x y position
    yPos += 64; // Just moves the next tile down
  }
}

I want the scrollbar to let me see the rest of the 15 freakin tiles I drew. I don't know how to make the scrollbar let me scroll past the boundaries of the window. Please help!

Share this post


Link to post
Share on other sites
Advertisement
Scrollbars aren't magic, you need to actually handle scrollbar events and set them up properly to do whatever you want to do with them.

Scrollbar reference on MSDN.

The basics are that you need to handle WM_VSCROLL and/or WM_HSCROLL to detect when the scrollbars have moved, use SetScrollInfo to set thier new values, and repaint taking into account the position of the scrollbar.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!