Sign in to follow this  
Followers 0
michaelslamet

GUI hang (not responsive)

4 posts in this topic

#1 ·  Posted (edited)

I never face something like this, so here it is:

Using taietel's GUI Panel ('?do=embed' frameborder='0' data-embedContent>>) and

modified Google Maps UDF by kescho ()

I come up with this code:

;http://www.autoitscript.com/forum/topic/146952-gui-design-concepts/
;by taietel
;_Google Maps v2.au3 download at http://www.autoitscript.com/forum/topic/115437-google-maps-udf/?p=1132056

#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <_Google Maps v2.au3>
#region GLOBAL VARIABLES
Global $iW = 600, $iH = 400, $iT = 52, $iB = 52, $iLeftWidth = 150, $iGap = 10, $hMainGUI
#endregion GLOBAL VARIABLES

_MainGui()

Func _MainGui()
    Local $hFooter, $nMsg, $aPos
    Local $iLinks = 5
    Local $sMainGuiTitle = "Sample Title"
    Local $sHeader = "Sample GUI"
    Local $sFooter = "2012 © AutoIt"
    Local $aLink[$iLinks], $aPanel[$iLinks]
    $aLink[0] = $iLinks - 1
    $aPanel[0] = $iLinks - 1
    $hMainGUI = GUICreate($sMainGuiTitle, $iW, $iH, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP))
    GUISetIcon("shell32.dll", -58, $hMainGUI)

    GUICtrlCreateLabel($sHeader, 48, 8, $iW - 56, 32, $SS_CENTERIMAGE)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial", 5)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

    GUICtrlCreateIcon("shell32.dll", -131, 8, 8, 32, 32)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    GUICtrlCreateLabel("", 0, $iT, $iW, 2, $SS_SUNKEN);separator
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT)
    GUICtrlCreateLabel("", $iLeftWidth, $iT + 2, 2, $iH - $iT - $iB - 2, $SS_SUNKEN);separator
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH)
    GUICtrlCreateLabel("", 0, $iH - $iB, $iW, 2, $SS_SUNKEN);separator
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT)

    $hFooter = GUICtrlCreateLabel($sFooter, 10, $iH - 34, $iW - 20, 17, BitOR($SS_LEFT, $SS_CENTERIMAGE))
    GUICtrlSetTip(-1, "AutoIt Forum", "Click to open...")
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

    ;add links to the left side
    $aLink[1] = _AddNewLink("Link 1")
    $aLink[2] = _AddNewLink("Link 2", -167)
    $aLink[3] = _AddNewLink("Link 3", -222)
    $aLink[4] = _AddNewLink("Link 4", -22)
    ;and the corresponding GUI's
    $aPanel[1] = _AddNewPanel("Title for the panel 1")
    $aPanel[2] = _AddNewPanel("Title for the panel 2")
    $aPanel[3] = _AddNewPanel("Title for the panel 3")
    $aPanel[4] = _AddNewPanel("Title for the panel 4")

    ;add some controls to the panels
    _AddControlsToPanel($aPanel[1])
    GUICtrlCreateEdit("", 10, 37, $iW - $iLeftWidth + 2 - 20 - 5, $iH - $iT - $iB - 40, BitOR($ES_AUTOVSCROLL, $ES_NOHIDESEL, $ES_WANTRETURN, $WS_VSCROLL), $WS_EX_STATICEDGE)
    Local $sTestTxt = ""
    For $i = 1 To 10
        $sTestTxt &= @TAB & "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum felis lectus, pharetra vel laoreet nec, pulvinar nec justo. Donec malesuada, nunc eu faucibus sodales, diam sem tempor neque, id condimentum turpis nunc vel lacus. Nulla a nulla libero, eget eleifend dolor. Vivamus volutpat tincidunt ultricies. Vestibulum eu libero nisi, quis tincidunt nisi. Proin tincidunt, ipsum ullamcorper posuere venenatis, libero nulla venenatis enim, ultrices tincidunt ipsum arcu nec turpis. In at erat sed ipsum gravida mattis in at felis. Vivamus diam purus, dictum ut luctus vitae, sollicitudin ut velit. Maecenas velit mauris, fringilla ut condimentum bibendum, aliquam a neque. Nulla metus eros, commodo id dictum in, interdum sed ipsum. Vivamus feugiat, mi at auctor fringilla, libero lectus vulputate tortor, eu sollicitudin nulla lacus at neque." & @CRLF
        $sTestTxt &= @TAB & "Sed vel ante magna. Curabitur porttitor ante in tellus bibendum non tristique diam volutpat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In tellus lectus, ultrices in tempus eget, sollicitudin quis eros. Curabitur at arcu bibendum massa feugiat euismod at a felis. Nunc molestie, enim non ornare tincidunt, ipsum nisi tempus sapien, quis elementum elit velit ut neque. Suspendisse eu adipiscing risus. Nam tempor odio ut elit auctor rhoncus. Etiam viverra elit id felis feugiat pellentesque pretium porttitor dui. Vivamus eu quam non ante suscipit vehicula a nec eros. Phasellus congue massa sed libero interdum ullamcorper. Quisque fringilla massa ut lorem fringilla pulvinar eget ullamcorper eros. Praesent faucibus, erat at consequat tempus, nulla erat sodales mi, eget sagittis nibh erat nec nunc. Phasellus risus nibh, porta viverra pretium nec, vehicula eget nisi." & @CRLF
        $sTestTxt &= @TAB & "Sed vel neque vel urna elementum accumsan feugiat quis mauris. Sed mi nisl, consequat dapibus molestie ac, rutrum ut elit. Praesent sed risus sem. Mauris rutrum blandit magna nec tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse consequat iaculis odio nec cursus. Duis varius tincidunt ligula ac ultricies. Ut eget magna in nulla vulputate dapibus ut vel sem. Integer ac tempor risus." & @CRLF
        $sTestTxt &= @TAB & "Maecenas molestie semper turpis, id tristique nibh pharetra eget. Aliquam erat volutpat. In egestas, lorem quis varius vestibulum, enim diam porta lorem, quis dictum arcu ante a diam. Nullam vel nisi mauris. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam ut leo purus, eget vulputate augue. Fusce et est sagittis felis accumsan sollicitudin eget a lectus. Cras sapien sapien, rutrum eu tempor non, tempor nec velit. Vivamus interdum adipiscing felis in malesuada. Fusce quis purus est, eget molestie turpis. In hac habitasse platea dictumst." & @CRLF
        $sTestTxt &= @TAB & "Aenean eleifend risus vitae lorem laoreet facilisis. Suspendisse ac urna quam, vel rutrum sem. Sed bibendum porta tellus malesuada scelerisque. Vestibulum at ligula sed nulla sollicitudin tincidunt. Pellentesque mi magna, vulputate et aliquam a, auctor et nunc. Phasellus feugiat fringilla accumsan. Donec ultrices, elit id dapibus auctor, nunc odio viverra lorem, non commodo mi libero a libero. Cras vitae felis venenatis augue laoreet tincidunt scelerisque id odio. Proin lorem purus, molestie feugiat pretium nec, ornare aliquam turpis. "
    Next
    GUICtrlSetData(-1, $sTestTxt)
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM)

    _AddControlsToPanel($aPanel[2])
    GUICtrlCreateLabel("Label1", 8, 38, 36, 17)
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    Local $hInput1 = GUICtrlCreateInput("Input1", 56, 35, 121, 21)
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    Local $hButton1 = GUICtrlCreateButton("Button1", 200, 33, 75, 25)
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

    _AddControlsToPanel($aPanel[3])
    $gmap_ctrl = _GUICtrlGoogleMap_Create($gmap, 5, 5, 836, 426, "serbia", 10, 0, False, True, 0, 4, 3, 3, 1, "US", "C")

    _AddControlsToPanel($aPanel[4])
    GUICtrlCreateGroup("Group1", 8, 35, 129, 90)
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    Local $aChkBox[4]
    For $i = 1 To 3
        $aChkBox[$i] = GUICtrlCreateRadio("Some radio " & $i, 16, 56 + ($i - 1) * 20, 113, 17)
        GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    Next
    GUICtrlSetState(-1, $GUI_CHECKED)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

    ;set default to Panel1
    GUISwitch($aPanel[1])
    ;show the main GUI
    GUISetState(@SW_SHOW, $hMainGUI)

    While 1
        Sleep(10)
        $nMsg = GUIGetMsg(1)
        Switch $nMsg[1]
            Case $hMainGUI
                Switch $nMsg[0]
                    Case $GUI_EVENT_CLOSE
                        Exit
                    Case $GUI_EVENT_MINIMIZE, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE
                        $aPos = WinGetPos($hMainGUI)
                        $iW = $aPos[2]
                        $iH = $aPos[3]
                        For $i = 0 To $aPanel[0]
                            WinMove($aPanel[$i], "", $iLeftWidth + 2, $iT, $iW - $iLeftWidth + 2, $iH - $iT - $iB - 20)
                        Next
                    Case $aLink[1], $aLink[2], $aLink[3], $aLink[4]
                        For $i = 1 To $aLink[0]
                            If $nMsg[0] = $aLink[$i] Then
                                GUISetState(@SW_SHOW, $aPanel[$i])
                            Else
                                GUISetState(@SW_HIDE, $aPanel[$i])
                            EndIf
                        Next
                    Case $hFooter
                        ;ShellExecute("<a href='http://www.autoitscript.com/forum/topic/146952-gui-design-concepts/' class='bbc_url' title=''>http://www.autoitscript.com/forum/topic/146952-gui-design-concepts/"</a>)
                EndSwitch
            Case $aPanel[2]
                Switch $nMsg[0]
                    Case $hButton1
                        MsgBox(32, "Test", "You have " & GUICtrlRead($hInput1) & "?")
                EndSwitch
            Case $aPanel[4]
                Switch $nMsg[0]
                    Case $aChkBox[1], $aChkBox[2], $aChkBox[3]
                        For $i = 1 To 3
                            If GUICtrlRead($aChkBox[$i]) = $GUI_CHECKED Then MsgBox(64, "Test", "You checked nr. " & $i & "!")
                        Next
                EndSwitch
        EndSwitch
    WEnd
