 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
totonf
Joined: 09 Apr 2008 Posts: 8
|
Posted: Wed Jul 09, 2008 8:33 pm Post subject: GUI edit control |
|
|
I add an edit component with a default message. I wish delete the message as soon as the user focus on the edit box?
I tried with a gRoutine in vain (the routine is not launched when cursor is to the edit box).
 |
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 103 Location: New York
|
Posted: Wed Jul 09, 2008 11:01 pm Post subject: |
|
|
This is how I would do it... but that's just me and my knowledge is definately limited but I try to help when I can.
Oh! and it's tested so go ahead and try it out:
| Code: | SetTimer, Persistent_Routine, 100
Gui, Add, Edit, x86 y75 w100 h20 , Edit
Gui, Add, Edit, x86 y104 w100 h30 veditBox, Edit
Gui, Show, x131 y91 h377 w477, Test
Return
GuiClose:
ExitApp
Persistent_Routine:
GuiControlGet, OutputVar, Focus
If OutputVar = Edit2
{
GuiControl,, editBox,
SetTimer, Persistent_Routine, Off ;You could shut it off if it won't be used again so it doesn't eat memory
}
return
|
|
|
| Back to top |
|
 |
totonf! Guest
|
Posted: Thu Jul 10, 2008 4:10 pm Post subject: |
|
|
I appreciate your idea, bravo.
Thanks a lot. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Thu Jul 10, 2008 4:36 pm Post subject: |
|
|
You could monitor the EN_SETFOCUS notification.
| Code: | Gui, Add, Edit, x86 y75 w200 h20 vEdit1 , <Enter Data Here>
Gui, Add, Edit, x86 y104 w200 h20 vEdit2 hwndEC1, <Enter Data Here>
Gui, Show, x131 y91 h377 w477, Test
OnMessage( 0x111, "WM_Command" )
Return
WM_Command( wp, lp ) {
Global EC1
If ( (wp >> 16) = 0x100 && lp = EC1 ) { ; EN_SETFOCUS = 0x100
GuiControl,,Edit2
OnMessage( 0x111, "" )
}}
GuiClose:
ExitApp |
 _________________
 |
|
| Back to top |
|
 |
totonf
Joined: 09 Apr 2008 Posts: 8
|
Posted: Mon Jul 14, 2008 2:01 pm Post subject: |
|
|
Very nice, thank you! Where did you find parameter values for OnMessage and the hexa code for wp?
I wish to set back the default message as soon as the user quit focus from the edit box if empty? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Mon Jul 14, 2008 3:15 pm Post subject: |
|
|
| Quote: | | Where did you find parameter values for OnMessage and the hexa code for wp? |
| Quote: | | I wish to set back the default message as soon as the user quit focus from the edit box if empty? |
| Code: | Gui, Add, Edit, w200 h20 vEdit1 hwndEC1, <Enter Data Here>
Gui, Add, Edit, w200 h20 vEdit2 hwndEC2, <Enter Data Here>
Gui, Add, Edit, w200 h20 vEdit3 hwndEC3, <Enter Data Here>
Gui, Add, Edit, w200 h20 vEdit4 hwndEC4, <Enter Data Here>
Gui, Add, Edit, w200 h20 vEdit5 hwndEC5, <Enter Data Here>
Gui, Show, x131 y91 h377 w477, Test
OnMessage( 0x111, "WM_Command" )
Return
WM_Command( wp, lp ) {
Global EC1,EC2,EC3,EC4,EC5
If ( (wp >> 16) = 0x100 && ( lp=EC1||lp=EC2||lp=EC3||lp=EC4||lp=EC5 ) ) { ; EN_SETFOCUS
ControlGetText,Text,, ahk_id %lp%
IfEqual,text,<Enter Data Here>, ControlSetText,,,ahk_id %lp%
}
If ( (wp >> 16) = 0x200 && ( lp=EC1||lp=EC2||lp=EC3||lp=EC4||lp=EC5 ) ) { ; EN_KILLFOCUS
ControlGetText,Text,, ahk_id %lp%
IfEqual,text,, ControlSetText,,<Enter Data Here>,ahk_id %lp%
}
}
GuiClose:
ExitApp |
 _________________
 |
|
| Back to top |
|
 |
totonf
Joined: 09 Apr 2008 Posts: 8
|
Posted: Tue Jul 15, 2008 3:12 am Post subject: |
|
|
Thank you very much!  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|