Jump to content

Non editable text in editable inputbox


Recommended Posts

Hi,

Is it possible to create an Inputbox with text already in it, that isn't editable, but when you select the inputbox, you start typing behind the text that's already in the inputbox?

For example:

When having a series of product which all start with the same first four characters, is it possible to default have these first four characters in an inputbox, but people can't delete there characters and always start typing behind the default text? Maybe in the form of a picture?

Thanks in advance.

post-66455-0-62965900-1337679085_thumb.j

Edited by Maikey81
Link to comment
Share on other sites

#Region    ;************ Includes ************
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#EndRegion ;************ Includes ************
$GUI = GUICreate(" My GUI", 350, 180)
$hInput = GUICtrlCreateInput("DN40", 10, 5, 300, 20)
GUICtrlSetLimit(-1, 10)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $controlID = _WinAPI_LoWord($wParam)
If $controlID = $hInput Then
  If StringLeft(GUICtrlRead($hInput), 4) <> 'DN40' Then
   GUICtrlSetData($hInput, "DN40")
  EndIf
  ; hier jegliche Logik rein.
EndIf
EndFunc   ;==>MY_WM_COMMAND

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

#Region ;************ Includes ************
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#EndRegion ;************ Includes ************
$GUI = GUICreate(" My GUI", 350, 180)
$hInput = GUICtrlCreateInput("DN40", 10, 5, 300, 20)
GUICtrlSetLimit(-1, 10)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $controlID = _WinAPI_LoWord($wParam)
If $controlID = $hInput Then
  If StringLeft(GUICtrlRead($hInput), 4) <> 'DN40' Then
   GUICtrlSetData($hInput, "DN40")
  EndIf
  ; hier jegliche Logik rein.
EndIf
EndFunc   ;==>MY_WM_COMMAND

Thanks Xeno! That did the trick!

Now I'm going to try and figure out what you did.

Link to comment
Share on other sites

I even wanted SomeThing Like That

The Problem is its not Case-Sensitive

Try Selecting the 'D' and type 'd' in its place

it replaces that

EDIT: forgot case sensitive option

this would do the work

code:

#Region ;************ Includes ************
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#EndRegion ;************ Includes ************
$GUI = GUICreate(" My GUI", 350, 180)
$hInput = GUICtrlCreateInput("DN40", 10, 5, 300, 20)
GUICtrlSetLimit(-1, 10)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $controlID = _WinAPI_LoWord($wParam)
If $controlID = $hInput Then
  If Not (StringLeft(GUICtrlRead($hInput), 4)=='DN40') Then
   GUICtrlSetData($hInput, "DN40")
  EndIf
  ; hier jegliche Logik rein.
EndIf
EndFunc   ;==>MY_WM_COMMAND

thnx xenobiologist for the code

Regards

Phoenix XL

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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