EndFunc   ;==>_MainGui

Func _AddNewLink($sTxt, $iIcon = -44)
    Local $hLink = GUICtrlCreateLabel($sTxt, 36, $iT + $iGap, $iLeftWidth - 46, 17)
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    GUICtrlCreateIcon("shell32.dll", $iIcon, 10, $iT + $iGap, 16, 16)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $iGap += 22
    Return $hLink
EndFunc   ;==>_AddNewLink

Func _AddNewPanel($sTxt)
    Local $gui = GUICreate("", $iW - $iLeftWidth + 2, $iH - $iT - $iB, $iLeftWidth + 2, $iT, $WS_CHILD + $WS_VISIBLE, -1, $hMainGUI)
    GUICtrlCreateLabel($sTxt, 10, 10, $iW - $iLeftWidth - 20, 17, $SS_CENTERIMAGE)
    GUICtrlSetFont(-1, 9, 800, 4, "Arial", 5)
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    Return $gui
EndFunc   ;==>_AddNewPanel

Func _AddControlsToPanel($hPanel)
    GUISwitch($hPanel)
EndFunc   ;==>_AddControlsToPanel

The problem is when I click on "Link 3" to display Google Maps and then let the window loose focus for few secs,

and then back to the script/GUI, the GUI will be "hang" (not responding).

