View previous topic :: View next topic |
Author |
Message |
rko
Joined: 24 May 2006 Posts: 12
|
Posted: Wed May 24, 2006 1:13 am Post subject: beginner needs help |
|
|
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 |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Wed May 24, 2006 9:12 am Post subject: Re: beginner needs help |
|
|
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 |
|
|
rko
Joined: 24 May 2006 Posts: 12
|
Posted: Thu May 25, 2006 8:37 am Post subject: |
|
|
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 |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Thu May 25, 2006 1:06 pm Post subject: |
|
|
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 |
|
|
rko
Joined: 24 May 2006 Posts: 12
|
Posted: Fri May 26, 2006 8:29 am Post subject: |
|
|
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 |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Fri May 26, 2006 2:06 pm Post subject: |
|
|
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 |
|
|
|