Jump to content
Sign in to follow this  
Killer

How to remove the displayed portion?

Recommended Posts

Killer

Can someone enlighten me? I am trying to make a simple menus to perform some functions. The result will displayed does not go away when I clicked on a different tab. Can someone help me?

#include <GUIConstants.au3>

;===== my column position setting

;GuiCtrlCreateLabel("Admins right detected", 150, 60, 130, 60) left, top, width, height

$num1=150

$num2=60

$num3=130

$num4=60

;GUICtrlSetState(-1,$GUI_HIDE) clearscreem

GUICreate("My GUI menu",300,200)

Global $defaultstatus = "runas: "&@UserName

Global $status

; MENU

$filemenu = GUICtrlCreateMenu ("&File")

$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)

GUICtrlSetState(-1,$GUI_DEFBUTTON)

$helpmenu = GUICtrlCreateMenu ("?")

$saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)

GUICtrlSetState(-1,$GUI_DISABLE)

$infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

$exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)

$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu

$viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)

GUICtrlSetState(-1,$GUI_CHECKED)

;$okbutton = GUICtrlCreateButton ("OK",50,130,70,20)

GUICtrlSetState(-1,$GUI_FOCUS)

$quitbutton = GUICtrlCreateButton ("Quit",-180,130,70,20) ;button hidden

$statuslabel = GUICtrlCreateLabel ($defaultstatus,0,165,300,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

; TAB

GuiCtrlCreateTab(2, 0, 298, 160)

GuiCtrlCreateTabItem("Network")

;GuiCtrlCreateLabel("Sample Tab with tabItems", 10, 40)

$chkadminbutton = GUICtrlCreateButton ("Check Admin",10,28,80,20)

$chkIPbutton = GUICtrlCreateButton ("Check IP",10,58,80,20)

$chkcomputernamebutton = GUICtrlCreateButton ("Computername",10,88,80,20)

GuiCtrlCreateTabItem("Two")

GuiCtrlCreateLabel("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 4, 60, 298, 160)

$chkadminbutton1 = GUICtrlCreateButton ("Check Admin",10,28,80,20)

$chkIPbutton1 = GUICtrlCreateButton ("Check IP",10,58,80,20)

$chkcomputernamebutton1 = GUICtrlCreateButton ("Computername",10,88,80,20)

GuiCtrlCreateTabItem("Three")

GuiCtrlCreateTabItem("")

GUISetState ()

While 1

$msg = GUIGetMsg()

If $msg = $fileitem Then

$file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")

If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)

EndIf

; If $msg = $viewstatusitem Then

; If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then

; GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)

; GUICtrlSetState($statuslabel,$GUI_HIDE)

; Else

; GUICtrlSetState($viewstatusitem,$GUI_CHECKED)

; GUICtrlSetState($statuslabel,$GUI_SHOW)

; EndIf

; EndIf

If $msg = $GUI_EVENT_CLOSE Or $msg = $quitbutton Or $msg = $exititem Then ExitLoop

If $msg = $infoitem Then Msgbox(0,"Info","Only a test...")

; SYS TOOL TAB

Select

GUICtrlSetState(-1,$GUI_HIDE)

Case $msg = $chkadminbutton

;GuiCtrlCreateLabel("Admins right detected", 150, 60, 130, 60) left, top, leftend, bottomend

If IsAdmin() Then

GuiCtrlCreateLabel("Admins right detected", $num1, $num2, $num3, $num4)

else

GuiCtrlCreateLabel("No admins right detected", $num1, $num2, $num3, $num4)

endif

Case $msg = $chkIPbutton

GuiCtrlCreateLabel(@IPAddress1 & @CRLF, $num1, $num2, $num3, $num4)

Case $msg = $chkcomputernamebutton

GuiCtrlCreateLabel(@ComputerName & @CRLF, $num1, $num2, $num3, $num4)

EndSelect

WEnd

GUIDelete()

Exit

Edited by Killer

Share this post


Link to post
Share on other sites
Killer

Even when I changed it to inputbox, it doesn't go away when I click on Tab 2.

Share this post


Link to post
Share on other sites
Amen

When you create a conrtol use $Variable_1=Guicreate...

The $Variable_1 stores the Id of that object.

