News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Scrolling window

Started by Jimg, March 18, 2005, 07:08:38 PM

Previous topic - Next topic

Jimg

I'm working on a program that will add controls to a dialog as main window as needed.  I'm resizing the dialog as the controls are added, up to the maximum size that will fit on the screen.  If I add too many controls for the dialog to fit on the screen, is there some setting that will cause the dialog that is not maximized to add a scroll bar automatically for the user to use or do I have to handle all the scrolling myself?  Just addiing WS_VSCROLL to the dialog doesn't seem to do it.  If I have to handle it myself, how does one scroll a dialog window?  Move all the controls? ScrollWindowEx?  I can probaly brute-force this thing out but I hate to do something dumb when there is a simpler way.

Manos

#1
You have to handle the WM_VSCROLL and WM_HSCROLL and use ScrollWindow or ScrollWindowEx API,
with lpRect =NULL and lpClipRect =NULL.
Only when  lpRect =NULL ,all childs windows are offset by the amount specified by the XAmount and YAmount parameters.
Also you have to add Scrollbar controls or standard Scrollbars.

Manos.

Jimg

Thank you Manos.  I figured it wouldn't be as simple as a style setting :wink

Manos

Send me your .exe and I 'll try to send you an example.

Manos.

Jimg

Thanks again Manos.   I think I can do this with the information you have given me already.  I just wanted to make sure I wasn't spending hours coding stuff the hard way if there was a simple way available.  This is just a silly program to test different code to see which runs the fastest.  I changed it so it would add the test buttons and result boxes automatically when another test proc was added and I just wanted to take care of the situation of when I added so many tests it wouldn't fit on the screen any longer.  I'd be happy to post the code if you want, but it's really pretty simple stuff.
-Jim

Jimg

After playing with this awhile, it seems that ScrollWindow is not the thing to use.  It only moves the bitmap of the window, not the actual controls.  So I have to move the controls themselves, which make the ScrollWindow unnecessary.  Am I missing something else here?  Would it be better to make a child window containing all the controls and just move it around inside the main dialog?

Manos

Hi Jimg.

You have to set  lpRect =NULL and lpClipRect =NULL in ScrollWindow.
Only when  lpRect =NULL childs windows are offset.
I 'll try to send you an simple example today.

Manos.

Manos

Jimg,

I sent you the follow example.I have program vertical scrolling only,
but the horzondal is the same.

Manos.


[attachment deleted by admin]

Jimg

Excellent Manos, Thank you very much.
-Jim

Jimg

After working on this for over a week (with a short break to struggle with invoke), I've created an example for myself of scrolling a dialog in a window.   I'm going to call the main window the parent, and the scrollable dialog the child, even though I'm not sure this is how the relationship is normally used.

Currently, there is only vertical scrolling, horizontal is next.

If the parent window is resized by the user, the program will automatically resize, position, and scroll the child dialog as needed.  The parent will also keep it's bottom header in the correct relative position.  Much more difficult that I thought it would be.  There seems to be a great deal more code than should be required to keep things lined up properly.

Any suggestions on how to do this in a better way will be greatly appreciated.


[attachment deleted by admin]

Manos

Hi Jimg.

It is good,but why you decrease the NewWidth by 10 ?
When use system Scrolbars,Windows fend for the size.
Also,in my opinion,is better if you set WS_EX_CLIENTEDGE style for the child window.
Have a look in follow attachement:

Regards,
Manos.



[attachment deleted by admin]

Jimg

Quotewhy you decrease the NewWidth by 10 ?
oops.  That was an aborted start at doing horizontal scrolling.

Jimg

Quote
Quotewhy you decrease the NewWidth by 10 ?
oops.  That was an aborted start at doing horizontal scrolling.
Actually the comment was wrong.  It was just to balance out the left side which started at 11.