Jump to content

$GUI_ONTOP


livewire
 Share

Recommended Posts

In new beta 3.1.1.107, how can I make this script have the buttons and labels appear on top of the graphic control so that I can click them (obviously without resizing the graphic control).

This script worked as is in beta 3.1.1.106. **Note: Important part of code is GUI control creation part...pretty much ignore the rest.

#include <GuiConstants.au3>
#include <File.au3>
#include <Array.au3>
$scale = 30
$XScreenSize = 700
$YScreenSize = 700

Global $glCounter = 0
Global $XABS
Global $YABS
Global $EARLY_EXIT

$GUI_Handle = GuiCreate("Grab 'N Draw", 176, 161,(@DesktopWidth-176)/2, (@DesktopHeight-161)/2)

$Button_1 = GuiCtrlCreateButton("Select", 50, 135, 75, 20)
$List_2 = GuiCtrlCreateList("List3", 10, 20, 160, 110)
$Label_3 = GuiCtrlCreateLabel("Select IP to use:", 45, 5, 80, 15)

$IP_STRING = "|127.0.0.1"
If @IPAddress1 <> "0.0.0.0" And @IPAddress1 <> "127.0.0.1" Then
    $IP_STRING &= "|" & @IPAddress1
EndIf
If @IPAddress2 <> "0.0.0.0" And @IPAddress2 <> "127.0.0.1" Then
    $IP_STRING &= "|" & @IPAddress2
EndIf
If @IPAddress3 <> "0.0.0.0" And @IPAddress3 <> "127.0.0.1" Then
    $IP_STRING &= "|" & @IPAddress3
EndIf
If @IPAddress4 <> "0.0.0.0" And @IPAddress4 <> "127.0.0.1" Then
    $IP_STRING &= "|" & @IPAddress4
EndIf

GUICtrlSetData($List_2,$IP_STRING,"127.0.0.1")

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $Button_1
        $IP_TO_USE = GUICtrlRead($List_2)
        GUISetState(@SW_HIDE,$GUI_Handle)
        ExitLoop
    Case $msg = $GUI_EVENT_CLOSE
        $EARLY_EXIT = 1
        Exit
    Case Else
       ;;;
    EndSelect
WEnd

$nGridSize = 10
Dim $FileArray[1]
Dim $FloatArray[1000000]
$main = GUICreate("Grab 'N Draw", $XScreenSize, $YScreenSize, (@DesktopWidth - $XScreenSize)/2, 1, BitOr($WS_POPUP, $WS_CAPTION, $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_THICKFRAME))
$init_button = GUICtrlCreateButton("Init",430,670,50,20)
$Draw_Button = GUICtrlCreateButton("Draw",490,670,50,20)
$File_Write_Button = GUICtrlCreateButton("2File",550,670,50,20)
$File_Read_Button = GUICtrlCreateButton("FromFile",610,670,50,20)
$total_queues = GUICtrlCreateLabel("Total Ques:",75,675,100,20)
$num_of_queues_label = GUICtrlCreateLabel("0",140,675,100,20)
$input = GUICtrlCreateInput($scale,350,670,50,20)
$updown = GUICtrlCreateUpdown($input)
$pkts = GUICtrlCreateLabel("Packets Received:",200,675,100,20)
$label = GUICtrlCreateLabel("0",300,675,40,20)
$GRID = GUICtrlCreateGraphic(0, 0, 1024, 768)

init_screen()
GUISetState()
UDPStartup()

$socket = UDPBind($IP_TO_USE, 20000)
If @error Then Exit

$index = 0
$array_count = 0
While 1
    $data = UDPRecv($socket, 2000)
    If $data <> "" Then
        $split_data = StringSplit($data,@LF)
        For $i = 1 To $split_data[0] - 1
            $FloatArray[$index] = $split_data[$i]
            $index += 1
        Next
        
        $glCounter += 1
        GUICtrlSetData($label,$glCounter)
        ContinueLoop
    EndIf
    
    $msg = GUIGetMsg()
    Select
    Case $msg = $init_button
        $index = 0
        $array_count = 0
        GUICtrlDelete($GRID)
        $GRID = GUICtrlCreateGraphic(0, 0, 1024, 768)
        init_screen()
        GUICtrlSetData($label,0)
        GUICtrlSetData($num_of_queues_label,0)
        $glCounter = 0
        GUICtrlSetGraphic($GRID,$GUI_GR_REFRESH)
        WinSetTitle(WinGetTitle($main),"","Grab 'N Draw")
    Case $msg = $Draw_Button
        _DrawAll($FloatArray)
    Case $msg = $File_Read_Button
        $selected = FileOpenDialog("Draw4Real",@DesktopDir,"Que Files (*.que)")
        If Not @error Then
            _FileReadToArray($selected,$FileArray)
            _DrawFromFile($FileArray)
        EndIf
    Case $msg = $File_Write_Button
        $chosen_file = FileSaveDialog("Grab 'N Draw",@DesktopDir,"Queues (*.que)",18,"recv.que")
        If Not @error Then
            If FileExists($chosen_file) Then
                $fhndl = FileOpen($chosen_file,2)
                FileClose($fhndl)
            EndIf
            $fhndl = FileOpen($chosen_file,1)
            
            #comments-start
            For $i = 1 To $split_data[0]
                FileWriteLine($fhndl,"array[" & $array_count & "] = " & $split_data[$i] & ";")
                $array_count += 1
            Next
            FileWriteLine($fhndl,"/////////////////////////")
            $array_count = 0
            #comments-end
            
            For $i = 0 To $index - 1
                FileWriteLine($fhndl,$FloatArray[$i])
                $array_count += 1
            Next
            
            FileClose($fhndl)
            MsgBox(0,"Grab 'N Draw",'Queues written to file: "' & $chosen_file & '"')
        EndIf
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case Else
       ;;; 
    EndSelect
