Jump to content

Lock Controls without graying out


 Share

Recommended Posts

Try to access the input box :)

#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIConv.au3>

Example()

Func Example()
  Global $hWnd = GUICreate(" My GUI input acceptfile")
  Global $idInput = GUICtrlCreateInput("Test", 10, 5, 300, 20)
  Local $idBtn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

  GUIRegisterMsg($WM_COMMAND, WM_COMMAND)

  GUISetState(@SW_SHOW)

  ; Loop until the user exits.
  While 1
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
      Case $idBtn
        ExitLoop
    EndSwitch
  WEnd

EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
  Local $iIDFrom = _WinAPI_LoWord($wParam), $iCode = _WinAPI_HiWord($wParam)
  If $iCode = $EN_SETFOCUS And $iIDFrom = $idInput Then ControlSend($hWnd, "", "", "{TAB}")
  Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Just set a boolean to make the input box available or not...

Link to comment
Share on other sites

@Zedna  Good point.  But I was trying to emulate a disabled item without disabling it.  The same strategy can be applied to other controls :

#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIConv.au3>

Example()

Func Example()
  Global $hWnd = GUICreate(" My GUI input acceptfile")
  Global $idInput = GUICtrlCreateInput("Disabled", 10, 5, 300, 20)
  Global $idCombo =  GUICtrlCreateCombo("", 10, 30, 185, 20)
  GUICtrlSetData(-1,"Item 1|Item 2|Item3", "Item 1")
  Global $idBtn = GUICtrlCreateButton("Ok", 40, 75, 60, 20, $BS_NOTIFY)
  Global $idEnable = GUICtrlCreateInput("Enabled", 10, 125, 300, 20)

  GUIRegisterMsg($WM_COMMAND, WM_COMMAND)

  GUISetState(@SW_SHOW)

  ; Loop until the user exits.
  While 1
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd

EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
  Local $iIDFrom = _WinAPI_LoWord($wParam), $iCode = _WinAPI_HiWord($wParam)
  If ($iCode = $BN_SETFOCUS And $iIDFrom = $idBtn) Or ($iCode = $EN_SETFOCUS And $iIDFrom = $idInput) or _
      ($iCode = $CBN_SETFOCUS And $iIDFrom = $idCombo) Then
    ControlSend($hWnd, "", "", "{TAB}")
    Return 1
  EndIf
  Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Not perfect but best I could think of...

Edited by Nine
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...