Jump to content

scrollbar not showing full contents of gui


Recommended Posts

if the values of the ini exceed a certain number and hte icons "fall out of the space allocated"

i did extend the size of $maxY = to 1000. but i think theres a limit set.

is there a way to set it to unlimited to allow the user to enter as many icons as theyd like

also is there a way to disable the horizontal bar?

#include <GUIConstantsEx.au3>

#include <ComboConstants.au3>

#include <ButtonConstants.au3>

Opt("GUIOnEventMode", 1)

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <StructureConstants.au3>

#include <GUIScrollBars.au3>

#include <ScrollBarConstants.au3>

Global $toolsdir, $filemenu, $filemenuopenitem, $filemenuexititem, $helpmenu, $changeitem, $helpitem, $contextmenu, $iplist, $dGUI

$toolsdir="C:\CRS\Tools"

If Not FileExists($toolsdir) Then

DirCreate($toolsdir)

EndIf

If Not FileExists($toolsdir & "\Dashboard") Then

DirCreate($toolsdir & "\Dashboard")

EndIf

Global $Ini = $toolsdir & "\Dashboard\settings.ini"

If Not FileExists($Ini) Then

MsgBox(262144, "Dashboard", "Settings.ini is missing. A generic one has been created for you.")

IniWrite($Ini, "LOCATIONS", "CRMC","CRMC_ASSETS")

IniWrite($Ini, "LOCATIONS", "GIG","GIG_ASSETS")

IniWrite($Ini, "LOCATIONS", "DR","DR_ASSETS")

_FileWriteToLine($Ini, 5, "", 0)

IniWrite($Ini, "CRMC_ASSETS", "ANDS_ETP","D0090774")

_FileWriteToLine($Ini, 9, "", 0)

IniWrite($Ini, "GIG_ASSETS", "ANDS_ESR","D0090775")

_FileWriteToLine($Ini, 13, "", 0)

IniWrite($Ini, "DR_ASSETS", "DLG_ETP","D0049852")

ShellExecute($Ini)

EndIf

$dGUI=GUICreate("Dashboard v0.1", 520, 430)

GUISetBkColor (0xffffff)

GUIRegisterMsg($WM_SIZE, "WM_SIZE")

GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")

_GUIScrollBars_Init($dGUI)

Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)

#forceref $Msg, $wParam

Local $index = -1, $yChar, $xChar, $xClientMax, $xClient, $yClient, $ivMax

For $x = 0 To UBound($aSB_WindowInfo) - 1

If $aSB_WindowInfo[$x][0] = $hWnd Then

$index = $x

$xClientMax = $aSB_WindowInfo[$index][1]

$xChar = $aSB_WindowInfo[$index][2]

$yChar = $aSB_WindowInfo[$index][3]

$ivMax = $aSB_WindowInfo[$index][7]

ExitLoop

EndIf

Next

If $index = -1 Then Return 0

Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

; Retrieve the dimensions of the client area.

$xClient = BitAND($lParam, 0x0000FFFF)

$yClient = BitShift($lParam, 16)

$aSB_WindowInfo[$index][4] = $xClient

$aSB_WindowInfo[$index][5] = $yClient

; Set the vertical scrolling range and page size

DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))

DllStructSetData($tSCROLLINFO, "nMin", 0)

DllStructSetData($tSCROLLINFO, "nMax", $ivMax)

DllStructSetData($tSCROLLINFO, "nPage", $yClient / $yChar)

_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

Return $GUI_RUNDEFMSG

EndFunc ;==>WM_SIZE

Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)

#forceref $Msg, $wParam, $lParam

Local $nScrollCode = BitAND($wParam, 0x0000FFFF)

Local $index = -1, $yChar, $yPos

Local $Min, $Max, $Page, $Pos, $TrackPos

For $x = 0 To UBound($aSB_WindowInfo) - 1

If $aSB_WindowInfo[$x][0] = $hWnd Then

$index = $x

$yChar = $aSB_WindowInfo[$index][3]

ExitLoop

EndIf

Next

If $index = -1 Then Return 0

; Get all the vertial scroll bar information

Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)

