Jump to content

Read treeview Items in case of MultiGUI


Recommended Posts

Here's my code, but I cant read TreeView Items

Could anyone help me!!!

#include <GuiEdit.au3>
#include <array.au3>
#include <file.au3>
#Include <String.au3>
#include <Misc.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GUIListViewEx.au3>
#include <Crypt.au3>
#include <ComboConstants.au3>
#include <GuiTreeView.au3>

Global $Paused
HotKeySet("`", "TogglePause")
HotKeySet("^q", "Terminate")

opt("WinTitleMatchMode", 2)
opt('MouseCoordMode', 2)
opt('PixelCoordMode', 2)

;If UBound(ProcessList("autoit3.exe")) > 2 Then
 ;  MsgBox(262208, "* NOTE * ", "Welcome to AutoIt 1-2-3 was already running  ", 5)
  ; Exit
;EndIf
#EndRegion

#Region ### DECLARE VAR ###
$iEditMode = 0
Local $ImportDrugGUI = 9999, $AddDrug, $Clear, $ImgPathBrowse, $ImgPathIp, $ImgPathLabel, $DropDownDrugType, $DrugTypeIp, $DrugNameIp, $ChongChiDinhIp, $ThanTrongIp, $LieuLuongIp, $CachDungIp, $PriceIp, $ChietKhauIp, $ImgPathIp, $TuongTacThuocIp, $ChiDinhIp
Local $GuideGui = 9999, $PreviousBtn, $NextBtn
$DataLabel = ''

$DrugDataPath = @ScriptDir & '\Data\DrugDatabase.txt'
$TreeDataPath = @ScriptDir & '\Data\TreeData.txt'

