Jump to content

Menus And Statusbar


Recommended Posts

1. Does anyone know why Help->About and File->Exit take so long to execute (display the messagebox or exit) in this code? Clicking on the "X" to exit or clicking the button execute normally.

2. Also, does anyone know why double clicking the title bar doesn't resize/move the StatusBar correctly? Clicking the maximize/restore button resizes/moves the StatusBar correctly, but double clicking the title bar doesn't.

*Using AutoIt3 beta version 3.1.1.120*

#include <GuiConstants.au3>
#include <GuiStatusBar.au3>
#include <GUIListView.au3>

UDPStartup()

$IP = "127.0.0.1"
$Port = 20001
$socket_in = UDPBind($IP,$Port)
If @error <> 0 Then 
    MsgBox(0,"Testing","Error binding to 127.0.0.1 port 20001")
    Exit
EndIf

$Main = GUICreate("Testing",800,600,(@DesktopWidth - 800)/2,(@DesktopHeight - 600)/2,BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_MAXIMIZEBOX))

$FileMenu = GUICtrlCreateMenu("&File")
$FileMenuExit = GUICtrlCreateMenuitem("Exit",$FileMenu)

$HelpMenu = GUICtrlCreateMenu("&Help")
$HelpMenuAbout = GUICtrlCreateMenuItem("&About",$HelpMenu)

$MainWinSize = WinGetClientSize($Main)

$CodeListviewLeft = 5
$CodeListviewTop = 5
$CodeListviewWidth = $MainWinSize[0]*0.6
$CodeListviewHeight = $MainWinSize[1] - 60

$VariablesListviewLeft = $CodeListviewLeft + $CodeListviewWidth + 5
$VariablesListviewTop = 5
$VariablesListviewWidth = $MainWinSize[0] - $CodeListviewWidth - 15
$VariablesListviewHeight = $MainWinSize[1] - 60

$CodeListview = GUICtrlCreateListView("Column1|Column2",$CodeListviewLeft,$CodeListviewTop,$CodeListviewWidth,$CodeListviewHeight,$LVS_REPORT,$LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES + $LVS_EX_GRIDLINES)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
_GUICtrlListViewSetColumnWidth($CodeListview,1,450)
$VariablesListview = GUICtrlCreateListView("Column3|Column4",10 + $MainWinSize[0]*0.6,$VariablesListviewTop,$VariablesListviewWidth,$VariablesListviewHeight,$LVS_REPORT,$LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES + $LVS_EX_GRIDLINES)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
_GUICtrlListViewSetColumnWidth($VariablesListview,0,100)
_GUICtrlListViewSetColumnWidth($VariablesListview,1,200)

$Button1 = GUICtrlCreateButton("Button1",400,530,100,20)
$Label = GUICtrlCreateLabel("",200,530,100,20)

Local $StatusPartsRightEdge[1] = [$MainWinSize[0]]
Local $StatusPartsText[1] = ["Statusbar Text"]
$StatusBar = _GuiCtrlStatusBarCreate($Main,$StatusPartsRightEdge,$StatusPartsText)

$total_items = 0
GuiSetState()
$data = ""
While 1
    $data = UDPRecv($socket_in,50)
    If $data <> "" Then
        MsgBox(0,"Testing","$data = " & $data)
    EndIf
    
    $msg = GuiGetMsg()
    Select
    Case $msg = $HelpMenuAbout
        MsgBox(0,"Testing","About Information Here")
    Case $msg = $Button1
        MsgBox(0,"Testing","Button clicked")
    Case $msg = $GUI_EVENT_CLOSE Or $msg = $FileMenuExit
        ExitLoop
    Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE
        _GuiCtrlStatusBarResize($StatusBar)
        $MainWinSize = WinGetClientSize($Main)
        $CodeListviewLeft = 5
        $CodeListviewTop = 5
        $CodeListviewWidth = $MainWinSize[0]*0.6
        $CodeListviewHeight = $MainWinSize[1] - 60

        $VariablesListviewLeft = $CodeListviewLeft + $CodeListviewWidth + 5
        $VariablesListviewTop = 5
        $VariablesListviewWidth = $MainWinSize[0] - $CodeListviewWidth - 15
        $VariablesListviewHeight = $MainWinSize[1] - 60
        GUICtrlSetPos($CodeListview,$CodeListviewLeft,$CodeListviewTop,$CodeListviewWidth,$CodeListviewHeight)
        GUICtrlSetPos($VariablesListview,$VariablesListviewLeft,$VariablesListviewTop,$VariablesListviewWidth,$VariablesListviewHeight)
    Case Else
      ;;;
    EndSelect
WEnd
Edited by livewire
Link to comment
Share on other sites

