Sign in to follow this  
Followers 0
bogQ

How to do GUICtrlCreateInput like in MSN?

16 posts in this topic

So im interested at example555@hotmail.com gray text thet will hide if field isnt emptu

im not interested in scripting it (that i can do my self but effect will probably not b identical)

im interested if there is easyer way-something i miss in help file like style that will work for it, or some other control that will replicate similar behavior (or control over control).

Posted Image


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites



Something like that?

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 230, 230, -1, -1, $WS_TABSTOP)
GUISetBkColor(0xFFFFFF)
$idCombo = GUICtrlCreateCombo("Example555@hotmail.com", 8, 8, 209, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetFont(-1, 9, 400, 2, "Arial")
GUICtrlSetColor(-1, 0x808080)
$idInput = GUICtrlCreateInput("Enter your password", 8, 40, 209, 23)
GUICtrlSetFont(-1, 9, 400, 2, "Arial")
GUICtrlSetColor(-1, 0x808080)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

no, :/

gray text that will hide if field isnt emptu

on MSN you can't select gray text and you can't tupe in it, but it will disapier if Input field inst empty, its like some info tip that stands inside Input it self when there inst any data in that Input.

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

You'll need to check whether the input field has the current focus, if it has, you can set the field contents to empty and the color to black. If it looses focus check, whether it's empty and reassign the grey example.


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Look at MSDN for EM_SETCUEBANNER and CB_SETCUEBANNER.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

So this is using UEZ's initial example but I've added the option of when a user selects the combo or inputbox it will delete the data & if you don't add any data then it will revert back to the previous text!

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $__ControlID, $__PreviousText

_Main()

Func _Main()
Local $hGUI

$hGUI = GUICreate("Example by guinness 2011", 230, 230, -1, -1)
GUISetBkColor(0xFFFFFF)
GUICtrlCreateCombo("Example555@hotmail.com", 8, 8, 209, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetFont(-1, 9, 400, 2, "Arial")
GUICtrlSetColor(-1, 0x808080)
GUICtrlCreateInput("Enter your password", 8, 40, 209, 23)
GUICtrlSetFont(-1, 9, 400, 2, "Arial")
GUICtrlSetColor(-1, 0x808080)
GUICtrlSetState(-1, $GUI_FOCUS)

GUIRegisterMsg($WM_COMMAND, 'WM_CHECK')
GUISetState(@SW_SHOW, $hGUI)

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd
EndFunc ;==>_Main

Func WM_CHECK($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $ilParam
Local $hHandle, $iCode

$hHandle = GUICtrlGetHandle($__ControlID)
$iCode = _WinAPI_HiWord($iwParam)
Switch $iCode
Case $EN_SETFOCUS, $CBN_SETFOCUS
$__ControlID = _WinAPI_LoWord($iwParam)
$__PreviousText = GUICtrlRead($__ControlID)
GUICtrlSetData($__ControlID, "")

Case $EN_KILLFOCUS, $CBN_KILLFOCUS
If _WinAPI_GetClassName($hHandle) = "ComboBox" Then
_GUICtrlComboBox_SetEditText($hHandle, $__PreviousText)
Else
If GUICtrlRead($__ControlID) = "" Then
GUICtrlSetData($__ControlID, $__PreviousText)
EndIf
EndIf

EndSwitch
Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_CHECK
Edited by guinness
2 people like this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

ty ahmet

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Here my version:

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 230, 230, -1, -1, $WS_TABSTOP)
GUISetBkColor(0xFFFFFF)
$idCombo = GUICtrlCreateCombo("Example555@hotmail.com", 8, 8, 209, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetFont(-1, 9, 400, 2, "Arial")
GUICtrlSetColor(-1, 0x808080)
$hCombo = GUICtrlGetHandle($idCombo)
$idInput = GUICtrlCreateInput("Enter your password", 8, 40, 209, 23, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
GUICtrlSetFont(-1, 9, 400, 2, "Arial")
GUICtrlSetColor(-1, 0x808080)
$hInput = GUICtrlGetHandle($idInput)
$idButton = GUICtrlCreateButton("Exit", 194, 170)

Global $DefaultPassChar = GUICtrlSendMsg($idInput, $EM_GETPASSWORDCHAR, 0, 0)
GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, 0, 0)

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "Check")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $idButton
            Exit
    EndSwitch
WEnd

Func Check($hWnd, $iMsg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    Switch $nNotifyCode
        Case 256, 3 ;set focus
            Switch $nID
                Case $idCombo
                    If _GUICtrlComboBox_GetEditText($hCombo) = "Example555@hotmail.com" Then _GUICtrlComboBox_SetEditText($hCombo, "")
                Case $idInput
                    If GUICtrlRead($idInput) = "Enter your password" Then
                        GUICtrlSetData($idInput, "")
                        GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, $DefaultPassChar, 0)
                    EndIf
            EndSwitch
        Case 512, 4 ;kill focus
            If GUICtrlRead($idInput) = "" Then
                GUICtrlSetData($idInput, "Enter your password")
                GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, 0, 0)
            EndIf
            If GUICtrlRead($idCombo) = "" Then _GUICtrlComboBox_SetEditText($hCombo, "Example555@hotmail.com")
        EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc

Br,

UEZ

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

:)

