Jump to content

Scrollable GUI's


GaryFrost
 Share

Recommended Posts

Hello! I'm trying to remove the "$nFileMenu = GUICtrlCreateMenu("File")" tag from the GUI, but when i do so, it renders the scroll bar usless. any suggestions?

#include <GUIConstants.au3>
#include <GUIScrollBars.au3>

Global $m_width = 600, $m_height = 600

_Main()

Func _Main()
    Local $nFileMenu, $nExititem, $GUIMsg, $hGUI, $h_cGUI, $h_cGUI2
    Local $listview, $button, $button2

    GUIRegisterMsg($WM_CREATE, "MY_WM_CREATE")
    GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")

    $hGUI = GUICreate("My GUI", 330, 390, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))
    GUISetBkColor(0x88AABB)
    
    ;$nFileMenu = GUICtrlCreateMenu("File")
    
    $Label2 = GUICtrlCreateLabel("ALabel2", 168, 600, 43, 17)
    $Label1 = GUICtrlCreateLabel("ALabel1", 104, 56, 43, 17)

    _SetScrollRange($hGUI, $SB_VERT, 0, 400)
    _SetScrollRange($hGUI, $SB_HORZ, 0, 400)
    
    GUISwitch($hGUI)
    
    GUIRegisterMsg($WM_VSCROLL, "MY_WM_VSCROLL")
    GUIRegisterMsg($WM_HSCROLL, "MY_WM_HSCROLL")
    
    GUISetState(@SW_SHOW, $hGUI)
   
    While 1
        $GUIMsg = GUIGetMsg()

        Switch $GUIMsg
            Case $GUI_EVENT_CLOSE;, $nExititem
                ExitLoop
        EndSwitch
    WEnd
    
    Exit
EndFunc
Add the _SetScrollRange calls to set the horizontal and vertical ranges of the scrollbars and it will work.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • 2 months later...
  • Replies 65
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Updated code, little more versatile.

Removed the need for creating global variables for width and height.

No longer use Event on Create, use _GUIScrollBars_Init after creating gui.

Renamed the functions more to UDF style naming convention.

Need 3.2.9.4 or higher

Edited by GaryFrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hey Gary,

your zip demo doesn't show anything, no errors but exits

+>10:36:33 AU3Check ended.rc:0
>Running:(3.2.9.5):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Documents and Settings\ROBERT M\Desktop\GuiScrollbars\Scrollbars_Test.au3"    
!===========================================================
+===========================================================
-->index: 0
+===========================================================
!===========================================================
+===========================================================
-->$xChar: 7
+===========================================================
!===========================================================
+===========================================================
-->$xUpper: 10.5
+===========================================================
!===========================================================
+===========================================================
-->$yChar: 16
+===========================================================
!===========================================================
+===========================================================
-->$xClientMax: 
+===========================================================
+>10:36:38 AutoIT3.exe ended.rc:0
+>10:36:39 AutoIt3Wrapper Finished
>Exit code: 0    Time: 6.983

beta 3.2.9.5

thanks

8)

NEWHeader1.png

Link to comment
Share on other sites

Hey Gary,

your zip demo doesn't show anything, no errors but exits

+>10:36:33 AU3Check ended.rc:0
>Running:(3.2.9.5):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Documents and Settings\ROBERT M\Desktop\GuiScrollbars\Scrollbars_Test.au3"    
!===========================================================
+===========================================================
-->index: 0
+===========================================================
!===========================================================
+===========================================================
-->$xChar: 7
+===========================================================
!===========================================================
+===========================================================
-->$xUpper: 10.5
+===========================================================
!===========================================================
+===========================================================
-->$yChar: 16
+===========================================================
!===========================================================
+===========================================================
-->$xClientMax: 
+===========================================================
+>10:36:38 AutoIT3.exe ended.rc:0
+>10:36:39 AutoIt3Wrapper Finished
>Exit code: 0    Time: 6.983

beta 3.2.9.5

thanks

8)

3.2.9.5 and above I believe there is a bug in the registered events, I did find a few other little bugs, worked them out, just don't use the wm_size event and the show function afterwards, silently bombs it.

Updated the file.

Gary

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

thx

8)

Looks like they fixed the crash problem, was an internal bug with DllCall, now works as it should with 3.2.9.10

Updated the example, can use both WM_SIZE event and _GUIScrollBars_Show at same time.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Looks like they fixed the crash problem, was an internal bug with DllCall, now works as it should with 3.2.9.10

Updated the example, can use both WM_SIZE event and _GUIScrollBars_Show at same time.

At last!

I've been trying this example regularly and it has never worked correctly for me until this latest version, and using 3.2.9.10.

But now it's working fine. :P

Thanks Gary and the other devs.

