AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Any way to clear edit control upon focus or initial change

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
vahju



Joined: 17 Feb 2008
Posts: 296

PostPosted: Tue Oct 21, 2008 7:47 pm    Post subject: Any way to clear edit control upon focus or initial change Reply with quote

So I have this edit control that contains some default text.
Code:
Gui, Add, Edit, r3 vEditText y+10 w140, Add some extra notes.


What I would like to do is when someone clicks in the edit control the default text is cleared. I could not find a built in option in the help system.

This GUI I am creating will eventually take the input from all controls and put them in the clipboard to be pasted in helpdesk tickets. I don't want the "add some extra notes" in every ticket.

Any ideas?
Back to top
View user's profile Send private message
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Tue Oct 21, 2008 7:56 pm    Post subject: Reply with quote

You can use OnMessage to catch clicks in the Edit control:

Code:
Gui, Add, Edit, r3 vEditText HwndEdit y+10 w140, Add some extra notes.
Gui, Show
OnMessage(0x201, "WM_LBUTTONDOWN")
Return

WM_LBUTTONDOWN(wParam, lParam, Msg, hWnd)
{
   Global Edit
   If (hWnd = Edit)
      GuiControl,, Edit1
}

_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Tue Oct 21, 2008 10:48 pm    Post subject: Reply with quote

http://www.autohotkey.com/forum/viewtopic.php?t=33554
Back to top
View user's profile Send private message Send e-mail
vahju



Joined: 17 Feb 2008
Posts: 296

PostPosted: Wed Oct 22, 2008 5:00 pm    Post subject: Reply with quote

Serenity I tried you suggestion and it clears the edit field but for some reason no matter what contol I click on it minimizes or hides the GUI.

I really don't understand the WM_LButtonDown parameters. This is the first time I have every used this type of code. From what I can see the hWnd is passed and it compares it to Edit. But for some reason it is making the comparison no matter what GUI control I click on.

Code:
WM_LBUTTONDOWN(wParam, lParam, Msg, hWnd)
{
   Global Edit
   Edit
   If (hWnd = Edit)
   {
      GuiControl,,Edit1
   }
}
Back to top
View user's profile Send private message
vahju



Joined: 17 Feb 2008
Posts: 296

PostPosted: Thu Oct 23, 2008 4:09 pm    Post subject: Reply with quote

SKAN thanks for the link. The Timer approach worked perfectly.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group