Hrm... I would have to say it has something to do with the socket you are trying to recieve at the first part of the script. Is there a way to loop that only in certain instances?

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Seems like a bug in both situations to me. But I'm seeing if I'm doing something wrong. It appears that the UDPRecv is screwing up the menu messages being sent to GUIRecvMsg.

-Livewire

I came up with a thought to move the UDPRecv() to the bottom of the While loop, and that didnt help at all. I would have thought it would process it on a first come first serve basis. I am working on some other theories atm.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

$StatusBar = _GuiCtrlStatusBarCreate($Main,-1,$StatusPartsText)
Not sure what that did as I havent messed with any of those fucntions before, but it still has the same exiting and performing behavior...slow.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Not sure what that did as I havent messed with any of those fucntions before, but it still has the same exiting and performing behavior...slow.

JS

It was the answer to the second question, not the 1st one your working on

Try putting the other code in the else, will still be sluggish but not at bad, i.e.

Case Else
         $data = UDPRecv($socket_in,50)
         If $data <> "" Then
              MsgBox(0,"Testing","$data = " & $data)
         EndIf

udprecv is attempting to recieve up to 50 characters at the same time guigetmsg is expecting a key/mouse click event and keeps checking for it, so everytime udprecv runs yes the guigetmsg will be sluggish.

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

$StatusBar = _GuiCtrlStatusBarCreate($Main,-1,$StatusPartsText)
@gafrost

I'm sorry, I didn't make my self clear...I edited my first post. I was wondering why it didn't move the statusbar to the bottom of the GUI when double-clicking the title bar. Clicking maximize/restore button does do this.

-Livewire

Edited by livewire
Link to comment
Share on other sites

@gafrost

I'm sorry, I didn't make my self clear...I edited my first post. I was wondering why it didn't move the statusbar to the bottom of the GUI when double-clicking the title bar. Clicking maximize/restore button does do this.

-Livewire

change your case statement

Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MINIMIZE Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE

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

change your case statement

Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MINIMIZE Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE
@gafrost

This does not work (completely) if you double-click on the title bar. It resizes the control correctly, but does not move the statusbar to the bottom of the GUI as it should.

Try it:

- click the minimize/restore button to maximize and restore, then

- double-click the title bar to maximize and restore

-Livewire

Link to comment
Share on other sites

@gafrost

This does not work (completely) if you double-click on the title bar. It resizes the control correctly, but does not move the statusbar to the bottom of the GUI as it should.

Try it:

- click the minimize/restore button to maximize and restore, then

- double-click the title bar to maximize and restore

-Livewire

I tried your suggestion, it works for me, however it is slow to do so due to the udprecv

#include <GuiConstants.au3>
#include <GuiStatusBar.au3>
#include <GUIListView.au3>

UDPStartup()

$IP = "127.0.0.1"
$Port = 20001
$socket_in = UDPBind($IP, $Port)
If @error <> 0 Then
    MsgBox(0, "Testing", "Error binding to 127.0.0.1 port 20001")
    Exit
EndIf

$Main = GUICreate("Testing", 800, 600, (@DesktopWidth - 800) / 2, (@DesktopHeight - 600) / 2, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))

$FileMenu = GUICtrlCreateMenu("&File")
$FileMenuExit = GUICtrlCreateMenuitem("Exit", $FileMenu)

$HelpMenu = GUICtrlCreateMenu("&Help")
$HelpMenuAbout = GUICtrlCreateMenuitem("&About", $HelpMenu)

$MainWinSize = WinGetClientSize($Main)

$CodeListviewLeft = 5
$CodeListviewTop = 5
$CodeListviewWidth = $MainWinSize[0] * 0.6
$CodeListviewHeight = $MainWinSize[1] - 60

$VariablesListviewLeft = $CodeListviewLeft + $CodeListviewWidth + 5
$VariablesListviewTop = 5
$VariablesListviewWidth = $MainWinSize[0] - $CodeListviewWidth - 15
$VariablesListviewHeight = $MainWinSize[1] - 60

$CodeListview = GUICtrlCreateListView("Column1|Column2", $CodeListviewLeft, $CodeListviewTop, $CodeListviewWidth, $CodeListviewHeight, $LVS_REPORT, $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES + $LVS_EX_GRIDLINES)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
_GUICtrlListViewSetColumnWidth($CodeListview, 1, 450)
$VariablesListview = GUICtrlCreateListView("Column3|Column4", 10 + $MainWinSize[0] * 0.6, $VariablesListviewTop, $VariablesListviewWidth, $VariablesListviewHeight, $LVS_REPORT, $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES + $LVS_EX_GRIDLINES)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
_GUICtrlListViewSetColumnWidth($VariablesListview, 0, 100)
_GUICtrlListViewSetColumnWidth($VariablesListview, 1, 200)

$Button1 = GUICtrlCreateButton("Button1", 400, 530, 100, 20)
$Label = GUICtrlCreateLabel("", 200, 530, 100, 20)

