Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / A Question ABout The Scrollbar Commands In Blue GUI

Author
Message
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 13th Mar 2006 00:33
I couldn't find any examples that uses these commands anywhere under Blue GUI 2.0. I looked at the help files for syntax and usage for the scrollbar commands, but I still having trouble getting them to work the way I want.

Approach:

1. Get image file with openDialog() (.bmp, .jpg, .png, .tga)
2. Copy image to a canvas gadget (Cool function written by Freddix.)
3. Check canvas size XY against main window size
4. If canvas size is greater than mainWin, then create scrollbars accordingly. This is to move the unviewable portions of the canvas in the main windiw into view.

Problem #1 - is getting the current position of scrollbar thumb without releasing the mouse buttom.

Problem #2 - is getting the ScrollbarThumbSize set correctly. It should directly correlate to the difference between the main window size and the canvas size. I am not sure how to properly figure this.

It seems that the amount the of setScrollbarRange divides the max distance between the arrows where the scrollbar thumb can travel by the differences of the min/maz range values. Say, the range was between is 1 to 10, then there is ten equally divided portions for the scrollbar thumb to move to. If you move the thumb in the scrollbar slightly, it just snaps back to the current range value, unless you have move it far enough to get to the next range value.

I want to make the thumb be in accordance to the travel difference by pixel. Does that make sense? If there is a difference between the canvas size and the main window size of 50 pixels, then the scrollbar thumb size should be 50 pixel minus the max scroll range distance bewteen the arrows in the scrollbar. After this, I want the scroll bar thumb to move by pixel 50 pixels (values) either way to reflect how much to scroll the canvas in the main window. Is this possible?

Here is my source code:



The scrollbar is setup under the "openSingleFile()" function. The scrollbar values are retrieved in the "processEvents()" function.
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 15th Mar 2006 18:29
Nobody has an answer for this one?

Just in case my explaination was confusing:

I need to know how to get the scrollbar to return values without releasing the mouse button. (getSrollBarPosition)

I need an in depth explaination of how to setup the scrollbar thumb sizes and the range values for the scrollbar. (setScrollbarRange, and setScrollbarThumbSize). My program uses scrollbars to move the unviewable portions of the current canvas image in to view within the main window.
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 17th Mar 2006 18:06 Edited at: 18th Mar 2006 01:26
I guess I'll have to e-mail you on this one, Rob...

<EDIT>

I figured out my problem with the Scrollbar range and the thumb size after doing a little thinking and inspection of the code. It turns out that you need to make the program calculate the maximum range values as shown below.

X range = mainWidth+(canvasWidth-mainWidth)
X Thumb Size = mainWidth

if the X scrollbar wasn't created for scrolling the canvas width and the Y scrollbar needs to be made to scroll the height of the canvas, use:

Y scrollbar range = mainHeight+(canvasHeight-mainHeight)+20
Y Thumb Size = mainHeight

Else, if the X scrollbar was created along with the Y scrollbar, use:

Y range = mainHeight+gadgetHeight(sliderX)+(canvasHeight-mainHeight)+20
Y Thumb Size = mainHeight

Then resize the X scrollbar minus the width of the Y scrollbar and then use this formula for the scroll range for the X scrollbar:

X range = mainWidth+gadgetWidth(sliderY)+(canvasWidth-mainWidth)
X Thumb Size = mainWidth

For those of you that are curious on how to set this up, I supplied the code modifications from my previous post here as a code snippet.

The +20 part of the Y scroll range is to make up for the status bar at the bottom of the main window created. It appears that you can't return a height with gadgetHeight() for the status bar for some reason, so I used a constant value here. You can ommit this, if you're not using a status bar in the main window.



I'm still having trouble figuring out a way of returning the current position of the scrollbar without releasing the mouse button with getScrollBarPosition. I don't know if this is an issue with Blue GUI or not. If someone has a solution to it, I would appreciate the input. The code to that part is in my original post (ProcessEvents()).

Thanks,
D Ogre
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 25th Mar 2006 05:31
Sometimes you can't always see the forest through the trees... This is the case with doing this project requiring the use of the scrollbar commands. In my case, I was just over thinking the problem.

You can simplify the code by simply setting the scrollbar range with just the canvas width and/or height. Then use the main menu width and height for the thumb size, if the either the canvas width or height has to be scrolled. If both are created together for scrolling, you still have to add the other scrollbar gadget width or height depending on what gadget we are talking about ot the thumbbar size.

I guess I answered my own question here.

Duh! Right?
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 6th Apr 2006 01:06 Edited at: 6th Apr 2006 01:07
I still want to know if you can get the current scroll bar position without releasing the mouse button when you move the tumb bar. If anyone knows a way to do this, please post it here! I am assuming that it might just be the way Blue GUI 2.0 handles getting the new values from the the ScrollbarPosition command. Not sure if there really is a work around for this. What's up with this, Rob K?

Thanks Again,
D Ogre
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 6th Apr 2006 01:43 Edited at: 6th Apr 2006 01:43
I don't own BlueGui but from what I remember while writing a WinGui library for PlayBasic: when you click on the thumb of a scrollbar, Windows runs a modal loop- similar to what happens when you open a menu or resize a window. That means that the main thread pauses while you move the thumb. So without callbacks/hooks etc. (which are not possible in DBpro) you can't get the position in "realtime".

Rob K
Retired Moderator
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 8th Apr 2006 04:11
Hi D Ogre,

I don't get the chance to check the TGC forums as much as I used to at the moment. If you need help on a BlueGUI-related issue it is best to email me - [email protected]

Regarding getting the scrollbar position in real time, this is tricky for the reason empty mentioned. When you begin scrolling Windows jumps into a loop which continues until the scrollbar is released. This means that your DBPro code is effectively "suspended" from executing until the scroll bar is released.

This can be somewhat frustrating, but an alternative option is to provide buttons instead of scrollbars that adjust the position of the canvas when depressed.

Regards,
Robert.


BlueGUI Windows Plugin
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 11th Apr 2006 19:22
Okay, Thanks for the input guys. That's kind of what I figured to be the case. I guess it's no big deal, but it would be nice to get the position in real time.

Login to post a reply

Server time is: 2025-05-19 19:27:48
Your offset time is: 2025-05-19 19:27:48