#EndRegion
;-------------------------------------------------------
#Region ### START Koda GUI section ### Form=f:\autoit\gui builder\koda_1.7.3.0\forms\dontuvan.kxf
$Form1 = GUICreate("PRESCRIPTION TOOLS", 996, 443, 316, 120)
$Group1 = GUICtrlCreateGroup("KE DON TU VAN", 3, 3, 403, 433)
$Label1 = GUICtrlCreateLabel("Patient's Name", 15, 27, 75, 17)
$Label2 = GUICtrlCreateLabel("Birth", 15, 48, 25, 17)
$Label3 = GUICtrlCreateLabel("Sex", 90, 48, 22, 17)
$Label4 = GUICtrlCreateLabel("Diagnosis", 150, 48, 50, 17)
$Label5 = GUICtrlCreateLabel("Drug", 51, 99, 27, 17)
$Label6 = GUICtrlCreateLabel("Amount", 153, 99, 40, 17)
$Label7 = GUICtrlCreateLabel("usage", 288, 99, 33, 17)
$TenBNIp = GUICtrlCreateInput("", 93, 24, 304, 21)
$NamSinhIp = GUICtrlCreateInput("", 45, 45, 40, 21)
$GioiTinhIp = GUICtrlCreateInput("", 117, 45, 31, 21)
$ChanDoanIp = GUICtrlCreateInput("", 204, 45, 193, 21)
$Label8 = GUICtrlCreateLabel("PRESCRIPTION", 153, 75, 96, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$TenThuoc1Ip = GUICtrlCreateInput("", 18, 120, 115, 21)
$SLThuoc1Ip = GUICtrlCreateInput("", 147, 120, 52, 21)
$CachSDThuoc1Ip = GUICtrlCreateInput("", 213, 120, 187, 21)
$TenThuoc2Ip = GUICtrlCreateInput("", 18, 150, 115, 21)
$SLThuoc2Ip = GUICtrlCreateInput("", 147, 150, 52, 21)
$CachSDThuoc2Ip = GUICtrlCreateInput("", 213, 150, 187, 21)
$TenThuoc3Ip = GUICtrlCreateInput("", 18, 180, 115, 21)
$SLThuoc3Ip = GUICtrlCreateInput("", 147, 180, 52, 21)
$CachSDThuoc3Ip = GUICtrlCreateInput("", 213, 180, 187, 21)
$TenThuoc4Ip = GUICtrlCreateInput("", 18, 210, 115, 21)
$SLThuoc4Ip = GUICtrlCreateInput("", 147, 210, 52, 21)
$CachSDThuoc4Ip = GUICtrlCreateInput("", 213, 210, 187, 21)
$TenThuoc5Ip = GUICtrlCreateInput("", 18, 240, 115, 21)
$SLThuoc5Ip = GUICtrlCreateInput("", 147, 240, 52, 21)
$CachSDThuoc5Ip = GUICtrlCreateInput("", 213, 240, 187, 21)
$StartCalc = GUICtrlCreateButton("Cost", 108, 261, 52, 25)
$Label9 = GUICtrlCreateLabel("Price: xxxxx VND", 189, 267, 208, 17)
$Group3 = GUICtrlCreateGroup("Statistics", 12, 285, 391, 145)
$StartThongKe = GUICtrlCreateButton("Month Statistics", 108, 294, 91, 19, $BS_MULTILINE)
$ThongKeThangLV = GUICtrlCreateListView("TT|Drug|Amount|Cost", 21, 315, 376, 106)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 30)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50)
$DiscountCost = GUICtrlCreateLabel("Discount: xxxxx VND", 210, 297, 187, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Print = GUICtrlCreateButton("Print", 48, 261, 52, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("DRUG DATABASE", 414, 3, 574, 433)
$DrugTreeView = GUICtrlCreateTreeView(426, 21, 244, 409)
$StartImportDrug = GUICtrlCreateButton("IMPORT DRUG", 678, 12, 88, 28)
$TenThuocDT = GUICtrlCreateLabel("DRUGNAME", 679, 48, 304, 17)
$CCDDT = GUICtrlCreateLabel("SPECIAL PRECAUTIONS", 679, 150, 303, 59)
$ThanTrongDT = GUICtrlCreateLabel("SIDE EFFECTS", 679, 216, 302, 59)
$LieuLuongDT = GUICtrlCreateLabel("Dosage", 679, 345, 302, 29)
$CachDungDT = GUICtrlCreateLabel("Administration", 679, 378, 302, 29)
$ShowGuide = GUICtrlCreateButton("SHOW DRUG GUIDE", 867, 12, 112, 28)
$GiaDT = GUICtrlCreateLabel("Price (Unit)", 679, 411, 131, 17)
$ChietKhauDT = GUICtrlCreateLabel("Chiet khau %", 835, 411, 147, 17)
$ChiDinhDT = GUICtrlCreateLabel("INDICATIONS", 679, 70, 303, 71)
$Label10 = GUICtrlCreateLabel("DRUG INTERACTIONS", 679, 281, 303, 56)
$DelDrug = GUICtrlCreateButton("DELETE DRUG", 772, 11, 88, 28)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

#Region ### UPDATE THÔNG TIN ######################
$LVIdx = _GUIListViewEx_Init($ThongKeThangLV, '', 0, Default, Default, 1+2+4)
_GUIListViewEx_MsgRegister()

local $DrugTypeArr
_FileReadToArray($TreeDataPath, $DrugTypeArr, Default, '|')
_ArrayDelete($DrugTypeArr, 0)
;~ _ArrayDisplay($Drugtypearr)

_GUICtrlTreeView_BeginUpdate($DrugTreeView)

$CurrentItem = ''
for $a = 0 to UBound($DrugTypeArr) - 1
   if $DrugTypeArr[$a][1] <> '' then
      $DrugTypeArr[$a][0] = _GUICtrlTreeView_Add($DrugTreeView, 0, $DrugTypeArr[$a][1] )
      $CurrentItem = $DrugTypeArr[$a][0]
   Else
      if $DrugTypeArr[$a][2] <> '' then
         $DrugTypeArr[$a][0] = _GUICtrlTreeView_AddChild($DrugTreeView, $CurrentItem, $DrugTypeArr[$a][2] )
      Else
         $CurrentItem = ''
      EndIf
   EndIf


Next
_GUICtrlTreeView_EndUpdate($DrugTreeView)

$ListLabel = ''
for $a0 = 0 to UBound($DrugTypeArr) - 1
   if $DrugTypeArr[$a0][2] <> '' then
      $ListLabel &= $DrugTypeArr[$a0][2] & '|'
   EndIf
Next
$ListLabel = StringRegExpReplace($ListLabel, '|$', '', 0)
#EndRegion
;-------------------------------------------------------

While 1
    $nMsg = GUIGetMsg(1)

    Switch $nMsg[1]
    case $Form1
       Switch $nMsg[0]
         Case $GUI_EVENT_CLOSE
            Exit
         case GUICtrlRead($DrugTreeView)
            $ID = GUICtrlRead($DrugTreeView)
            MsgBox(0, '', $ID)

         case $StartImportDrug
            _CreateImportDrugGui()
            GUICtrlSetState($StartImportDrug, $GUI_DISABLE)
         case $ShowGuide
            _CreateShowDrugGui()
            GUICtrlSetState($ShowGuide, $GUI_DISABLE)
         case $StartCalc

         case $StartThongKe

         case $Print

         case $DelDrug

      EndSwitch

    case $IMPORTDRUGGUI
      Switch $nMsg[0]
         case $GUI_EVENT_CLOSE
            GUIDelete($IMPORTDRUGGUI)
            GUICtrlSetState($StartImportDrug, $GUI_ENABLE)
         case $AddDrug
            _AddToDrugDatabase()
         case $Clear
            _ClearAddDrug()
         case $ImgPathBrowse
            _ImgPathBrowse()
         case $DropDownDrugType
            $sName = GUICtrlRead($DropDownDrugType)
            $DataLabel &= $sName & ', '
            GUICtrlSetData($DrugTypeIp, $DataLabel)
      EndSwitch

    case $GUIDEGUI
      Switch $nMsg[0]
         case $GUI_EVENT_CLOSE
            GUIDelete($GUIDEGUI)
            GUICtrlSetState($ShowGuide, $GUI_ENABLE)
         case $PreviousBtn

         case $NextBtn

      EndSwitch


    EndSwitch
    _GUIListViewEx_EditOnClick($iEditMode)

WEnd
Func _CreateImportDrugGui()
$IMPORTDRUGGUI = GUICreate("IMPORTDRUGGUI", 326, 522, 530, 120)
$Label00 = GUICtrlCreateLabel("Drug Name", 3, 6, 58, 17)
$DrugNameIp = GUICtrlCreateInput("", 90, 3, 229, 21)
$Label0 = GUICtrlCreateLabel("Drug Type", 3, 30, 76, 19)
$DrugTypeIp = GUICtrlCreateInput("", 90, 27, 88, 21)
$DropDownDrugType = GUICtrlCreateCombo("--- Select Drug Type ---", 180, 27, 139, 25)
$ChiDinhIp = GUICtrlCreateEdit("", 90, 54, 229, 70)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("Special Precautions", 3, 131, 84, 57)
$ChongChiDinhIp = GUICtrlCreateEdit("", 90, 128, 229, 74)
GUICtrlSetData(-1, "")
$Label2 = GUICtrlCreateLabel("Side Effects", 3, 225, 60, 17)
$ThanTrongIp = GUICtrlCreateEdit("", 90, 207, 229, 70)
GUICtrlSetData(-1, "")
$Label3 = GUICtrlCreateLabel("Dosage", 3, 291, 53, 17)
$LieuLuongIp = GUICtrlCreateEdit("", 90, 282, 229, 52)
GUICtrlSetData(-1, "")
$Label4 = GUICtrlCreateLabel("Administration", 3, 345, 80, 26)
$CachDungIp = GUICtrlCreateEdit("", 91, 336, 229, 49)
GUICtrlSetData(-1, "")
$TuongTacThuocIp = GUICtrlCreateEdit("", 93, 390, 229, 46)
$Label5 = GUICtrlCreateLabel("Price/Unit", 3, 441, 67, 17)
$PriceIp = GUICtrlCreateInput("", 90, 438, 73, 21)
$Label6 = GUICtrlCreateLabel("Chiet khau %", 177, 441, 66, 17)
$ChietKhauIp = GUICtrlCreateInput("", 249, 438, 73, 21)
$ImgPathIp = GUICtrlCreateInput("", 90, 463, 203, 21)
$ImgPathBrowse = GUICtrlCreateButton("...", 298, 466, 25, 20)
$ImgPathLabel = GUICtrlCreateLabel("Img Path", 3, 469, 85, 14)
$AddDrug = GUICtrlCreateButton("ADD", 87, 488, 70, 31)
$CLEAR = GUICtrlCreateButton("CLEAR", 170, 488, 70, 31)
$Label7 = GUICtrlCreateLabel("Indications", 3, 75, 55, 17)
$Label8 = GUICtrlCreateLabel("Drug Interactions", 3, 393, 85, 17)
GUISetState(@SW_SHOW)

   GUICtrlSetData($DropDownDrugType, $ListLabel, ' --- Select Label --- ')
EndFunc

Func _CreateShowDrugGui()
   $GuideGui  = GUICreate("Form2", 495, 662, 564, 28)
   $Pic1 = GUICtrlCreatePic("", 9, 9, 475, 616)
   $PageStatus = GUICtrlCreateLabel("Page x of x", 99, 636, 126, 17)
   $PreviousBtn = GUICtrlCreateButton("Previous", 237, 630, 58, 28)
   $NextBtn = GUICtrlCreateButton("Next", 303, 629, 58, 28)
   GUISetState(@SW_SHOW)

EndFunc

Func _StringSplitTo2D($String, $sSeparator = @TAB)
    Local $aRows = StringSplit(StringStripCR($String), @LF), $aColumns, $aResult[$aRows[0]][1]
    For $iRow = 1 To $aRows[0]
        $aColumns = StringSplit($aRows[$iRow], $sSeparator)
        If $aColumns[0] > UBound($aResult, 2) Then ReDim $aResult[$aRows[0]][$aColumns[0]]
        For $iColumn = 1 To $aColumns[0]
            $aResult[$iRow - 1][$iColumn - 1] = $aColumns[$iColumn]
        Next
    Next
    Return $aResult
EndFunc

;--------------------------------------------------------

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(200)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

 

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