Edited by GaryFrost
Correct name
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 2 weeks later...

At last!

I've been trying this example regularly and it has never worked correctly for me until this latest version, and using 3.2.9.10.

But now it's working fine. :P

Thanks Gary and the other devs.

I spoke too soon. Various problems. But here a fix for one of them

If the gui is resized when a scroll bar is not at zero then the components are drawn shifted out of position untill the gui is resized again with the scroll bar at zero. A small addition of 2 lines as follows fixes it. There might be a better solution.

Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $wParam

    _GUIScrollBars_SetPos($hWnd,$SB_VERT, 0);<---------------added
    _GUIScrollBars_SetPos($hWnd,$SB_HORZ, 0);<---------------added

    Local $index = -1, $m_height, $m_width, $c_top, $c_height, $yChar, $xChar, $xClientMax, $xClient, $yClient
    Local $ivMax, $aRet
    For $x = 0 To UBound($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[...............
.
.
.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi,

I use your script with the scrollable GUI

But it don`t work.

#include<GUIConstants.au3>
#include<GUIScrollBars.au3>
AutoitSetOption("GUIResizeMode",802); bei Größenänderung der GUI, bleiben die Elemente unverändert 

$Form1 = GUICreate("Form1", 930, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
_GUIScrollBars_Init ($Form1)
GUIRegisterMsg($WM_VSCROLL, "MY_WM_VSCROLL")
GUIRegisterMsg($WM_HSCROLL, "MY_WM_HSCROLL")
GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")
$Label1 = GUICtrlCreateLabel("Label1", 32, 32, 36, 17) 
$Input1 = GUICtrlCreateInput("Input1", 900, 870, 30, 30) 
GUISetState(@SW_SHOW) 

While 1 
 $nMsg = GUIGetMsg() 
 Switch $nMsg 
  Case $GUI_EVENT_CLOSE 
   Exit 
 EndSwitch 
WEnd

Make the GUI bigger and smaller and than you will see what I mean.

Please help me, thanks

Link to comment
Share on other sites

Hi,

I use your script with the scrollable GUI

But it don`t work.

#include<GUIConstants.au3>
#include<GUIScrollBars.au3>
AutoitSetOption("GUIResizeMode",802); bei Größenänderung der GUI, bleiben die Elemente unverändert 

$Form1 = GUICreate("Form1", 930, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
_GUIScrollBars_Init ($Form1)
GUIRegisterMsg($WM_VSCROLL, "MY_WM_VSCROLL")
GUIRegisterMsg($WM_HSCROLL, "MY_WM_HSCROLL")
GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")
$Label1 = GUICtrlCreateLabel("Label1", 32, 32, 36, 17) 
$Input1 = GUICtrlCreateInput("Input1", 900, 870, 30, 30) 
GUISetState(@SW_SHOW) 

While 1 
 $nMsg = GUIGetMsg() 
 Switch $nMsg 
  Case $GUI_EVENT_CLOSE 
   Exit 
 EndSwitch 
WEnd

Make the GUI bigger and smaller and than you will see what I mean.

Please help me, thanks

Use this for the init

_GUIScrollBars_Init ($Form1,-1,60)

On my PC I need to resize the Gui before the scrollbars ajust to the correct sizes. I've tried various ways to fix this but so far the only success I've had is to resize the gui after it's shown using Winmove. So I start with the GUi 1 pixel wider than I want it then resize it down 1 pixel.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi,

now it works better but not best.

The vertical scroll works, but the horizontal scroll not

#include<GUIConstants.au3>
#include<GUIScrollBars.au3>
AutoitSetOption("GUIResizeMode",802); bei Größenänderung der GUI, bleiben die Elemente unverändert 

$Form1 = GUICreate("Form1", 930, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
WinMove("Form1", "", -1, -1, 931, 901)
_GUIScrollBars_Init ($Form1, -1, 60)
GUIRegisterMsg($WM_VSCROLL, "MY_WM_VSCROLL")
GUIRegisterMsg($WM_HSCROLL, "MY_WM_HSCROLL")
GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")

$Label1 = GUICtrlCreateLabel("Label1", 32, 32, 36, 17) 
$Input1 = GUICtrlCreateInput("Input1", 900, 870, 30, 30) 
GUISetState(@SW_SHOW) 

While 1 
    $nMsg = GUIGetMsg() 
    Switch $nMsg 
      Case $GUI_EVENT_CLOSE 
        Exit 
    EndSwitch 
WEnd
Link to comment
Share on other sites

Hi,

now it works better but not best.

The vertical scroll works, but the horizontal scroll not

#include<GUIConstants.au3>
#include<GUIScrollBars.au3>
AutoitSetOption("GUIResizeMode",802); bei Größenänderung der GUI, bleiben die Elemente unverändert 

$Form1 = GUICreate("Form1", 930, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
WinMove("Form1", "", -1, -1, 931, 901)
_GUIScrollBars_Init ($Form1, -1, 60)
GUIRegisterMsg($WM_VSCROLL, "MY_WM_VSCROLL")
GUIRegisterMsg($WM_HSCROLL, "MY_WM_HSCROLL")
GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")

$Label1 = GUICtrlCreateLabel("Label1", 32, 32, 36, 17) 
$Input1 = GUICtrlCreateInput("Input1", 900, 870, 30, 30) 
GUISetState(@SW_SHOW) 

While 1 
    $nMsg = GUIGetMsg() 
    Switch $nMsg 
      Case $GUI_EVENT_CLOSE 
        Exit 
    EndSwitch 
WEnd
If you resize the window small enough you will see the horizontal scroll bar appear. The default of -1 set the width to be scrolled to a bit more than 60 character widths. Just add some value like this

_GUIScrollBars_Init ($Form1, 930, 60)

The values 930,60 are the sizes of the width and height of the window to be scrolled in pixels for the width and character heights or line spacing for the vertical bar.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

As far as getting the appropriate numbers for the scroll range, here's what I've found works (by trying logical attempt after logical attempt until something seemed to work):

Note that I'm using EN-US Vista, with normal DPI and default mouse settings (I don't know what all effects this equation). Also, I've only tried this on vertical scrollbars, it could be that horizontal scroll bars use a different equation.

Assume that:

$pixels is the number of the bottom pixel you want to be able to scroll to

$GUIheight is the height of the GUI with the scrollbars, in pixels (so if you defined the GUI as GUICreate("scrollable",640,480), $GUIheight would equal 480.

local $range=($pixels-$GUIheight)/15
If $range<0 Then $range=0oÝ÷ Ù8^*.q©ìzÛaz¶§éb殶­seôuT67&öÆÄ&'5õ6WE&ævRb33c´×uTÂb33cµ4%õdU%BÃÂb33c·&ævR

In english, you're calculating the number of 'stops' the scrollbar needs to make (at 15 pixels each) to get to the pixel you want, minus the number of pixels already visible. This worked for me with $pixels being defined from 150 to around 2000, pretty reliably. Since this is all trial-and-error, it could be that I'm off a bit, or that 15 isn't a constant (hopefully that's a number you could pull from the registry if it isn't a constant).

Hope this helps!

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

As far as getting the appropriate numbers for the scroll range, here's what I've found works (by trying logical attempt after logical attempt until something seemed to work):

.

.

.

In english, you're calculating the number of 'stops' the scrollbar needs to make (at 15 pixels each) to get to the pixel you want, minus the number of pixels already visible. This worked for me with $pixels being defined from 150 to around 2000, pretty reliably. Since this is all trial-and-error, it could be that I'm off a bit, or that 15 isn't a constant (hopefully that's a number you could pull from the registry if it isn't a constant).

Hope this helps!

In the function _GUIScrollBars_Init the value of $ychar is used for the height unit. On my PC with the default font that is 16. However, the range is used as the number of lines for the character height, so if the font changes I assume your calculations would be wrong. In this case it would be better to determine the correct value using the same method used in _GUIScrollBars_Init.

My preference would be to have an extra parameter in the udf functions to specify whether the range is in pixels or character heights.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

In the function _GUIScrollBars_Init the value of $ychar is used for the height unit. On my PC with the default font that is 16. However, the range is used as the number of lines for the character height, so if the font changes I assume your calculations would be wrong. In this case it would be better to determine the correct value using the same method used in _GUIScrollBars_Init.

My preference would be to have an extra parameter in the udf functions to specify whether the range is in pixels or character heights.

Good catch there. However, my machine tells me that $yChar is 16 as well, but when I change $yChar to a Global variable and use it instead of 15 in my equation, it doesn't let me scroll as far as I need to get to the pixel I want. Also, I tried a script I've been working on, on a computer with 120 DPI and all system fonts set to 12 instead of default 9, and 15 still appeared to be the correct number. So maybe $yChar isn't the number we need to be working from after all. I don't know. For now I'm going to continue using my equation, assuming that 15 is a constant, but if I find something that appears more logical, I'll let you know. If you find a different equation, be sure to post it too! :-D

P.S. I agree, it'd be nice to have that extra parameter, but we've got to understand how to get the correct number of pixels to character heights (if that's what the current units actually are) before anyone could add that conversion into the UDF, especially since Gary (who wrote this UDF, as far as I can tell) has been asking for people to help figure this out from the beginning...I don't think he knows how to get it in there yet, either.

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

  • 1 month later...
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...