Jump to content


Photo

[SOLVED]Gray Placeholder Text?


  • Please log in to reply
8 replies to this topic

#1 Xei

Xei
  • Members
  • 114 posts

Posted 31 January 2012 - 11:38 PM

Not sure what this is called, but I was wondering if there is a command to add gray placeholder text into an edit control? or would this be something that I would have to do myself? An example of what I'm talking about is below.

Posted Image

When nothing is typed into the text box, the placeholder text is shown. Otherwise, whatever is entered into the edit control will automatically replace the placeholder text with what you type.

#2 nimda

nimda
  • Members
  • 4301 posts

Posted 01 February 2012 - 12:30 AM

Placeholder() :?:


Query used

#3 Xei

Xei
  • Members
  • 114 posts

Posted 01 February 2012 - 12:42 AM

Thank you.

Haven't seen a lmgtfy in a while. Anyway, I did Google it, but my results were <!-- m -->http://www.autohotke...topic80323.html<!-- m --> and others.. along with unrelated topics. I wasn't sure if it was called placeholder text either.

I did learn a new Google search tool though. :) I've been using +autohotkey | AHK

#4 nimda

nimda
  • Members
  • 4301 posts

Posted 01 February 2012 - 12:51 AM

Interesting. Searching from the homepage gives the function as the second result, but a forum search puts it several down. And Google puts it as the first result. Hmmph.

(Although your search works just as well)

#5 Xei

Xei
  • Members
  • 114 posts

Posted 01 February 2012 - 12:56 AM

Indeed it does. Well anyway, I appreciate your help. Couldn't have done it without ya! Also, the function works perfectly. Thanks again!

#6 just me

just me
  • Members
  • 1175 posts

Posted 01 February 2012 - 05:45 AM

Gui, Margin, 20, 20

Gui, Font, s10 Bold

Gui, Add, Text, , Name

Gui, Font, Normal

Gui, Add, Edit, xm y+10 w150 hwndHED1

SetEditCueBanner(HED1, "First")

Gui, Add, Edit, x+10 yp wp hwndHED2

SetEditCueBanner(HED2, "Last")

Gui, Show, , EM_SETCUEBANNER

Return

GuiClose:

ExitApp 



SetEditCueBanner(HWND, Cue) {  ; requires AHL_L

   Static EM_SETCUEBANNER := (0x1500 + 1)

   Return DllCall("User32.dll\SendMessageW", "Ptr", HWND, "Uint", EM_SETCUEBANNER, "Ptr", True, "WStr", Cue)

}


#7 nimda

nimda
  • Members
  • 4301 posts

Posted 01 February 2012 - 12:11 PM

There's an edit message for that? :shock:

#8 Deo

Deo
  • Members
  • 199 posts

Posted 02 February 2012 - 07:46 AM

just me
thanks!

#9 garry

garry
  • Members
  • 2596 posts

Posted 02 February 2012 - 08:08 AM

just basic, to see both edit fields with gray text (focus)
can place Gui,show earlier or use focus

Gui, Margin, 20, 20
Gui, Font, s10 Bold
Gui, Add, Text, , Name
Gui, Font, Normal
;Gui, Show,x10 y10 h100 w350 , EM_SETCUEBANNER

Gui, Add, Edit, xm y+10 w150 hwndHED1 vEdit1
SetEditCueBanner(HED1, "First")
Gui, Add, Edit, x+10 yp wp hwndHED2 vEdit2
SetEditCueBanner(HED2, "Last")

Gui, Add, Edit,x0 y0 h0 w0 vEmpty1  ; not visible editfield set focus here

Gui, Show, , EM_SETCUEBANNER

GuiControl,1:Focus,empty1   ; see two edits gray First Last
;GuiControl,1:Focus,edit2
Return


GuiClose:
ExitApp


SetEditCueBanner(HWND, Cue) {  ; requires AHL_L
   Static EM_SETCUEBANNER := (0x1500 + 1)
   Return DllCall("User32.dll\SendMessageW", "Ptr", HWND, "Uint", EM_SETCUEBANNER, "Ptr", True, "WStr", Cue)
}