# scrolling dialogs

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

## Recommended Posts

Hello everyone,

I'm trying to create a scrolling dialog containing some bitmaps that you can pick one of them, but im not pretty sure how to do it properly

first off, how to initiate the scrolling dialog? i've got some code from msdn but i couldnt fully understand it, so this is my current code

LRESULT CALLBACK BrowserProc ( HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam ){	RECT rc;	GetClientRect ( wnd, &rc );	SCROLLINFO si;	// Set the vertical scrolling range and page size	si.cbSize = sizeof si; 	si.fMask  = SIF_RANGE | SIF_PAGE | SIF_TRACKPOS; 	si.nMin   = 0;	si.nMax   = ((editor->GetNumImages ( ) + editor->GetNumObjects ( ))/3)*64 > rc.bottom-rc.top ?				((editor->GetNumImages ( ) + editor->GetNumObjects ( ))/3) : 0;	si.nPage  = 1;	static int yPos = 0;	switch ( msg )	{		case WM_SIZE:			SetScrollInfo ( wnd, SB_VERT, &si, TRUE );			break;		case WM_VSCROLL:			// Get all the vertial scroll bar information.			si.cbSize = sizeof si;			si.fMask  = SIF_ALL;			GetScrollInfo ( wnd, SB_VERT, &si );			// Save the position for comparison later on.			yPos = si.nPos;			si.nPos = si.nTrackPos;			// Set the position and then retrieve it.  Due to adjustments			// by Windows it may not be the same as the value set.			si.fMask = SIF_POS;			SetScrollInfo ( wnd, SB_VERT, &si, TRUE );			GetScrollInfo ( wnd, SB_VERT, &si );			// If the position has changed, scroll window and update it.			if ( si.nPos != yPos )			{                    				ScrollWindow ( wnd, 0, 10 * (yPos - si.nPos), NULL, NULL );				InvalidateRect ( wnd, NULL, FALSE );				UpdateWindow ( wnd );			}			return 0;		case WM_PAINT:		{			editor->PaintBrowser ( wnd );			break;		}		default:			return FALSE;	}	return TRUE;}

the main problem is the SCROLLINFO structure, or lets say SCROLLINFO::nPage / SCROLLINFO::nMax, i dont know how to use them, msdn says:

Quote:
 nMax int Specifies the maximum scrolling position. nPage UINT Specifies the page size, in device units. A scroll bar uses this value to determine the appropriate size of the proportional scroll box.

device units are not pixels, are they? if not, what are they then?

my second question is, after having the scroll bar, everything in the window scrolls automatically or i have to set the image positions to fit the new scrolling position?

and my final question is, lets say i want to pick one of the images, how do i do this? if the dialog was not scrollable, i could have just checked the mouse position and picked whatever is lying in that place, but it's different with scrolling dialogs, as the positions are not known for me

##### Share on other sites
Any particular reason not to just use a ListView control?

##### Share on other sites
can you add images to a list view? could you show me the way?

EDIT: Ah i was mixing between list views and list boxes, thanks for mentioning this !

[Edited by - Hassanbasil on July 11, 2010 11:58:20 AM]

• 17
• 11
• 12
• 9
• 49
• ### Forum Statistics

• Total Topics
631395
• Total Posts
2999758
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!