thats why i tolded that i whud not like to hard code it, i need around 30 fields with that gray thing :)

i think that code from rover is easyer

#include <GUIConstantsEX.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
$hGui = GUICreate("Subclassed edit controls /w custom tooltips and cue banners from rover", 500, 300)
GUICtrlCreateLabel("Info", 10, 5)
$Input1 = GUICtrlCreateInput("", 10, 20, 140, 20)
$Input2 = GUICtrlCreateInput("", 10, 40, 140, 20)
$Input3 = GUICtrlCreateInput("", 10, 60, 140, 20)
$Input4 = GUICtrlCreateInput("", 10, 80, 140, 20)
$Input5 = GUICtrlCreateInput("", 10, 100, 140, 20)
$Input6 = GUICtrlCreateInput("", 10, 120, 140, 20)
_GUICtrlEdit_SetCueBanner($Input1, "Name")
_GUICtrlEdit_SetCueBanner($Input2, "Adress")
_GUICtrlEdit_SetCueBanner($Input3, "Nome Phone")
_GUICtrlEdit_SetCueBanner($Input4, "Mobile Phone")
_GUICtrlEdit_SetCueBanner($Input5, "Date of birth")
_GUICtrlEdit_SetCueBanner($Input6, "Town")
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd
Func _GUICtrlEdit_SetCueBanner($hWnd, $sText)
    Local $tText = _WinAPI_MultiByteToWideChar($sText)
    _SendMessage(GUICtrlGetHandle($hWnd), $EM_SETCUEBANNER, False, DllStructGetPtr($tText))
EndFunc

never the less t u all for suggestions :mellow:

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Hi,

Here my version:

;#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Include <WinAPI.au3>
#Include <GuiComboBox.au3>
 
$hGUI = GUICreate("Test", 230, 230, -1, -1, $WS_TABSTOP)
GUISetBkColor(0xFFFFFF)
$idCombo = GUICtrlCreateCombo("", 8, 8, 209, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
SetCueText($idCombo, "Example555@hotmail.com")
GUICtrlSetFont(-1, 9, 400, 2, "Arial")
GUICtrlSetColor(-1, 0x808080)
$idInput = GUICtrlCreateInput("", 8, 40, 209, 23)
SetCueText($idInput, "Enter your password")
GUICtrlSetFont(-1, 9, 400, 2, "Arial")
GUICtrlSetColor(-1, 0x808080)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Func SetCueText($control, $text, $wParam = False)
$hWnd = GUICtrlGetHandle($control)
    if (_WinAPI_GetClassName($hWnd)='ComboBox') Then
  _GUICtrlComboBox_SetCueBanner($hWnd, $text)
    else
  If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  $text = _WinAPI_MultiByteToWideChar($text)
  Return _SendMessage($hWnd, $EM_SETCUEBANNER, $wParam, DllStructGetPtr($text)) = 1;
     EndIf
EndFunc

Jeanphile

1 person likes this

Share this post


Link to post
Share on other sites

@bogQ

MultiByteToWideChar is no longer needed.

#include <GUIConstantsEX.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
$hGui = GUICreate("", 500, 300)
GUICtrlCreateLabel("Info", 10, 5)
Local $aInput[6][2] = [[0, "Name"],[0, "Address"],[0, "Home Phone"],[0, "Mobile Phone"],[0, "Date of birth"],[0, "Town"]]
For $i = 0 To UBound($aInput) -1
$aInput[$i][0] = GUICtrlCreateInput("", 10, (20*($i+1)), 140, 20)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, $aInput[$i][1])
Next
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

