Sign in to follow this  
Followers 0
aommaster

Little problem with a GUI window

7 posts in this topic

Hi Everyone!

My code:

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GuiEdit.au3>
#Include <String.au3>

#region Create Window
Opt("GUIOnEventMode", 1)
$window= GUICreate("Canned Speech Assistant V0.1 by Aommaster", 1000, 800, -1, -1, BitOr($WS_HSCROLL, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_VSCROLL)) 

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
#endregion

#region Tabs
$tab=GUICtrlCreateTab (10,10,960,740)
GUICtrlSetResizing(-1,$GUI_DOCKAUTO)
#Region Create Post Previewer
$tab0=GUICtrlCreateTabitem ("Post Previewer")
GUICtrlCreateLabel("Message:", 20, 60, 940, -1)
GUICtrlSetResizing ( -1, 550)

$message= GUICtrlCreateEdit("", 20, 75, 940, 300)
GUICtrlSetResizing ( -1, 550)

GUICtrlCreateLabel("Preview:", 20, 415, 940, -1)
GUICtrlSetResizing ( -1, 550)

$generatepreview=guictrlcreatebutton("Generate preview", 430, 390)
GUICtrlSetResizing ( -1, 802)
guictrlsetonevent($generatepreview, "preview")

$oIE = _IECreateEmbedded()
$Preview = GUICtrlCreateObj($oIE, 20, 430, 940, 300)
GUICtrlSetResizing ( -1, 550)
GUISetState(@SW_SHOW)
$htmlfile=@ScriptDir  & "\output.html"
_IENavigate($oIE, $htmlfile)

while 1
    sleep(100)
WEnd

If you attempt to run this (yes there are undefined functions.. I have written them, but didn't post them here because they're not important) GUI a few things I'd like to fix:

1. The scrollbars seem active even though the whole window is viewed. How do I grey them out when no scrolling is needed?

2. If the window is resized, the scrollbars don't do anything, ie. I cannot scroll regardless. How do I fix this?

3. If you resize the window to a reall small size, you'll notice that the "Preview" button overlaps the white tab limit. How do I prevent this from happening? This goes the same to the edit boxes.

Thanks :)

Share this post


Link to post
Share on other sites



Hi Everyone!

My code:

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GuiEdit.au3>
#Include <String.au3>

#region Create Window
Opt("GUIOnEventMode", 1)
$window= GUICreate("Canned Speech Assistant V0.1 by Aommaster", 1000, 800, -1, -1, BitOr($WS_HSCROLL, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_VSCROLL)) 

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
#endregion

#region Tabs
$tab=GUICtrlCreateTab (10,10,960,740)
GUICtrlSetResizing(-1,$GUI_DOCKAUTO)
#Region Create Post Previewer
$tab0=GUICtrlCreateTabitem ("Post Previewer")
GUICtrlCreateLabel("Message:", 20, 60, 940, -1)
GUICtrlSetResizing ( -1, 550)

$message= GUICtrlCreateEdit("", 20, 75, 940, 300)
GUICtrlSetResizing ( -1, 550)

GUICtrlCreateLabel("Preview:", 20, 415, 940, -1)
GUICtrlSetResizing ( -1, 550)

$generatepreview=guictrlcreatebutton("Generate preview", 430, 390)
GUICtrlSetResizing ( -1, 802)
guictrlsetonevent($generatepreview, "preview")

$oIE = _IECreateEmbedded()
$Preview = GUICtrlCreateObj($oIE, 20, 430, 940, 300)
GUICtrlSetResizing ( -1, 550)
GUISetState(@SW_SHOW)
$htmlfile=@ScriptDir  & "\output.html"
_IENavigate($oIE, $htmlfile)

while 1
    sleep(100)
WEnd

If you attempt to run this (yes there are undefined functions.. I have written them, but didn't post them here because they're not important) GUI a few things I'd like to fix:

1. The scrollbars seem active even though the whole window is viewed. How do I grey them out when no scrolling is needed?

2. If the window is resized, the scrollbars don't do anything, ie. I cannot scroll regardless. How do I fix this?

3. If you resize the window to a reall small size, you'll notice that the "Preview" button overlaps the white tab limit. How do I prevent this from happening? This goes the same to the edit boxes.

Thanks :)

Sounds like your code won't run so if you post something we can try you might get more replies.

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.

Share this post


Link to post
Share on other sites

Hi Martin!

Thank you very much for your time. I've reposted the code, however, an extremely simplified version so as that you can see where I have my problems. Since this post is several days old, I could not post the whole piece of code, as it is more than 500 lines long, and most of it is irrelevant to this problem :)

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

#region Create Window
Opt("GUIOnEventMode", 1)
$window= GUICreate("Canned Speech Assistant V0.1 by Aommaster", 1000, 800, -1, -1, BitOr($WS_HSCROLL, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_VSCROLL)) 

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
#endregion


$tab=GUICtrlCreateTab (10,10,960,740)
GUICtrlSetResizing(-1,$GUI_DOCKAUTO)

$tab0=GUICtrlCreateTabitem ("Post Previewer")
GUICtrlCreateLabel("Message:", 20, 60, 940, -1)
GUICtrlSetResizing ( -1, 550)

$message= GUICtrlCreateEdit("", 20, 75, 940, 300)
GUICtrlSetResizing ( -1, 550)

$generatepreview=guictrlcreatebutton("Generate preview", 430, 390)
GUICtrlSetResizing ( -1, 802)