WEnd

Func _DrawFromFile(ByRef $FArray)
    MsgBox(0,"Testing","Called Draw From File")
EndFunc

Func _DrawAll(ByRef $FArray)
    MsgBox(0,"Testing","Called Draw All")
EndFunc

Func _DrawGrid(ByRef $array,$i)
    MsgBox(0,"Testing","Called Draw Grid")
EndFunc  ;==>_DrawGrid

Func GetXCartCoords($x)
    $x = $x + $XScreenSize/2
    return $x
EndFunc

Func GetYCartCoords($y)
    $y = -$y + $YScreenSize/2
    return $y
EndFunc

Func init_screen()
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(0),GetYCartCoords(0))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(0),GetYCartCoords(0))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(1),GetYCartCoords(0))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(1),GetYCartCoords(1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(1),GetYCartCoords(-1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(0),GetYCartCoords(1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(0),GetYCartCoords(-1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(-1),GetYCartCoords(1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(-1),GetYCartCoords(0))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(-1),GetYCartCoords(-1))
EndFunc

Func OnAutoItExit()
    If Not $EARLY_EXIT Then
        UDPCloseSocket($socket)
        UDPShutdown()
    EndIf
EndFunc
Link to comment
Share on other sites

OK...I had to move the Graphic creation before the button, label, etc. creation. This causes my init function to not work however (the buttons and label get covered back up). Also, I cannot update the Graphic while it is disabled (can't see the updates)...any insight or other approaches?

Updated code:

#include <GuiConstants.au3>
#include <File.au3>
#include <Array.au3>
$scale = 30
$XScreenSize = 700
$YScreenSize = 700

Global $glCounter = 0
Global $XABS
Global $YABS
Global $EARLY_EXIT

$GUI_Handle = GuiCreate("Grab 'N Draw", 176, 161,(@DesktopWidth-176)/2, (@DesktopHeight-161)/2)

$Button_1 = GuiCtrlCreateButton("Select", 50, 135, 75, 20)
$List_2 = GuiCtrlCreateList("List3", 10, 20, 160, 110)
$Label_3 = GuiCtrlCreateLabel("Select IP to use:", 45, 5, 80, 15)

$IP_STRING = "|127.0.0.1"
If @IPAddress1 <> "0.0.0.0" And @IPAddress1 <> "127.0.0.1" Then
    $IP_STRING &= "|" & @IPAddress1
EndIf
If @IPAddress2 <> "0.0.0.0" And @IPAddress2 <> "127.0.0.1" Then
    $IP_STRING &= "|" & @IPAddress2
EndIf
If @IPAddress3 <> "0.0.0.0" And @IPAddress3 <> "127.0.0.1" Then
    $IP_STRING &= "|" & @IPAddress3
EndIf
If @IPAddress4 <> "0.0.0.0" And @IPAddress4 <> "127.0.0.1" Then
    $IP_STRING &= "|" & @IPAddress4
EndIf

GUICtrlSetData($List_2,$IP_STRING,"127.0.0.1")

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $Button_1
        $IP_TO_USE = GUICtrlRead($List_2)
        GUISetState(@SW_HIDE,$GUI_Handle)
        ExitLoop
    Case $msg = $GUI_EVENT_CLOSE
        $EARLY_EXIT = 1
        Exit
    Case Else
      ;;;
    EndSelect
WEnd

$nGridSize = 10
Dim $FileArray[1]
Dim $FloatArray[1000000]
$main = GUICreate("Grab 'N Draw", $XScreenSize, $YScreenSize, (@DesktopWidth - $XScreenSize)/2, 1, BitOr($WS_POPUP, $WS_CAPTION, $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_THICKFRAME))
$GRID = GUICtrlCreateGraphic(0, 0, 1024, 768)
GUICtrlSetState($GRID,$GUI_DISABLE)
$init_button = GUICtrlCreateButton("Init",430,670,50,20)
$Draw_Button = GUICtrlCreateButton("Draw",490,670,50,20)
$File_Write_Button = GUICtrlCreateButton("2File",550,670,50,20)
$File_Read_Button = GUICtrlCreateButton("FromFile",610,670,50,20)
$total_queues = GUICtrlCreateLabel("Total Ques:",75,675,100,20)
$num_of_queues_label = GUICtrlCreateLabel("0",140,675,100,20)
$input = GUICtrlCreateInput($scale,350,670,50,20)
$updown = GUICtrlCreateUpdown($input)
$pkts = GUICtrlCreateLabel("Packets Received:",200,675,100,20)
$label = GUICtrlCreateLabel("0",300,675,40,20)

init_screen()
GUISetState()
UDPStartup()

$socket = UDPBind($IP_TO_USE, 20000)
If @error Then Exit

$index = 0
$array_count = 0
While 1
    $data = UDPRecv($socket, 2000)
    If $data <> "" Then
        $split_data = StringSplit($data,@LF)
        For $i = 1 To $split_data[0] - 1
            $FloatArray[$index] = $split_data[$i]
            $index += 1
        Next
        
        $glCounter += 1
        GUICtrlSetData($label,$glCounter)
        ContinueLoop
    EndIf
    
    $msg = GUIGetMsg()
    Select
    Case $msg = $init_button
        $index = 0
        $array_count = 0
        GUICtrlDelete($GRID)
        $GRID = GUICtrlCreateGraphic(0, 0, 1024, 768)
        init_screen()
        GUICtrlSetData($label,0)
        GUICtrlSetData($num_of_queues_label,0)
        $glCounter = 0
        GUICtrlSetGraphic($GRID,$GUI_GR_REFRESH)
        GUICtrlSetState($GRID,$GUI_DISABLE)
        WinSetTitle(WinGetTitle($main),"","Grab 'N Draw")
    Case $msg = $Draw_Button
        _DrawAll($FloatArray)
    Case $msg = $File_Read_Button
        $selected = FileOpenDialog("Draw4Real",@DesktopDir,"Que Files (*.que)")
        If Not @error Then
            _FileReadToArray($selected,$FileArray)
            _DrawFromFile($FileArray)
        EndIf
    Case $msg = $File_Write_Button
        $chosen_file = FileSaveDialog("Grab 'N Draw",@DesktopDir,"Queues (*.que)",18,"recv.que")
        If Not @error Then
            If FileExists($chosen_file) Then
                $fhndl = FileOpen($chosen_file,2)
                FileClose($fhndl)
            EndIf
            $fhndl = FileOpen($chosen_file,1)
            
            #comments-start
            For $i = 1 To $split_data[0]
                FileWriteLine($fhndl,"array[" & $array_count & "] = " & $split_data[$i] & ";")
                $array_count += 1
            Next
            FileWriteLine($fhndl,"/////////////////////////")
            $array_count = 0
            #comments-end
            
            For $i = 0 To $index - 1
                FileWriteLine($fhndl,$FloatArray[$i])
                $array_count += 1
            Next
            
            FileClose($fhndl)
            MsgBox(0,"Grab 'N Draw",'Queues written to file: "' & $chosen_file & '"')
        EndIf
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case Else
      ;;;
    EndSelect
WEnd

Func _DrawFromFile(ByRef $FArray)
    MsgBox(0,"Testing","Called Draw From File")
EndFunc

Func _DrawAll(ByRef $FArray)
    MsgBox(0,"Testing","Called Draw All")
EndFunc

Func _DrawGrid(ByRef $array,$i)
    MsgBox(0,"Testing","Called Draw Grid")
EndFunc ;==>_DrawGrid

Func GetXCartCoords($x)
    $x = $x + $XScreenSize/2
    return $x
EndFunc

Func GetYCartCoords($y)
    $y = -$y + $YScreenSize/2
    return $y
EndFunc

Func init_screen()
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(0),GetYCartCoords(0))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(0),GetYCartCoords(0))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(1),GetYCartCoords(0))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(1),GetYCartCoords(1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(1),GetYCartCoords(-1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(0),GetYCartCoords(1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(0),GetYCartCoords(-1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(-1),GetYCartCoords(1))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(-1),GetYCartCoords(0))
    GUICtrlSetGraphic($GRID, $GUI_GR_PIXEL,GetXCartCoords(-1),GetYCartCoords(-1))
EndFunc

Func OnAutoItExit()
    If Not $EARLY_EXIT Then
        UDPCloseSocket($socket)
        UDPShutdown()
    EndIf
EndFunc
Edited by livewire
Link to comment
Share on other sites

  • Moderators

?????

What State are you in?

8)

Hey, I had been up for 22 hours o:) when I answered that... ;) cut me some slack. :lmao:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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