;Does not work for edit controls with $ES_MULTILINE style.
;In XP, the banner disappears when the edit has focus (cursor in edit)
;In Vista/7 the banner can optionally still appear when the edit has focus (cursor in edit)
;(third parameter = True/False)

The original function was coded in 2008 for an Ansi version of AutoIt.

2 people like this

I see fascists...

Share this post


Link to post
Share on other sites

Cool, $EM_SETCUEBANNER supports also $ES_PASSWORD.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

@bogQ

MultiByteToWideChar is no longer needed.

#include <GUIConstantsEX.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
$hGui = GUICreate("", 500, 300)
GUICtrlCreateLabel("Info", 10, 5)
Local $aInput[6][2] = [[0, "Name"],[0, "Address"],[0, "Home Phone"],[0, "Mobile Phone"],[0, "Date of birth"],[0, "Town"]]
For $i = 0 To UBound($aInput) -1
$aInput[$i][0] = GUICtrlCreateInput("", 10, (20*($i+1)), 140, 20)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, $aInput[$i][1])
Next
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd
 
;Does not work for edit controls with $ES_MULTILINE style.
;In XP, the banner disappears when the edit has focus (cursor in edit)
;In Vista/7 the banner can optionally still appear when the edit has focus (cursor in edit)
;(third parameter = True/False)

The original function was coded in 2008 for an Ansi version of AutoIt.

yes, but it works

excuse my English, I'm french

JeanPhile

Share this post


Link to post
Share on other sites

anyone have the clue why something like that won't work under some XP computers?

My work comp XP sp 2 working. home comps XP sp3 and sp2 not working

If @error isnt detected.


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

yes, but it works

I assume you are referring to the use of _WinAPI_MultiByteToWideChar()?

If using a pre-unicode version of AutoIt, then yes it works, and is required.

In a unicode version of AutoIt, it is not necessary.

anyone have the clue why something like that won't work under some XP computers?

My work comp XP sp 2 working. home comps XP sp3 and sp2 not working

If @error isnt detected.

When you say it won't work with some XP computers,

are you referring to EM_SETCUEBANNER with ES_PASSWORD? (thanks UEZ).

or do you mean the stripped down version with GUICtrlSendMsg(), the version with MultiByteToWideChar(), or both?

Are you running a script with a unicode version of AutoIt on those machines?

The only other issue I came across when coding the udfs other than unicode, was a problem with Asian language support in XP (not an issue in Vista/Win 7).

apparently installing Asian language support disables the cue banner.

In that case, you have to use the WM_COMMAND with EN_KILLFOCUS/EN_SETFOCUS notifications method

SIAO had some comments on this (possibly the forums Siao?)

EM_SETCUEBANNER vs. international support in XP and Server 2003

https://blogs.msdn.com/michkap/archive/2006/02/25/538735.aspx

I have used this on XP x86 SP2/SP3 and Vista machines (tested in english only)

Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

mucha gracias amigo :mellow:

your correct, problem appeared because of 10MB supplemental language support in regional and language options for right-to-left languages (including Thai)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

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