Sign in to follow this  
Followers 0
ptrex

Button jumps when GUI is maximized ?

4 posts in this topic

When you run this prog. and maximize the GUI.

Then click the button with the ICON, the button jumps to the right ??

This is not happening when the GUI is not maximized.

;--------------------------------------------
;FireWall Log Analyzer V0.6
;
;My first AutoIT project and first programming,
;with a little help of my friends, (AutoIT Forum)
;PTRex 29/06/05
;
;Completed: 
;# Line Selection
;Auto Refresh
;Check status FW On or Off
;Show Exception Apps & Open Ports
;Drag&Drop columns + Sort data
;
;To Do :
;Check status Logging On or Off
;Include Whois function
;FW on Remote Computer 
;
;---------------------------------------------

; Includes
#include <GuiConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>

; Declare Vars
Dim $Font ="Arial Bold"
Dim $OS = @OSVersion
Dim $SP = @OSServicePack
Dim $Host = "Localhost"
Dim $aArray
Dim $avArray[14]
Dim $datacol
Dim $combo2Item
Dim $button_ON , $Label_ON
Dim $IP, $Line
Dim $DataListApps , $DataListPorts


; Options
;opt("GUICoordMode",2)
;Opt("GUIResizeMode", 1)
;Opt("GUIOnEventMode", 1)

; Main GUI
;---------
$Gui = GuiCreate("Firewall Log Analyser for XP v0.6", 952, 571,(@DesktopWidth-797)/2, (@DesktopHeight-571)/2 , _ 
$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Tab=GUICtrlCreateTab (8,30, 936,520)
GUICtrlSetResizing ($Tab,$GUI_DOCKAUTO)

; Tab1
$Tab1=GUICtrlCreateTabitem ("LogData")
$ListView = GUICtrlCreateListView("date|time|action| protocol| src-ip| dst-ip| _
src-port| dst-port| size| tcpflags|tcpsyn| tcpack| tcpwin| icmptype", 10, 70, 930, 474,-1,$LVS_EX_HEADERDRAGDROP);Drag&Drop Columns
GUICtrlSetResizing ($Listview,$GUI_DOCKAUTO)

$Tab1combo=GUICtrlCreateCombo ("# Lines", 10,8,60,40)
GUICtrlSetData(-1,"10|50|100|500|1000|2000|3000|4000", "50"); default 50
GUICtrlCreateLabel("Select # of lines",80,12)

$Tab2combo=GUICtrlCreateCombo ("Seconds", 200,8)
GUICtrlSetData(-1,"1|5|10|20|30")               ; default "" 
GUICtrlCreateLabel("Auto Refresh",290,12)

$Refrech = GuiCtrlCreateButton("Refresh", 852, 10, 90, 30)

$Button_ON = GUICtrlCreateButton ("Status", 380,5,40,40, $BS_ICON)
Status();check status of FW set Icon and Label

$Whois = GuiCtrlCreateButton("Whois", 650, 10, 90, 30)

; Tab2
$Tab2=GUICtrlCreateTabitem ( "Firewall Config")

$Listbox1 = GUICtrlCreateList("", 10, 70, 930, 225)
GUICtrlSetResizing ($Listview,$GUI_DOCKAUTO)
GUICtrlCreateLabel("Applications allowed : ",15,55)
GUICtrlSetColor(-1,0xff0000)
GUICtrlSetFont (-1,7.5, 100, 4, $font)
Open_apps()

$Listbox2 = GUICtrlCreateList("", 10, 300, 930, 225)
GUICtrlSetResizing ($Listview,$GUI_DOCKAUTO)
GUICtrlCreateLabel("Ports allowed : ",15,285)
GUICtrlSetColor(-1,0xff0000)
GUICtrlSetFont (-1,7.5, 100, 4, $font)

$Link = GuiCtrlCreateLabel("Click here for more info : Port Database", 200, 285, 290, 20)
GUICtrlSetColor ( -1, 0x0000ff)
GUICtrlSetFont (-1, -1 , 400 , 6 )
GUICtrlSetCursor ( -1, 0 )
Open_ports()

; Error checking : Test OS = XP/SP2 
;----------------------------------
If $OS <> "Win_XP"  Then
    MsgBox (0, "Your OS is not XP : ", $OS, 3)
    ElseIf  $SP <> "Service Pack 2"  Then
    MsgBox (0, "Your OS is not on SP2 : ", $SP, 3)
Else; Open the file and read data
$filename = "C:\WINDOWS\pfirewall.log" 
EndIf

Getdata()

GuiSetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ]; Used by Sort CLick Header

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Tab1Combo 
        GUICtrlRead($Tab1combo)
    Case $msg = $Tab2Combo 
        Do
         AutoRefresh()
         sleep  ($combo2Item * 1000)
         DeleteList()
         Getdata()
         Status()
         Until $combo2Item = 0 Or $msg = $GUI_EVENT_CLOSE
    Case $msg = $Button_ON
         GUICtrlDelete ($label_ON)
         status()
     Case $msg = $Whois
         ReadLine()
         If ($Line <> $LV_ERR) Then
                MsgBox(0, "Source IP", $IP,5)
            Else
                MsgBox(0, "Retry Again", "Nothing Selected",5)
        EndIf
    Case $msg = $listview ; sort the list by the column header clicked on
    _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))  
    Case $msg= $Link
        run("C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.portsdb.org/bin/portsdb.cgi","",@SW_MAXIMIZE)   
    Case else
        If $msg = $Refrech Then
        DeleteList()
        Getdata()
        Status()
    EndIf
    EndSelect
