Sign in to follow this  
Followers 0
mini

[SOLVE] HELP to solve a Hotkey question

7 posts in this topic

#1 ·  Posted (edited)

Hey guys, on my program i have to make a search, but 3 edit box aren't felled in with the stored information.

My problem is that I have 2 ways of searching my stored DATA.

1st DATA stored is the Edit Box DATA.

Case $Procurar
            _Check4Procurar()
            $sText = StringReplace(IniRead($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "DB Observações", "Não disponivel"), "\n", @CRLF)
            GUICtrlSetData($aEdit[0][0], $sText)

2nd DATA stored is the Input DATA.

GUICtrlSetData ($InputNome, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Nome", "Não disponivel"))

Well, the 2nd one loads the info with hotkey, but all the info on the Edit Box's, they are not "read" with the HotKeySet.

Im not figuring out how to make it load the DATA with the HotKeySet.

Any suggestion??

Edited by mini

Share this post


Link to post
Share on other sites



Hey guys, on my program i have to make a search, but 3 edit box aren't felled in with the stored information.

My problem is that I have 2 ways of searching my stored DATA.

1st DATA stored is the Edit Box DATA.

Case $Procurar
 _Check4Procurar()
            $sText = StringReplace(IniRead($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "DB Observações", "Não disponivel"), "\n", @CRLF)
 GUICtrlSetData($aEdit[0][0], $sText)

2nd DATA stored is the Input DATA.

GUICtrlSetData ($InputNome, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Nome", "Não disponivel"))

Well, the 2nd one loads the info with hotkey, but all the info on the Edit Box's, they are not "read" with the HotKeySet.

Im not figuring out how to make it load the DATA with the HotKeySet.

Any suggestion??

You need to give more information and preferably a small example which shows the problem. We don't know what $InputNom is for example or what is in $InputIDCB.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

You need to give more information and preferably a small example which shows the problem. We don't know what $InputNom is for example or what is in $InputIDCB.

Sorry i didn't made it earlier.

Here's half my code, but with the problem i have...

The button Search, feel all the info i need, but the HotKey "ALT+q", dont feel in the EditBox.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
HotKeySet("!q","_Check4Search")
;<==================================================================================
; Set the various styles we need
Global $iBase_Style = BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL)
Global $iHoriz_Style = BitOR($ES_WANTRETURN, $ES_AUTOHSCROLL, $WS_HSCROLL)
Global $iVert_Style = BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $WS_VSCROLL)
Global $iBoth_Style = BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $WS_HSCROLL, $WS_VSCROLL)
;<==================================================================================
; How many edits?
Global $iNum_Edits = 5
; Set up array to hold the variables for each Edit
; [0] = ControlID
; [1] = width
; [2] = height
; [3[ = horizontal scroll state
; [4] = vertical scroll state of each edit
;<==================================================================================

Global $aEdit[$iNum_Edits][5]
; Set all scroll states to False
For $i = 0 To $iNum_Edits - 1
    $aEdit[$i][3] = False
    $aEdit[$i][4] = False
Next
;<==================================================================================
;Main.
$hGUI = GUICreate("Base de Contactos BES", 537, 451)
GUISetBkColor(0x000000)
$sINI = @ScriptDir & "\"
$PageControl1 = GUICtrlCreateTab(10, 10, 516, 432)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
;BackGround
;$pic = GuiCtrlCreatePic(@ScriptDir & "\BES" & "\bes.jpg" ,0, 32, 537, 451)
;GUICtrlSetState(-1,$GUI_DISABLE)
;$pic = GuiCtrlCreatePic(@ScriptDir & "\BES" & "\bkp.jpg" ,441 , 9, 166, 23)
;GUICtrlSetState(-1,$GUI_DISABLE)
;Buttons
$Save = GUICtrlCreateButton("&Save", 24, 400, 75, 25)
GUICtrlSetCursor (-1, 0)

;<==================================================================================

;TabSheets
$TabSheet1 = GUICtrlCreateTabItem("Dados Basicos")
; Fill array with data for this Edit
$aEdit[0][1] = 289
$aEdit[0][2] = 377
$aEdit[0][0] = GUICtrlCreateEdit("", 216, 48, $aEdit[0][1], $aEdit[0][2], $iBase_Style)
;<========
;Input
$InputIDCB = GUICtrlCreateInput("IDCB", 24, 88, 169, 21)
;Buttons
$Search = GUICtrlCreateButton("Search", 24, 48, 75, 25)
GUICtrlSetCursor (-1, 0)
;Input
$InputNome = GUICtrlCreateInput("", 24, 144, 169, 21)
$InputContacto = GUICtrlCreateInput("", 24, 200, 169, 21)
$InputEmail = GUICtrlCreateInput("", 24, 256, 169, 21)
$InputUltimoContacto = GUICtrlCreateInput("", 24, 312, 169, 21)
$InputProximoContacto = GUICtrlCreateInput("", 24, 368, 169, 21)
;Buttons
$Clear = GUICtrlCreateButton("&Clear", 112, 400, 75, 25)
GUICtrlSetCursor (-1, 0)
$Delete = GUICtrlCreateButton("&Delete", 120, 48, 75, 25)
GUICtrlSetCursor (-1, 0)
;Label
$LabelNome = GUICtrlCreateLabel("Nome", 24, 120, 83, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$LabelContacto = GUICtrlCreateLabel("Contacto", 24, 176, 83, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$LabelEMail = GUICtrlCreateLabel("EMail", 24, 232, 83, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$LabelUltimoContacto = GUICtrlCreateLabel("Ultimo Contacto", 24, 288, 101, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$LabelProximoContacto = GUICtrlCreateLabel("Proximo Contacto", 24, 344, 101, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
;<========
;<==================================================================================
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
;<==================================================================================
While 1 ;Code
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3
            _Check4CLOSEClicked()
        Case $Clear
            _Check4Clear()
        Case $Delete
            _Check4Delete()     
        Case $Save
            _Check4Save()   
            $sText = StringReplace(GUICtrlRead($aEdit[0][0], $sText), @CRLF, "\n")
            IniWrite($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB), "DB Observações", $sText)
        Case $Search
            _Check4Search()
            $sText = StringReplace(IniRead($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "DB Observações", "Não disponivel"), "\n", @CRLF)
            GUICtrlSetData($aEdit[0][0], $sText)
                    EndSwitch
    ; Run through the edits to see if we need scrollbars
    For $i = 0 To $iNum_Edits - 1
        _Check_Scrolls($i)
    Next

WEnd
;<==================================================================================
Func _Check4CLOSEClicked();Exit
    
$answer = MsgBox(36, "Aviso", "              Quer fechar?"& @CRLF &""& @CRLF &"Novos dados não seram gravados?", 8)
If $answer = 6 Then
    Exit
EndIf
EndFunc
;<==================================================================================
Func _Check4Delete();Delete the Client INI file
    $answer = MsgBox(36, "Aviso", "Vai apagar o registo?", 8 )
If $answer = 6 Then
    ;<=================>;
FileDelete(GUICtrlRead($InputIDCB) & ".ini")
    ;<=================>;
EndIf   
    EndFunc
;<==================================================================================
Func _Check4Search() ;Search
GUICtrlSetData ($InputNome, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Nome", "Não disponivel"))
GUICtrlSetData ($InputContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) ,  "Contacto", "Não disponivel"))
GUICtrlSetData ($InputEmail, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) ,  "Email", "Não disponivel"))
GUICtrlSetData ($InputUltimoContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) ,  "Ultimo Contacto", "Não disponivel"))
GUICtrlSetData ($InputProximoContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Proximo Contacto", "Não disponivel"))
;<======== Depositos
EndFunc
;<==================================================================================
Func _Check4Clear() ;Clear Input / EditBox
$answer = MsgBox(36, "Aviso", "Tem a certeza que quer Limpar?", 8 )
If $answer = 6 Then
;<=== Dados Basicos
 GuiCtrlSetData ($InputIDCB, "IDCB")
 GuiCtrlSetData ($InputNome, "")
 GuiCtrlSetData ($InputContacto, "")
 GuiCtrlSetData ($InputEmail, "")
 GuiCtrlSetData ($InputUltimoContacto, "")
 GuiCtrlSetData ($InputProximoContacto, "")
 GuiCtrlSetData ($aEdit[0][0], "")
EndIf
EndFunc
 ;<==================================================================================
Func _Check4Save() ;Saves
$answer = MsgBox(36, "Aviso", "Tem a certeza que quer gravar?",8)
If $answer = 6 Then
;<==== Dados Basicos
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Nome" , GUICtrlRead($InputNome))
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Contacto" , GUICtrlRead($InputContacto))
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Email" , GUICtrlRead($InputEmail))
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Ultimo Contacto" , GUICtrlRead($InputUltimoContacto))
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Proximo Contacto" , GUICtrlRead($InputProximoContacto))
;<==== Depositos
EndIf
EndFunc
;<==================================================================================
Func _Check_Scrolls($iIndex) ;Scrolls Style

    ; Select the edit ControlID from the array
    $hControl = $aEdit[$iIndex][0]

    ; Get position of GUI
    $aPos = WinGetPos($hGui)
    ; Create a label outside the GUI with no size parameters
    $hTester = GUICtrlCreateLabel(GUICtrlRead($hControl), $aPos[0] + $aPos[2] + 10, $aPos[1])
    ; Get the size of the label - which is the size of the text
    $aSize = ControlGetPos($hGui, "", $hTester)
    ; Delete the label
    GUICtrlDelete($hTester)

    ; Check text width and adjust horizontal scroll bar style as necessary
    If $aSize[2] > $aEdit[$i][1] - 8 Then ; compare to Edit width
        ; We need a Horiz scrollbar
        If $aEdit[$i][3] = False Then ; If no Horiz scrollbar we need to add it
            If $aEdit[$i][4] = True Then ; Check if Vert scrollber exists
                ; Both needed
                GUICtrlSetStyle($hControl, $iBoth_Style)
                ConsoleWrite("Both" & @CRLF)
            Else
                ; Only Horiz needed
                GUICtrlSetStyle($hControl, $iHoriz_Style)
                ConsoleWrite("Horiz" & @CRLF)
            EndIf
            $aEdit[$i][3] = True
        EndIf
    Else
        ; No Horiz scrollbar needed
        If $aEdit[$i][3] = True Then
            ; We do not need a Horiz scrollbar
            If $aEdit[$i][4] = True Then ; Check if Vert scrollbar exists
                ; Only Vert needed
                GUICtrlSetStyle($hControl, $iVert_Style)
                ConsoleWrite("Vert" & @CRLF)
            Else
                ; Meither needed
                GUICtrlSetStyle($hControl, $iBase_Style)
                ConsoleWrite("Base" & @CRLF)
            EndIf
            $aEdit[$i][3] = False
            ; Force whole line to show
            ControlSend($hGui, "", $hControl, "{HOME}{END}")
        EndIf
    EndIf

    ; Check text height and adjust vertical scroll bar style as necessary
    If $aSize[3] > $aEdit[$i][2] - 6 Then
        If $aEdit[$i][4] = False Then
            If $aEdit[$i][3] = True Then
                ; Both needed
                GUICtrlSetStyle($hControl, $iBoth_Style)
                ConsoleWrite("Both" & @CRLF)
            Else
                ; Only Vert needed
                GUICtrlSetStyle($hControl, $iVert_Style)
                ConsoleWrite("Vert" & @CRLF)
            EndIf
            $aEdit[$i][4] = True
        EndIf
    Else
        If $aEdit[$i][4] = True Then
            If $aEdit[$i][3] = True Then
                ; Only Horiz needed
                GUICtrlSetStyle($hControl, $iHoriz_Style)
                ConsoleWrite("Horiz" & @CRLF)
            Else
                ; Neither needed
                GUICtrlSetStyle($hControl, $iBase_Style)
                ConsoleWrite("Base" & @CRLF)
            EndIf
            $aEdit[$i][4] = False
        EndIf
    EndIf

EndFunc   ;==>_Check_Scrolls
 ;<==================================================================================

Share this post


Link to post
Share on other sites

If you add 2 lines to your function like this

Func _Check4Search() ;Search
GUICtrlSetData ($InputNome, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Nome", "Não disponivel"))
GUICtrlSetData ($InputContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Contacto", "Não disponivel"))
GUICtrlSetData ($InputEmail, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Email", "Não disponivel"))
GUICtrlSetData ($InputUltimoContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Ultimo Contacto", "Não disponivel"))
GUICtrlSetData ($InputProximoContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Proximo Contacto", "Não disponivel"))

;add these lines here but remove them from the Case $Search
$sText = StringReplace(IniRead($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "DB Observações", "Não disponivel"), "\n", @CRLF)
GUICtrlSetData($aEdit[0][0], $sText)
;<======== Depositos
EndFunc

Is that what you mean?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

If you add 2 lines to your function like this

Func _Check4Search() ;Search
GUICtrlSetData ($InputNome, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Nome", "Não disponivel"))
GUICtrlSetData ($InputContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Contacto", "Não disponivel"))
GUICtrlSetData ($InputEmail, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Email", "Não disponivel"))
GUICtrlSetData ($InputUltimoContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Ultimo Contacto", "Não disponivel"))
GUICtrlSetData ($InputProximoContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Proximo Contacto", "Não disponivel"))

;add these lines here but remove them from the Case $Search
$sText = StringReplace(IniRead($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "DB Observações", "Não disponivel"), "\n", @CRLF)
GUICtrlSetData($aEdit[0][0], $sText)
;<======== Depositos
EndFunc

Is that what you mean?

More / less, if i put the Search on the func, the Save will give me error on saving...

I try puting the bouth of them on the func, and its gives me erro warning

WARNING: $sText: possibly used before declaration.

$sText = StringReplace(GUICtrlRead($aEdit[0][0], $sText)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Thanks for the replay.

Share this post


Link to post
Share on other sites

More / less, if i put the Search on the func, the Save will give me error on saving...

I try puting the bouth of them on the func, and its gives me erro warning

WARNING: $sText: possibly used before declaration.

$sText = StringReplace(GUICtrlRead($aEdit[0][0], $sText)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Thanks for the replay.

Yes, but that error was in the code you posted and was not altered by the change I suggested. Try running the code you posted and you will see the same error.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Yes, but that error was in the code you posted and was not altered by the change I suggested. Try running the code you posted and you will see the same error.

Hello Martin.

That's impossible... I'm using my script and i never got any error for Searching / Saving.

One question, do you use Vista / 7??, if yes, there's the problem, if you use it on Xp, you will never get any error warning.

But i found a solution, i copy the Save / Search to the "func" an let the Original parts on the "While", like this.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
HotKeySet("!q","_Check4Search")
;<==================================================================================
; Set the various styles we need
Global $iBase_Style = BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL)
Global $iHoriz_Style = BitOR($ES_WANTRETURN, $ES_AUTOHSCROLL, $WS_HSCROLL)
Global $iVert_Style = BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $WS_VSCROLL)
Global $iBoth_Style = BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $WS_HSCROLL, $WS_VSCROLL)
;<==================================================================================
; How many edits?
Global $iNum_Edits = 1
; Set up array to hold the variables for each Edit
; [0] = ControlID
; [1] = width
; [2] = height
; [3[ = horizontal scroll state
; [4] = vertical scroll state of each edit
;<==================================================================================

Global $aEdit[$iNum_Edits][5]
; Set all scroll states to False
For $i = 0 To $iNum_Edits - 1
    $aEdit[$i][3] = False
    $aEdit[$i][4] = False
Next
;<==================================================================================
;Main.
$hGUI = GUICreate("Base de Contactos BES", 537, 451)
GUISetBkColor(0x000000)
$sINI = @ScriptDir & "\"
$PageControl1 = GUICtrlCreateTab(10, 10, 516, 432)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
;BackGround
;$pic = GuiCtrlCreatePic(@ScriptDir & "\BES" & "\bes.jpg" ,0, 32, 537, 451)
;GUICtrlSetState(-1,$GUI_DISABLE)
;$pic = GuiCtrlCreatePic(@ScriptDir & "\BES" & "\bkp.jpg" ,441 , 9, 166, 23)
;GUICtrlSetState(-1,$GUI_DISABLE)
;Buttons
$Save = GUICtrlCreateButton("&Save", 24, 400, 75, 25)
GUICtrlSetCursor (-1, 0)

;<==================================================================================

;TabSheets
$TabSheet1 = GUICtrlCreateTabItem("Dados Basicos")
; Fill array with data for this Edit
$aEdit[0][1] = 289
$aEdit[0][2] = 377
$aEdit[0][0] = GUICtrlCreateEdit("", 216, 48, $aEdit[0][1], $aEdit[0][2], $iBase_Style)
;<========
;Input
$InputIDCB = GUICtrlCreateInput("IDCB", 24, 88, 169, 21)
;Buttons
$Search = GUICtrlCreateButton("Search", 24, 48, 75, 25)
GUICtrlSetCursor (-1, 0)
;Input
$InputNome = GUICtrlCreateInput("", 24, 144, 169, 21)
$InputContacto = GUICtrlCreateInput("", 24, 200, 169, 21)
$InputEmail = GUICtrlCreateInput("", 24, 256, 169, 21)
$InputUltimoContacto = GUICtrlCreateInput("", 24, 312, 169, 21)
$InputProximoContacto = GUICtrlCreateInput("", 24, 368, 169, 21)
;Buttons
$Clear = GUICtrlCreateButton("&Clear", 112, 400, 75, 25)
GUICtrlSetCursor (-1, 0)
$Delete = GUICtrlCreateButton("&Delete", 120, 48, 75, 25)
GUICtrlSetCursor (-1, 0)
;Label
$LabelNome = GUICtrlCreateLabel("Nome", 24, 120, 83, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$LabelContacto = GUICtrlCreateLabel("Contacto", 24, 176, 83, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$LabelEMail = GUICtrlCreateLabel("EMail", 24, 232, 83, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$LabelUltimoContacto = GUICtrlCreateLabel("Ultimo Contacto", 24, 288, 101, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$LabelProximoContacto = GUICtrlCreateLabel("Proximo Contacto", 24, 344, 101, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
;<========
;<==================================================================================
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
;<==================================================================================
While 1 ;Code
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3
            _Check4CLOSEClicked()
        Case $Clear
            _Check4Clear()
        Case $Delete
            _Check4Delete()     
        Case $Save
            _Check4Save()   
            $sText = StringReplace(GUICtrlRead($aEdit[0][0], $sText), @CRLF, "\n")
            IniWrite($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB), "DB Observações", $sText)
        Case $Search
            _Check4Search()
            $sText = StringReplace(IniRead($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "DB Observações", "Não disponivel"), "\n", @CRLF)
            GUICtrlSetData($aEdit[0][0], $sText)
                    EndSwitch
    ; Run through the edits to see if we need scrollbars
    For $i = 0 To $iNum_Edits - 1
        _Check_Scrolls($i)
    Next

WEnd
;<==================================================================================
Func _Check4CLOSEClicked();Exit
    
$answer = MsgBox(36, "Aviso", "              Quer fechar?"& @CRLF &""& @CRLF &"Novos dados não seram gravados?", 8)
If $answer = 6 Then
    Exit
EndIf
EndFunc
;<==================================================================================
Func _Check4Delete();Delete the Client INI file
    $answer = MsgBox(36, "Aviso", "Vai apagar o registo?", 8 )
If $answer = 6 Then
    ;<=================>;
FileDelete(GUICtrlRead($InputIDCB) & ".ini")
    ;<=================>;
EndIf   
    EndFunc
;<==================================================================================
Func _Check4Search() ;Search
$sText = StringReplace(IniRead($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "DB Observações", "Não disponivel"), "\n", @CRLF)
GUICtrlSetData($aEdit[0][0], $sText)

GUICtrlSetData ($InputNome, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Nome", "Não disponivel"))
GUICtrlSetData ($InputContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) ,  "Contacto", "Não disponivel"))
GUICtrlSetData ($InputEmail, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) ,  "Email", "Não disponivel"))
GUICtrlSetData ($InputUltimoContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) ,  "Ultimo Contacto", "Não disponivel"))
GUICtrlSetData ($InputProximoContacto, IniRead (GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB) , "Proximo Contacto", "Não disponivel"))
;<======== Depositos
EndFunc
;<==================================================================================
Func _Check4Clear() ;Clear Input / EditBox
$answer = MsgBox(36, "Aviso", "Tem a certeza que quer Limpar?", 8 )
If $answer = 6 Then
;<=== Dados Basicos
 GuiCtrlSetData ($InputIDCB, "IDCB")
 GuiCtrlSetData ($InputNome, "")
 GuiCtrlSetData ($InputContacto, "")
 GuiCtrlSetData ($InputEmail, "")
 GuiCtrlSetData ($InputUltimoContacto, "")
 GuiCtrlSetData ($InputProximoContacto, "")
 GuiCtrlSetData ($aEdit[0][0], "")
EndIf
EndFunc
 ;<==================================================================================
Func _Check4Save() ;Saves
$answer = MsgBox(36, "Aviso", "Tem a certeza que quer gravar?",8)
If $answer = 6 Then
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Nome" , GUICtrlRead($InputNome))
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Contacto" , GUICtrlRead($InputContacto))
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Email" , GUICtrlRead($InputEmail))
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Ultimo Contacto" , GUICtrlRead($InputUltimoContacto))
    IniWrite ( GUICtrlRead($InputIDCB) & ".ini" , GUICtrlRead($InputIDCB) , "Proximo Contacto" , GUICtrlRead($InputProximoContacto))
$sText = StringReplace(GUICtrlRead($aEdit[0][0], $sText), @CRLF, "\n")
IniWrite($sINI & GUICtrlRead($InputIDCB) & ".ini", GUICtrlRead($InputIDCB), "DB Observações", $sText)
EndIf
EndFunc
;<==================================================================================
Func _Check_Scrolls($iIndex) ;Scrolls Style

    ; Select the edit ControlID from the array
    $hControl = $aEdit[$iIndex][0]

    ; Get position of GUI
    $aPos = WinGetPos($hGui)
    ; Create a label outside the GUI with no size parameters
    $hTester = GUICtrlCreateLabel(GUICtrlRead($hControl), $aPos[0] + $aPos[2] + 10, $aPos[1])
    ; Get the size of the label - which is the size of the text
    $aSize = ControlGetPos($hGui, "", $hTester)
    ; Delete the label
    GUICtrlDelete($hTester)

    ; Check text width and adjust horizontal scroll bar style as necessary
    If $aSize[2] > $aEdit[$i][1] - 8 Then ; compare to Edit width
        ; We need a Horiz scrollbar
        If $aEdit[$i][3] = False Then ; If no Horiz scrollbar we need to add it
            If $aEdit[$i][4] = True Then ; Check if Vert scrollber exists
                ; Both needed
                GUICtrlSetStyle($hControl, $iBoth_Style)
                ConsoleWrite("Both" & @CRLF)
            Else
                ; Only Horiz needed
                GUICtrlSetStyle($hControl, $iHoriz_Style)
                ConsoleWrite("Horiz" & @CRLF)
            EndIf
            $aEdit[$i][3] = True
        EndIf
    Else
        ; No Horiz scrollbar needed
        If $aEdit[$i][3] = True Then
            ; We do not need a Horiz scrollbar
            If $aEdit[$i][4] = True Then ; Check if Vert scrollbar exists
                ; Only Vert needed
                GUICtrlSetStyle($hControl, $iVert_Style)
                ConsoleWrite("Vert" & @CRLF)
            Else
                ; Meither needed
                GUICtrlSetStyle($hControl, $iBase_Style)
                ConsoleWrite("Base" & @CRLF)
            EndIf
            $aEdit[$i][3] = False
            ; Force whole line to show
            ControlSend($hGui, "", $hControl, "{HOME}{END}")
        EndIf
    EndIf

    ; Check text height and adjust vertical scroll bar style as necessary
    If $aSize[3] > $aEdit[$i][2] - 6 Then
        If $aEdit[$i][4] = False Then
            If $aEdit[$i][3] = True Then
                ; Both needed
                GUICtrlSetStyle($hControl, $iBoth_Style)
                ConsoleWrite("Both" & @CRLF)
            Else
                ; Only Vert needed
                GUICtrlSetStyle($hControl, $iVert_Style)
                ConsoleWrite("Vert" & @CRLF)
            EndIf
            $aEdit[$i][4] = True
        EndIf
    Else
        If $aEdit[$i][4] = True Then
            If $aEdit[$i][3] = True Then
                ; Only Horiz needed
                GUICtrlSetStyle($hControl, $iHoriz_Style)
                ConsoleWrite("Horiz" & @CRLF)
            Else
                ; Neither needed
                GUICtrlSetStyle($hControl, $iBase_Style)
                ConsoleWrite("Base" & @CRLF)
            EndIf
            $aEdit[$i][4] = False
        EndIf
    EndIf

EndFunc   ;==>_Check_Scrolls
 ;<==================================================================================

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