In this id you will update your data.Dont recreate the oblject beause it will be

create on the Last Tabmenu you've created.

Share this post


Link to post
Share on other sites
Killer

When you create a conrtol use $Variable_1=Guicreate...

The $Variable_1 stores the Id of that object.

In this id you will update your data.Dont recreate the oblject beause it will be

create on the Last Tabmenu you've created.

<{POST_SNAPBACK}>

Can you modify my code to show me? I really don't understand and your codes doesn't seems to work. :whistle:

Share this post


Link to post
Share on other sites
Amen

Here it is

#include <GUIConstants.au3>

;===== my column position setting
;GuiCtrlCreateLabel("Admins right detected", 150, 60, 130, 60) left, top, width, height
$num1=150
$num2=60
$num3=130
$num4=60

;GUICtrlSetState(-1,$GUI_HIDE) clearscreem



$Maingui=GUICreate("My GUI menu",300,200)

Global $defaultstatus = "runas: "&@UserName
Global $status

; MENU 
$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu ("?")
$saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
GUICtrlSetState(-1,$GUI_DISABLE)
$infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)
$exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2); create a separator line

$viewmenu = GUICtrlCreateMenu("View",-1,1); is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
GUICtrlSetState(-1,$GUI_CHECKED)
;$okbutton = GUICtrlCreateButton ("OK",50,130,70,20)
GUICtrlSetState(-1,$GUI_FOCUS)
$quitbutton = GUICtrlCreateButton ("Quit",-180,130,70,20);button hidden

$statuslabel = GUICtrlCreateLabel ($defaultstatus,0,165,300,16,BitOr($SS_SIMPLE,$SS_SUNKEN))


; TAB
GuiCtrlCreateTab(2, 0, 298, 160)
GuiCtrlCreateTabItem("Network")
;GuiCtrlCreateLabel("Sample Tab with tabItems", 10, 40)
$chkadminbutton = GUICtrlCreateButton ("Check Admin",10,28,80,20)
$chkIPbutton = GUICtrlCreateButton ("Check IP",10,58,80,20)
$chkcomputernamebutton = GUICtrlCreateButton ("Computername",10,88,80,20)
$Label_1= GuiCtrlCreateLabel("", $num1, $num2, $num3, $num4)

GuiCtrlCreateTabItem("Two")
$chkadminbutton1 = GUICtrlCreateButton ("Check Admin",10,28,80,20)
$chkIPbutton1 = GUICtrlCreateButton ("Check IP",10,58,80,20)
$chkcomputernamebutton1 = GUICtrlCreateButton ("Computername",10,88,80,20)
$Label_2=GuiCtrlCreateLabel("",  $num1, $num2, $num3, $num4)


GuiCtrlCreateTabItem("Three")
$Label_3=GuiCtrlCreateLabel("", $num1, $num2, $num3, $num4)
GuiCtrlCreateTabItem("")


GUISetState ()

While 1
$msg = GUIGetMsg()

If $msg = $fileitem Then
$file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)
EndIf 
; If $msg = $viewstatusitem Then
; If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
; GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
; GUICtrlSetState($statuslabel,$GUI_HIDE)
; Else
; GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
; GUICtrlSetState($statuslabel,$GUI_SHOW)
; EndIf
; EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $quitbutton Or $msg = $exititem Then ExitLoop
If $msg = $infoitem Then Msgbox(0,"Info","Only a test...")

; SYS TOOL TAB
Select
;GUICtrlSetState($Maingui,$GUI_HIDE)
Case $msg = $chkadminbutton
;GuiCtrlCreateLabel("Admins right detected", 150, 60, 130, 60) left, top, leftend, bottomend

If IsAdmin() Then 
    GUICtrlSetData($Label_1,"Admins right detected")
else
    GUICtrlSetData($Label_1,"No Admins right detected")
endif

Case $msg = $chkIPbutton
      GUICtrlSetData($Label_1,@IPAddress1)
Case $msg = $chkcomputernamebutton
GUICtrlSetData($Label_1,@ComputerName)


EndSelect
WEnd
GUIDelete()

Exit
Edited by Amen

Share this post


Link to post
Share on other sites
Killer

Thanks for helping out a newbie. :whistle::dance:

Share this post


Link to post
Share on other sites
Amen

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  

×