WEnd
Exit


; Functions
;----------
Func Getdata()
$file = FileOpen($filename,0)
; Check if file opened for reading OK
    If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file. Make sure that your Firewall Logging is turned on !!")
        Exit
    EndIf
    
$combo1Item=Number(GUICtrlRead($Tab1combo));# of lines selected

; Read in lines of text until the EOF is reached
$aArray = StringSplit(FileRead($file,FileGetSize($filename)),@LF)
; Ubound read lines bottom up, to # of lines
 for $i = (UBound($aArray) - 2) to $i+1-$combo1Item Step -1
; Split lines in 10 dimensions
    $string = StringSplit($aArray[$i], " ", 0)
; Assign each dimension to a new Array
    $avArray[0] = $string[1]
    $avArray[1] = $string[2]
    $avArray[2] = $string[3]
    $avArray[3] = $string[4]
    $avArray[4] = $string[5]
    $avArray[5] = $string[6]
    $avArray[6] = $string[7]
    $avArray[7] = $string[8]
    $avArray[8] = $string[9]
    $avArray[9] = $string[10]
    $avArray[10] = $string[11]
    $avArray[11] = $string[12]
    $avArray[12] = $string[13]
; Create string for displaying in ListView
    $data=$avArray[0]&"|"&$avArray[1]&"|"&$avArray[2]&"|"&$avArray[3]&"|"&$avArray[4]&"|"&$avArray[5]&"|"_
    &$avArray[6]&"|"&$avArray[7]&"|"&$avArray[8]&"|"&$avArray[9]&$avArray[10]&"|"&$avArray[11]&"|"&$avArray[12]&"|"&$avArray[13]
    $dataCol=GUICtrlCreateListViewItem($data,$listview)
Next
FileClose($file)
EndFunc
    
Func DeleteList()
    _GUICtrlListViewDeleteAllItems ($listview)  
EndFunc

Func AutoRefresh()
    $combo2Item=Number(GUICtrlRead($Tab2combo)); # of seconds
EndFunc

Func Status(); Check Firewell status and set Button + Label
GUICtrlDelete ($Label_ON)
GUICtrlDelete ($button_ON)
    $on_off = RegRead("HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall")
$button_ON = GUICtrlCreateButton ("Status", 380,5,40,40, $BS_ICON)
If dec($on_off) = 1 Then
GUICtrlSetImage (-1, "xpsp2res.dll",71)
    Else 
        GUICtrlSetImage (-1, "xpsp2res.dll",72)
Endif
IF dec($on_off) = 1 then 
$Label_ON = GUICtrlCreateLabel("Your Firewall is Enabled",430,12)
    Else 
        $Label_ON = GUICtrlCreateLabel("Your Firewall is Disabled",430,12)
Endif
EndFunc

Func ReadLine();Read selected item
        $Line =  _GUICtrlListViewGetItemText ($listview)
        $IP = StringMid($Line,30,11)
EndFunc
    
Func Open_Apps()
    $i = 1
    Do
    $Apps = RegEnumVal("HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\AuthorizedApplications\List", $i)
    $i = $i + 1
    $DataListApps = $DatalistApps & $Apps & "|"
    Until $Apps =""
    GUICtrlSetData($listbox1,$DataListApps)
EndFunc 

Func Open_Ports()
    $i = 1
    Do
    $Ports = RegEnumVal("HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\GloballyOpenPorts\List", $i)
    $i = $i + 1
    $DataListPorts =  $datalistPorts & $Ports & "|"
    Until $Ports =""
    GUICtrlSetData($Listbox2,$DataListPorts)
EndFunc

Any idea why ?

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

Extra info:

Probably it has something to do with the relative position of the button related to the main GUI.

When the GUI is maximized the positions change. Is there a function that avoids this behaviour ?

<{POST_SNAPBACK}>

Yes, I think it's called GUICtrlSetResizing or something like that. You need to dock the control's location and/or size to get the behavior you want.

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