$Min = DllStructGetData($tSCROLLINFO, "nMin")

$Max = DllStructGetData($tSCROLLINFO, "nMax")

$Page = DllStructGetData($tSCROLLINFO, "nPage")

; Save the position for comparison later on

$yPos = DllStructGetData($tSCROLLINFO, "nPos")

$Pos = $yPos

$TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

Switch $nScrollCode

Case $SB_TOP ; user clicked the HOME keyboard key

DllStructSetData($tSCROLLINFO, "nPos", $Min)

Case $SB_BOTTOM ; user clicked the END keyboard key

DllStructSetData($tSCROLLINFO, "nPos", $Max)

Case $SB_LINEUP ; user clicked the top arrow

DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)

Case $SB_LINEDOWN ; user clicked the bottom arrow

DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)

Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box

DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)

Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box

DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)

Case $SB_THUMBTRACK ; user dragged the scroll box

DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)

EndSwitch

;~ // Set the position and then retrieve it. Due to adjustments

;~ // by Windows it may not be the same as the value set.

DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)

_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

_GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

;// If the position has changed, scroll the window and update it

$Pos = DllStructGetData($tSCROLLINFO, "nPos")

If ($Pos <> $yPos) Then

_GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))

$yPos = $Pos

EndIf

Return $GUI_RUNDEFMSG

EndFunc ;==>WM_VSCROLL

$filemenu = GUICtrlCreateMenu("&File")

$fileopenitem = GUICtrlCreateMenuItem("Edit Asset List", $filemenu)

GUICtrlSetOnEvent(-1,"EditINI")

$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)

GUICtrlSetOnEvent(-1,"Xbutton")

$helpmenu = GUICtrlCreateMenu ("&Help")

$changeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)

GUICtrlSetOnEvent(-1,"Change")

$helpitem = GUICtrlCreateMenuitem ("About",$helpmenu)

GUICtrlSetOnEvent(-1,"About")

$contextmenu = GUICtrlCreateContextMenu ()

$combo = GUICtrlCreateCombo("Select Location...", 290, 5, 200, 20, $CBS_DROPDOWNLIST)

GUICtrlSetData(-1, LoadCombo(), "Location...")

Func LoadCombo()

Local $arr = IniReadSection($Ini, "LOCATIONS"), $Local

If Not @error Then

For $i = 1 To $arr[0][0]

$Local &= $arr[$i][0] & "|"

Next

Return StringTrimRight($Local, 1)

EndIf

Return "No assets loaded"

EndFunc ;==>LoadCombo

$ButHeight = 40

$ButWid = 40

$horPitch = $ButWid + 45

$horPitch = $ButWid + 45

$VertPItch = $ButHeight + 30

$maxX = 470;depends on your window size or whatever

$maxY = 9000;ditto

$startX = 5

$StartY = 0

$ButCount = 0;no buttons yet

$ButHor = 6

$ButVert = 0

Func CreateIcons()

Global $iplist[20]

$LOCS = IniReadSection($ini, "LOCATIONS")

For $i = 1 To $LOCS[0][0]

$PC_Btns = IniReadSection($ini, $LOCS[$i][1])

For $x = 1 To $PC_Btns[0][0]

$ButCount += 1

$ButHor += 1

If $ButHor * $horPitch + $ButWid + $startX > $maxX Then

$ButHor = 0

$ButVert += 1

If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more

EndIf

$buttemp=GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON)

GUICtrlSetImage(-1, "shell32.dll", 16)

GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + $ButHeight + 6)

GUICtrlSetOnEvent($buttemp, "UNC")

If UBound($iplist) < $buttemp Then ReDim $iplist[$buttemp + 5]

$iplist[$buttemp] = $PC_Btns[$x][1]

$Btn_context = GUICtrlCreateContextMenu($buttemp)

$Btn_context_item = GUICtrlCreateMenuItem("Take Remote Screenshot", $Btn_context)

GUICtrlSetOnEvent(-1,"About")

$Btn_context_item = GUICtrlCreateMenuItem("Manage", $Btn_context)

GUICtrlSetOnEvent(-1,"Manage")