Local $StatusPartsRightEdge[1] = [$MainWinSize[0]]
Local $StatusPartsText[1] = ["Statusbar Text"]
$StatusBar = _GuiCtrlStatusBarCreate($Main, -1, $StatusPartsText)

$total_items = 0
GUISetState()
$data = ""
While 1
    
    $msg = GUIGetMsg()
    Select
        Case $msg = $HelpMenuAbout
            MsgBox(0, "Testing", "About Information Here")
        Case $msg = $Button1
            MsgBox(0, "Testing", "Button clicked")
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $FileMenuExit
            ExitLoop
        Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MINIMIZE Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE
            _GuiCtrlStatusBarResize($StatusBar)
            $MainWinSize = WinGetClientSize($Main)
            $CodeListviewLeft = 5
            $CodeListviewTop = 5
            $CodeListviewWidth = $MainWinSize[0] * 0.6
            $CodeListviewHeight = $MainWinSize[1] - 60
            
            $VariablesListviewLeft = $CodeListviewLeft + $CodeListviewWidth + 5
            $VariablesListviewTop = 5
            $VariablesListviewWidth = $MainWinSize[0] - $CodeListviewWidth - 15
            $VariablesListviewHeight = $MainWinSize[1] - 60
            GUICtrlSetPos($CodeListview, $CodeListviewLeft, $CodeListviewTop, $CodeListviewWidth, $CodeListviewHeight)
            GUICtrlSetPos($VariablesListview, $VariablesListviewLeft, $VariablesListviewTop, $VariablesListviewWidth, $VariablesListviewHeight)
        Case Else
            $data = UDPRecv($socket_in, 50)
            If $data <> "" Then
                MsgBox(0, "Testing", "$data = " & $data)
            EndIf
        ;;;
    EndSelect
WEnd

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

Oh...I see what's going on with my second problem. Double-clicking the title bar doesn't trigger $GUI_EVENT_MAXIMIZE. Is this a bug (or do I need to do some GUIRegisterMsg thing)? Double-clicking a title bar that is already maximized does trigger $GUI_EVENT_RESIZED.

-Livewire

Edited by livewire
Link to comment
Share on other sites

Oh...I see what's going on with my second problem. Double-clicking the title bar doesn't trigger $GUI_EVENT_MAXIMIZE. Is this a bug (or do I need to do some GUIRegisterMsg thing)? Double-clicking a title bar that is already maximized does trigger $GUI_EVENT_RESIZED.

-Livewire

Doubleclicking titlebar change the size so $GUI_EVENT_RESIZED is fired.

$GUI_EVENT_MAXIMIZE or $GUI_EVENT_MINIZE are fired when clicking on the correspondant button. :think:

Link to comment
Share on other sites

livewire, trying using event mode instead. You don't want anything in a message loop which will slow down message processing. That's exactly what you have when you use internet related functions in your message loop.

Link to comment
Share on other sites

JPM,

You are missing what we are saying. When a window is already maximized, when you double-click the title bar I would think that it should trigger $GUI_EVENT_RESIZED. It currently doesn't. Is this a bug?

-Livewire

I believe he knows exactly what you are saying. He agrees it should trigger that. (Correct me if I am wrong JPM)

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Doubleclicking titlebar change the size so $GUI_EVENT_RESIZED is fired.

$GUI_EVENT_MAXIMIZE or $GUI_EVENT_MINIZE are fired when clicking on the correspondant button. :think:

IMO, this behavior is completely screwed up. When I have a window maximized and I double-click the titlebar, I expect to get $GUI_EVENT_RESTORE, not $GUI_EVENT_RESIZED. Also, when I double-click the titlebar of a non-maximized window, the window is maximized but I don't get an event at all.

The current behavior is:

  • Double click non-maximized window titlebar: The window is maximized and the event $GUI_EVENT_RESIZE is sent.
  • Double click maximized window titlebar: The window is restored and no event is sent.
This is the behavior I expect:
  • Double click non-maximized window titlebar: The window is maximized and the event $GUI_EVENT_MAXIMIZE is sent.
  • Double click maximized window titlebar: The window is restored and the event $GUI_EVENT_RESTORE is sent.
Link to comment
Share on other sites

I would expect that anything that causes the GUI to maximize would trigger $GUI_EVENT_MAXIMIZE. I am now seeing that this is not the case. Only clicking the maximize button or selecting maximize in the system menu causes $GUI_EVENT_MAXIMIZE.

This is similar for the other GUI EVENTS (RESTORE,MINIMIZE,etc.). For example, hitting "Windows Key" + M and "Windows Key" + Shift + M minimize and restore GUIs but do not trigger these events.

Is this how it should function? I'm just trying to make sure this is the functionality that you guys (AutoIt developers) want. If so, I will have to use GUIRegisterMsg.

-Livewire

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...