Jump to content

how highlight control when selecting tab ?


dirty
 Share

Recommended Posts

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#Include <GuiListView.au3>
$WindowTitle = "Title"
$Gui = GUICreate ($WindowTitle,1024,768)
GUICtrlCreateTab (0,0,1024,768)
$CreateTab = GUICtrlCreateTabItem ("Create")
GUICtrlCreateGroup ("Name your Project",5,25,240,65)
$CreateNameInput = GUICtrlCreateInput ("__Name....",10,40,190,20)
GUICtrlSetTip ($CreateNameInput,"This will be your Project Name","Information",1)
$CreateNumberCombo = GUICtrlCreateCombo ("",10,60,190,20)
GUICtrlSetData ($CreateNumberCombo,"Select Project number pattern|0123456789","Select Project number pattern")
$CreateNameButton = GUICtrlCreateButton ("Create",200,40,40,40)
GUICtrlCreateTabItem ("")
$DecontamTAB = GUICtrlCreateTabItem ("Decontam")
GUICtrlCreateGroup ("Scan your Project",5,25,240,40)
$DeconScanInput = GUICtrlCreateInput ("__Scan....",10,40,190,20)
GUICtrlSetTip ($DeconScanInput,"You can select this field and scan an item or you can manualy enter whole number.","Information",1)
$AddToDecontamListButton = GUICtrlCreateButton ("Add",200,40,40,20)
GUICtrlCreateTabItem ("")
$AssemblyTAB = GUICtrlCreateTabItem ("Assembly")
GUICtrlCreateTabItem ("")
$SterilizationTAB = GUICtrlCreateTabItem ("Sterilization")
GUICtrlCreateTabItem ("")
$CenterCoreTAB = GUICtrlCreateTabItem ("Center Core")
GUICtrlCreateTabItem ("")
$CaseCartTAB = GUICtrlCreateTabItem ("Case Cart")
GUICtrlCreateTabItem ("")
$ORTAB = GUICtrlCreateTabItem ("OR")
GUICtrlCreateTabItem ("")
IniWrite ("SetNames.ini","All","","")
$ListView = GUICtrlCreateListView ("Project Name|Project number|Location|Quantity|",10,110,350,200)
GUISetState (@SW_SHOW,$Gui)
_GUICtrlListView_RegisterSortCallBack($ListView)
Global $NumberFromINI,$NameFromINI
While 1
$MSG = GUIGetMsg()
If $MSG = $GUI_EVENT_CLOSE Then ExitLoop
If $MSG = $CreateTab Then
  GUICtrlSetState ($CreateNameInput,$GUI_FOCUS)
  ControlClick ($WindowTitle,"","Edit1","primary",2)
EndIf
If $MSG = $CreateNameButton Then
  $CreateName = GUICtrlRead ($CreateNameInput)
  $CreateNumber = GUICtrlRead ($CreateNumberCombo)
  IniWrite ("SetNames.ini","All",$CreateNumber,$CreateName)
EndIf
If $MSG = $DecontamTAB Then
  GUICtrlSetState ($DeconScanInput,$GUI_FOCUS)
  ControlClick ($WindowTitle,"","Edit3","primary",2)
EndIf
If $MSG = $AddToDecontamListButton Then
  $ReadDeconScanInput = GUICtrlRead ($DeconScanInput)
  If $ReadDeconScanInput  > "" Then
   FindAssociatedName()
   GUICtrlCreateListViewItem ($NameFromINI & '|' & $NumberFromINI,$ListView)
   MsgBox(0,'',$NumberFromINI)
   MsgBox(0,'',$NameFromINI)
  Else
   MsgBox(0,'Error','dont use blank')
  EndIf
EndIf
WEnd
Func FindAssociatedName()
$NumberFromINI = IniRead ("SetNames.ini","All",$ReadDeconScanInput,"No Project associated with this number.")
$NameFromINI = IniRead ("SetNames.ini","All",$ReadDeconScanInput,"No Project associated with this number.")
EndFunc

i am trying to highlight input control and double click it so that all text in it is highlighted ready for user input.

If $MSG = $CreateTab Then
  GUICtrlSetState ($CreateNameInput,$GUI_FOCUS)
  ControlClick ($WindowTitle,"","Edit1","primary",2)
EndIf

is not working.

am i doing it wrong ?

thanks

Edited by dirty
Link to comment
Share on other sites

  • Moderators

dirty,

am i doing it wrong ?

Yes! :rip:

Firstly you will never detect the click on the TabItem - you need to detect the click on the main Tab control and then use GUICtrlRead to find out which TabItem has been selected. Look at this:

While 1
    $MSG = GUIGetMsg()
    If $MSG = $GUI_EVENT_CLOSE Then ExitLoop
    If $MSG = $Tab Then              ; Was a tab control header clicked?
        Switch GUICtrlRead($Tab, 1)  ; Here we find out which one - using the advanced parameter returns the ControlID
            Case $CreateTab          ; And so we can now check if it was the Create TabItem

You will have to adjust the code so that all the TabItems are included in the Switch structure. :oops:

Now we have correctly identified the TabItem we can select the text in the input - like this:

Case $CreateTab
                GUICtrlSetState($CreateNameInput, $GUI_FOCUS) ; Focus the input
                Send("+{END}")                                ; Send Shift-End to highlight the content

All clear? :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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