Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Visual J# / November 2004

Tip: Looking for answers? Try searching our database.

Opacity

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 26 Oct 2004 20:13 GMT
I've got a Windows Application with multiple forms.  One is the Menu.jsl form
and the other is a Checkers.jsl form.  The user clicks a button in the Menu
form to open Checkers.  When this happens, I want the opacity of Menu.jsl to
change to 50%.  When Checkers is closed, I want the opacity to return to 100%
(or 0%, whichever is a solid color, not transparent).  How can I do that?  I
can't do it completely in the Menu form because it doesn't recognize when the
Checkers form is open / closed.
Lars-Inge T?nnessen [VJ# MVP] - 01 Nov 2004 19:51 GMT
You can do that by using a reference to the Menu instance in the checker
form.

Here is an example I have written. In this example I'm setting a reference
to the Menu ("this")  instance in the Checker instance. From now on I can
reach the Menu instance from the Checker instance and do the set_Opacity
call on the Menu instance from the Checker instance.

_____________________________________
Menu.jsl file:

import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Data.*;

public class Menu extends System.Windows.Forms.Form
{
private Checker che = null;
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;

public Menu()
{
 InitializeComponent();
}

protected void Dispose(boolean disposing)
{
 if (disposing)
 {
  if (components != null)
  {
   components.Dispose();
  }
 }
 super.Dispose(disposing);
}

private void InitializeComponent()
{
 this.button1 = new System.Windows.Forms.Button();
 this.SuspendLayout();
 this.button1.set_Location(new System.Drawing.Point(96, 104));
 this.button1.set_Name("button1");
 this.button1.set_TabIndex(0);
 this.button1.set_Text("Checker");
 this.button1.add_Click( new System.EventHandler(this.button1_Click) );
 this.set_AutoScaleBaseSize(new System.Drawing.Size(5, 13));
 this.set_ClientSize(new System.Drawing.Size(292, 266));
 this.get_Controls().Add(this.button1);
 this.set_Name("Form1");
 this.set_Text("Form1");
 this.ResumeLayout(false);
}

/** @attribute System.STAThread() */
public static void main(String[] args)
{
 Application.Run(new Menu());
}

private void button1_Click (Object sender, System.EventArgs e)
{
 this.che = new Checker();
 this.che.parentForm = this;
 this.che.Show();
 this.set_Opacity( .50 );
}
}

_____________________________________
Checker.jsl file:

import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;

public class Checker extends System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
public Menu parentForm = null;

private System.ComponentModel.Container components = null;

public Checker()
{
 InitializeComponent();
}

protected void Dispose(boolean disposing)
{
 if (disposing)
 {
  if (components != null)
  {
   components.Dispose();
  }
 }
 super.Dispose(disposing);
}

private void InitializeComponent()
{
 this.button1 = new System.Windows.Forms.Button();
 this.SuspendLayout();
 this.button1.set_Location(new System.Drawing.Point(72, 56));
 this.button1.set_Name("button1");
 this.button1.set_TabIndex(0);
 this.button1.set_Text("Close");
 this.button1.add_Click( new System.EventHandler(this.button1_Click) );
 this.set_AutoScaleBaseSize(new System.Drawing.Size(5, 13));
 this.set_ClientSize(new System.Drawing.Size(292, 266));
 this.get_Controls().Add(this.button1);
 this.set_Name("Checker");
 this.set_Text("Checker");
 this.ResumeLayout(false);

}

private void button1_Click (Object sender, System.EventArgs e)
{
 this.parentForm.set_Opacity( 1 );
 this.Close();
}
}

Regards,
Lars-Inge T?nnessen
http://www.larsinge.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.