The only way is to terminate it.

To try it, download _Google Maps v2.au3 from

What has happened?

Edit: it works great without google maps, but the problem is not with the google maps udf. Other google maps script (example) without this GUI panel is working great

Edited by michaelslamet

Share this post


Link to post
Share on other sites



I really hit the wall on this :(

Tried to read "managing multiple GUI wiki", changing window styles, use OnEvent mode cant solve it.

Is this case unsolvable?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Don't bump, you should know this by now.

Why not try isolating the issue first by not using the Google Maps UDF and then work from there. As I hope you can appreciate, it's quite difficult to fix a problem in an entire program that you've designed yourself. I hope you will put your acquired debugging skills to some use.

PS You didn't mention the essentials of what system you're using.

PPS From what I can see you have just merged a bunch of code together hoping it will work. As you can see that's an improper way to code a program, especially if you don't understand the code you're adding.

Edited by guinness
1 person likes this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Don't bump, you should know this by now.

Why not try isolating the issue first by not using the Google Maps UDF and then work from there. As I hope you can appreciate, it's quite difficult to fix a problem in an entire program that you've designed yourself. I hope you will put your acquired debugging skills to some use.

PS You didn't mention the essentials of what system you're using.

PPS From what I can see you have just merged a bunch of code together hoping it will work. As you can see that's an improper way to code program, especially if you don't understand the code you're adding.

 

Good day, guinness :)

I'm sorry for bumping, I forgot I should not post anything especially in the first 24 hours.

I do try to debug it by not using Google Maps UDF on the GUI Panel, it's working great, no GUI not-responding issue.

I also try to create a code just to display the maps (without the GUI panel), it also have no GUI not-responding issue.

After hours, I still have no idea how to "combine" them both. In my swallow knowledge, that is not really combine 2 different code,

because I just try to display the maps (control) on the GUI panel, by using run one function.

That script will not be my main script, as I still try to make it work, so it's basicly my (stupid) way to learn about it :)

Until I fully understand how it work, I will create my "final" code :)

 

I'm trying on WinXP SP2 and Win7 32 bit, both running 3.8.8.1 and have same issue.

Thank you for replying :)

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