GUISetState(@SW_SHOW)

while 1
    sleep(100)
WEnd

func closeclicked()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Hi Martin!

Thank you very much for your time. I've reposted the code, however, an extremely simplified version so as that you can see where I have my problems. Since this post is several days old, I could not post the whole piece of code, as it is more than 500 lines long, and most of it is irrelevant to this problem :)

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

#region Create Window
Opt("GUIOnEventMode", 1)
$window= GUICreate("Canned Speech Assistant V0.1 by Aommaster", 1000, 800, -1, -1, BitOr($WS_HSCROLL, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_VSCROLL)) 

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
#endregion


$tab=GUICtrlCreateTab (10,10,960,740)
GUICtrlSetResizing(-1,$GUI_DOCKAUTO)

$tab0=GUICtrlCreateTabitem ("Post Previewer")
GUICtrlCreateLabel("Message:", 20, 60, 940, -1)
GUICtrlSetResizing ( -1, 550)

$message= GUICtrlCreateEdit("", 20, 75, 940, 300)
GUICtrlSetResizing ( -1, 550)

$generatepreview=guictrlcreatebutton("Generate preview", 430, 390)
GUICtrlSetResizing ( -1, 802)

GUISetState(@SW_SHOW)

while 1
    sleep(100)
WEnd

func closeclicked()
    Exit
EndFunc
You need to look at the scrollbar example in the help. I have modified your code to give vertical scrolling for the window.

Func _GUIScrollBars_SetPos($hWnd, $wBar, $Pos)
    Local $index = -1, $m_height, $m_width, $c_top, $c_height, $yChar, $xChar, $xClientMax, $xyPos

    For $x = 0 To UBound($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $index = $x
            $xChar = $aSB_WindowInfo[$index][2]
            $yChar = $aSB_WindowInfo[$index][3]
            ExitLoop
        EndIf
    Next
    If $index = -1 Then Return 0

    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

; Save the position for comparison later on
    DllStructSetData($tSCROLLINFO, "cbSize", DllStructGetSize($tSCROLLINFO))
    DllStructSetData($tSCROLLINFO, "fMask", $SIF_ALL)
    DllCall("user32.dll", "int", "GetScrollInfo", "hwnd", $hWnd, "int", $wBar, "ptr", DllStructGetPtr($tSCROLLINFO))
    $xyPos = DllStructGetData($tSCROLLINFO, "nPos")

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    DllStructSetData($tSCROLLINFO, "nPos", $Pos)
    DllCall("user32.dll", "int", "SetScrollInfo", "hwnd", $hWnd, "int", $wBar, "ptr", DllStructGetPtr($tSCROLLINFO), "int", True)
    DllCall("user32.dll", "int", "GetScrollInfo", "hwnd", $hWnd, "int", $wBar, "ptr", DllStructGetPtr($tSCROLLINFO))
;// If the position has changed, scroll the window and update it
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If $wBar = $SB_HORZ Then
        If ($Pos <> $xyPos) Then DllCall("user32.dll", "int", "ScrollWindow", "hwnd", $hWnd, "int", $xChar * ($xyPos - $Pos), "int", 0, "ptr", 0, "ptr", 0)
    Else
        If ($Pos <> $xyPos) Then DllCall("user32.dll", "int", "ScrollWindow", "hwnd", $hWnd, "int", 0, "int", $yChar * ($xyPos - $Pos), "ptr", 0, "ptr", 0)
    EndIf
EndFunc  ;==>_GUIScrollBars_SetPos

The resizing styles need to be changed to make them sensible for a window with vertical scrolling though.


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.

Share this post


Link to post
Share on other sites

Hi Martin!

I'll take a look at the help file and see what it has about the scrollbars. I'm quite new to AutoIt's capability with GUI functions.

By the way, do you have any idea on how to fix this:

3. If you resize the window to a reall small size, you'll notice that the "Preview" button overlaps the white tab limit. How do I prevent this from happening? This goes the same to the edit boxes.

Share this post


Link to post
Share on other sites

Hi Martin!

I'll take a look at the help file and see what it has about the scrollbars. I'm quite new to AutoIt's capability with GUI functions.

By the way, do you have any idea on how to fix this:

I tried the code you posted and it didn't happen so I assumed you had changed the resizing style. If you want to limit how small a window can be made, or how big then you can do this-

Global Const $minHt=100, $minWd=150,$maxHt = @DeskTopHeight, $maxWid = @DeskTopWidth
;create window

GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO");somewhere after creating you window

Func MY_WM_GETMINMAXINFO($hWnd, $msg, $WParam, $LParam)
    Local $Structmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $LParam)
      
;set size when maximised
    DllStructSetData($Structmaxinfo , 3, $maxWid); max X
    DllStructSetData($Structmaxinfo , 4, $maxHt; max Y
;set min/max tracking sizes
    DllStructSetData($Structmaxinfo , 7,$minWid); min X
    DllStructSetData($Structmaxinfo , 8, $minHt); min Y
    DllStructSetData($Structmaxinfo , 9, $maxWid); max X
    DllStructSetData($Structmaxinfo , 10, $maxHt; max Y
    Return 0;return 0 to indicate we have dealt with this message
EndFunc  ;==>AMDB_WM_GETMINMAXINFO

msdn info


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.

Share this post


Link to post
Share on other sites

Ahh.. thanks Martin :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0