FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

beginner needs help

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
rko



Joined: 24 May 2006
Posts: 12

PostPosted: Wed May 24, 2006 1:13 am    Post subject: beginner needs help Reply with quote

hi,

is there any demo that shows how to change the background color in a textbox when it gets focus and when it looses focus?
any help or demo code is greatly apprechiated.

rko
________
penny stock picks


Last edited by rko on Sun Feb 06, 2011 9:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed May 24, 2006 9:12 am    Post subject: Re: beginner needs help Reply with quote

Attach some event handlers:
Code:
mytextbox.gotFocus ~= &mytextbox_gotFocus;
mytextbox.lostFocus ~= &mytextbox_lostFocus;

and their code:
Code:
private void mytextbox_gotFocus(Object sender, EventArgs ea)
{
   mytextbox.backColor = Color(0xFF, 0, 0); // Red bg.
}

private void mytextbox_lostFocus(Object sender, EventArgs ea)
{
   mytextbox.backColor = mytextbox.defaultBackColor; // Reset bg.
}


Full source: http://www.dprogramming.com/colorboxdemo.html

- Chris
Back to top
View user's profile Send private message
rko



Joined: 24 May 2006
Posts: 12

PostPosted: Thu May 25, 2006 8:37 am    Post subject: Reply with quote

thanx chris.

his works fine. i know i am asking a lot but could you also tell me how to make a form opaque if the mainform looses the focus, lets say to an e-mail client or another program?

thanx

rko
________
FERRARI 312


Last edited by rko on Wed Mar 09, 2011 5:01 am; edited 1 time in total
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Thu May 25, 2006 1:06 pm    Post subject: Reply with quote

Try the Form's events `activated` and `deactivate`, and property `opacity`. opacity 0 is completely invisible, 1 is completely visible, and between are percentages; e.g. 0.75 is 75? opaque.
Back to top
View user's profile Send private message
rko



Joined: 24 May 2006
Posts: 12

PostPosted: Fri May 26, 2006 8:29 am    Post subject: Reply with quote

thanx for the reply.

i tried the following:

activated ~= delegate void(Object o, EventArgs ea){opacity = 1.0;};
deactivate ~= delegate void(Object o, EventArgs ea){opacity = 0.5;};

on starting the program, it works. when i than click on another window, like the explorer, the form application throws an exception.

rko
________
T Series


Last edited by rko on Wed Mar 09, 2011 5:01 am; edited 1 time in total
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Fri May 26, 2006 2:06 pm    Post subject: Reply with quote

See the FAQ at the bottom of http://www.dprogramming.com/dfl.php and make your event handlers like the ones in my first example.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group