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 

GUI edit control

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



Joined: 09 Apr 2008
Posts: 8

PostPosted: Wed Jul 09, 2008 8:33 pm    Post subject: GUI edit control Reply with quote

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).
Confused
Back to top
View user's profile Send private message
ribbs2521



Joined: 28 Sep 2007
Posts: 103
Location: New York

PostPosted: Wed Jul 09, 2008 11:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
totonf!
Guest





PostPosted: Thu Jul 10, 2008 4:10 pm    Post subject: Reply with quote

I appreciate your idea, bravo.
Thanks a lot.
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Thu Jul 10, 2008 4:36 pm    Post subject: Reply with quote

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


Smile
_________________
Back to top
View user's profile Send private message
totonf



Joined: 09 Apr 2008
Posts: 8

PostPosted: Mon Jul 14, 2008 2:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon Jul 14, 2008 3:15 pm    Post subject: Reply with quote

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


Smile
_________________
Back to top
View user's profile Send private message
totonf



Joined: 09 Apr 2008
Posts: 8

PostPosted: Tue Jul 15, 2008 3:12 am    Post subject: Reply with quote

Thank you very much! Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   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