$Btn_context_item = GUICtrlCreateMenuItem("Netsupport", $Btn_context)

GUICtrlSetOnEvent(-1,"Xbutton")

$Checkers_menu = GUICtrlCreateMenu("Checkers", $Btn_context)

$Checkers_menu_item = GUICtrlCreateMenuItem("Bloomberg Info", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Reuters Info", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Active Processes", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Encryption Status", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Uptime", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Security", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu = GUICtrlCreateMenu("Get Logs", $Btn_context)

$get_menu_item = GUICtrlCreateMenuItem("ETP", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu_item = GUICtrlCreateMenuItem("Channel", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu_item = GUICtrlCreateMenuItem("Liquidnet", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu_item = GUICtrlCreateMenuItem("LAVA", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu_item = GUICtrlCreateMenuItem("Pipeline", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

Next

Next

EndFunc ;==>CreateIcons

CreateIcons()

;========== begin window context menu =============

$file_window_context_menu = GUICtrlCreateMenu("File",$contextmenu)

$file_window_context_menu_item = GUICtrlCreateMenuItem("Edit Asset List", $file_window_context_menu)

GUICtrlSetOnEvent(-1,"EditINI")

$file_window_context_menu_item = GUICtrlCreateMenuItem("Exit", $file_window_context_menu)

GUICtrlSetOnEvent(-1,"Xbutton")

$checkers_window_context_menu = GUICtrlCreateMenu("<Location> Checkers",$contextmenu)

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Bloomberg", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Reuters", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"About")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Active Processes", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Encryption Status", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Uptime", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Security", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

;========== end window context menu =============

GUICtrlCreateLabel("STATUS:", 5, 5)

GUICtrlCreateLabel("Idle. ", 5, 25)

GUICtrlSetFont (-1,7, 600)

GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton")

GUISetState ()

While 1

sleep(10)

Wend

Func UNC()

$asset = $iplist[@GUI_CtrlId]

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

GUICtrlCreateLabel("Idle. ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

EndIf

EndFunc ;==>UNC

Func Manage()

$asset = $iplist[@GUI_CtrlId]

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

Run(@ComSpec & " /c compmgmt.msc /computer=" & $asset)

GUICtrlCreateLabel("Idle. ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

EndIf

EndFunc ;==>Manage

Func EditINI()

ShellExecuteWait($Ini)

GUICTrlSetdata($combo,"")

GUICTrlSetdata($combo, "Select Asset...|" & LoadCombo(), "Select Asset...")

EndFunc ;==>EditINI

Func Change()

MsgBox(262144, "Dashboard v0.1", 'Change Log'&@CRLF & _

''&@CRLF & _

'No Changes'&@CRLF & _

''&@CRLF & _

'Please contact GXM x90760 for suggestions or bug reports.')

EndFunc ;==>Change

Func About()

MsgBox(64, "About", 'Dashboard v0.1'&@CRLF & _

''&@CRLF & _

'Launchpad for '&@CRLF & _

''&@CRLF & _

'1.'&@CRLF & _

'2.'&@CRLF & _

'3. '&@CRLF & _

'4.'&@CRLF & _

''&@CRLF & _

'Contact GXM x90760 for questions/suggestions.')

EndFunc ;==>About

Func Xbutton()

Exit

EndFunc ;==>Xbutton

Edited by gcue
Link to comment
Share on other sites

if the values of the ini exceed a certain number and hte icons "fall out of the space allocated"

i did extend the size of $maxY = to 1000. but i think theres a limit set.

is there a way to set it to unlimited to allow the user to enter as many icons as theyd like

also is there a way to disable the horizontal bar?

If you have very many icons to display there will always be a problem having enough space. I prefer to be able to scroll the images but leave the main gui alone. So one way I have used is to only show a 'page' at a time and the user has to click page up or page down to see the next or previous set. Then you can delete the displayed images and draw new ones.

Or you could also have a child window with the style WS_POPUP the size of the are used for the images with a vertical scroll bar which could scroll as far as you like.

Or maybe I've missed the point.

EDIT:Forgot to say, you need _GUIScrollBars_ShowScrollBar to hide or show a scrollbar.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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