Form.Hide

B

bhavin

Hi,
I need a application running on the PPC without any interface, like a
windows service. Is it possible in the CF?

Googling for it didn't really give me any relevant tips. So I thought of
creating a Form and the Hiding it in the constructor itself, and then
quietly keep doing what the application needs to do. Not too neat, but would
work I thought.

Wrong!
this.Hide() in the Application (Form) constructor doesnt seem to work for
some reason. Any thing special I need to do here?

If I try doing a this.Hide in a GotFocus event handler, it kind of works
(form dissapears but the main menu, with the keyboard control still shows).
also inside this eventhandler if I have a messagebox, the form doesnt
disappear. I am thinking there is something to do with the screen refresh
maybe.

I've attached the code of a test form I created.
really appreciate any help. on the Service issue, as well as Form hiding.

tia
-bh

********************** code *****************************
public Form1()
{
InitializeComponent();

this.FormBorderStyle = FormBorderStyle.None;
// this.Size = new Size(0,0);
// this.Hide();
this.GotFocus += new EventHandler(Form1_GotFocus);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.Menu = this.mainMenu1;
this.Text = "Form1";

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>

static void Main()
{
Application.Run(new Form1());
}

private void Form1_GotFocus(object sender, EventArgs e)
{
// MessageBox.Show("got focus");
this.Hide();
}

***************************************************
 
A

Alex Feinman [MVP]

Why not choose a "command line application" as a project ttype? That creates
a windowless application. Of course you will need to do sometihng to prevent
it from quitting prematurely. Typically such app should wait for some event
and then kick in, do some work and go back to sleep
 
C

Chris Tacke, eMVP

Simply don't create a Form in your Main. Don't use Application.Run, but
instead write some form of loop or whatever for your app construct.

-Chris
 
B

bhavin

I will try to do it that way. But any thoughts on why the Form.Hide behaves
such unexpectedly?
Is some part of the application or Screen not repainting itself right?

-bh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top