Fullscreen Form

Hello
Working with .net cf 2.0
The Problem:
I start an Application with a Mainform.
Inside the Mainform i start another form which should work as
a "Welcome Screen".
I want it to be fullscreen with a background picture.
So i derived my own form,
overrides the onpaint and onpainbackground method
set the WindowStyle to Maximized, disable the Minimize and Control Buttons
Set TopMost to true.
But when I show it, it displays the taskbar/start button
After clicking inside the form, it finaly redraws itself in fullscreen mode as wanted!
I tried differnt approaches
  • using the SHFullScreen funktion
  • Overriding OnLoad and OnActivated
but nothing works
Is this probably a bug in the .net cf 2.0 (its still beta)
Norbert
[827 byte] By [NorbertThek] at [2007-12-16]
# 1

Hi Norbert,

Do you have a piece of codes that demonstrate the issue? This way we can further investigate the issue.

Thanks,
Anthony

AnthonyWong at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2
here is the Code
First the "StartScreen" Form:


namespace MY_APP
{
public partial class Form_StartScreen : Form
{
Configurator cfg; // a helper class for storing configuration Data
public IRemoteServer theServer; // the Server Object
public Form_StartScreen()
{
theServer = null;
cfg = Configurator.GetInstance();
InitializeComponent();
// Set the address text
label_address.Text = cfg.ServerIPAddr[0] + ":" + (string)cfg.GetGenericValue("ServerPort");
}
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
Rectangle sourceRect = new Rectangle(0, 0, Properties.Resources.myapp_startscreen.Width, Properties.Resources.myapp_startscreen.Height);
e.Graphics.DrawImage(Properties.Resources.myapp_startscreen, ClientRectangle,
sourceRect, GraphicsUnit.Pixel);
}
protected override void OnPaint(PaintEventArgs e)
{
Brush br;
StringFormat sf = new StringFormat();
sf.Alignment= StringAlignment.Center;
foreach (Control c in Controls)
{
if (c is Label)
{
Label theLabel = (Label)c;
br = new SolidBrush(theLabel.ForeColor);
e.Graphics.DrawString(theLabel.Text, theLabel.Font, br, theLabel.Bounds, sf);
}
}
base.OnPaint(e);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
TopMost = true;
this.WindowState = FormWindowState.Maximized;
//Form_StartScreen.SHFullScreen(this.Handle, SHFS_HIDESTARTICON);
}
protected override void OnActivated(EventArgs e)
{
TopMost = true;
this.WindowState = FormWindowState.Maximized;
//Form_StartScreen.SHFullScreen(this.Handle, SHFS_HIDESTARTICON);
Invalidate();
}
private void button_Cancel_Click(object sender, EventArgs e)
{
this.Close();
}
protected override void OnClick(EventArgs e)
{
//This code handles the problem, that sometimes the Button doesn't get the event
if (Control.MousePosition.Y > button_Cancel.Top &&
Control.MousePosition.Y < button_Cancel.Bottom)
if (Control.MousePosition.X > button_Cancel.Left &&
Control.MousePosition.X < button_Cancel.Right)
{
button_Cancel_Click(this, e);
return;
}
Cursor.Current = Cursors.WaitCursor;
// When the User tap on the form I "start the Apllication" connected
// when cancel the User get the "Config Screen" of the MainForm.
int port = Convert.ToInt32((string)cfg.GetGenericValue("ServerPort"));
try
{
theServer = new RemoteTCPServer(cfg.id, cfg.ServerIPAddr[0], port, 0);
}
catch (Exception ex)
{
string errortext = Properties.Resources.Con_Error_Text1 + "\r\n" + ex.Message + "\r\n";
errortext += "\r\n" + Properties.Resources.Con_Error_Text2;
MessageBox.Show(errortext, Properties.Resources.Con_Error_Header, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
if (theServer != null)
theServer.Dispose();
theServer = null;
}
Cursor.Current = Cursors.Default;
base.OnClick(e);
}
}
}
// This is an extract from the Initalizecomponents Method
/*
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(240, 320);
this.ControlBox = false;
this.Controls.Add(this.button_Cancel);
this.Controls.Add(this.label_info);
this.Controls.Add(this.label_address);
this.Controls.Add(this.label2);
this.Controls.Add(this.label_header);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Location = new System.Drawing.Point(0, 0);
this.MinimizeBox = false;
this.Name = "Form_StartScreen";
this.TopMost = true;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ResumeLayout(false);
*/


####################################################
and here how i call it in the main form:


//In the constructor I create the form
public MainForm()
{
startscreen = new Form_StartScreen();
startscreen.Click += new EventHandler(startscreen_Click); // This method handles some connecting stuff
/// lots of other configuration
}
// in the onLoad function i "show" the startscreen
// I tried OnActivate , but it also doesnt worked
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
startscreen.Show();
}

NorbertThek at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3

Hi Norbert,

You also need to set the splash screen form's form border style to FormBorderStyle.None, as well as making the splash screen form a modal form. Here are some sample codes for your reference:



using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

class Form1 : System.Windows.Forms.Form
{
public Form1()
{
this.MinimizeBox = false;
Form2 form = new Form2();
form.ShowDialog();
}

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

public class Form2 : System.Windows.Forms.Form
{
public Form2()
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.TopMost = true;
this.BackColor = Color.Green;
Timer timer = new Timer();
timer.Interval = 3000;
timer.Tick += new EventHandler(timer_Tick);
timer.Enabled = true;
}

protected override void OnPaint(PaintEventArgs e)
{
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
Graphics g = e.Graphics;
g.DrawString(".NET Compact Framework", this.Font, new SolidBrush(Color.Blue), Screen.PrimaryScreen.Bounds, sf);
}

void timer_Tick(object o, EventArgs e)
{
this.Close();
}
}

Cheers,
Anthony

AnthonyWong at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 4
Hi
If have done this through the designer seetings
Here is the code of the "InitializeComponent" method


private void InitializeComponent()
{
this.label_header = new System.Windows.Forms.Label();
this.button_Cancel = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label_address = new System.Windows.Forms.Label();
this.label_info = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label_header
//
this.label_header.BackColor = System.Drawing.Color.Black;
this.label_header.Font = new System.Drawing.Font("Arial", 18F, System.Drawing.FontStyle.Bold);
this.label_header.ForeColor = System.Drawing.Color.Gainsboro;
this.label_header.Location = new System.Drawing.Point(0, 66);
this.label_header.Name = "label_header";
this.label_header.Size = new System.Drawing.Size(240, 58);
this.label_header.Text = "Welcome to \r\nAVL-DRIVE?";
this.label_header.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.label_header.Visible = false;
//
// button_Cancel
//
this.button_Cancel.BackColor = System.Drawing.Color.Ivory;
this.button_Cancel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button_Cancel.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Bold);
this.button_Cancel.ForeColor = System.Drawing.SystemColors.WindowText;
this.button_Cancel.Location = new System.Drawing.Point(0, 290);
this.button_Cancel.Name = "button_Cancel";
this.button_Cancel.Size = new System.Drawing.Size(240, 30);
this.button_Cancel.TabIndex = 1;
this.button_Cancel.Text = "Cancel";
this.button_Cancel.Click += new System.EventHandler(this.button_Cancel_Click);
//
// label2
//
this.label2.BackColor = System.Drawing.SystemColors.WindowText;
this.label2.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Bold);
this.label2.ForeColor = System.Drawing.SystemColors.Window;
this.label2.Location = new System.Drawing.Point(3, 214);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(240, 22);
this.label2.Text = "Last connected to:";
this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.label2.Visible = false;
//
// label_address
//
this.label_address.BackColor = System.Drawing.SystemColors.WindowText;
this.label_address.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Bold);
this.label_address.ForeColor = System.Drawing.SystemColors.Window;
this.label_address.Location = new System.Drawing.Point(3, 236);
this.label_address.Name = "label_address";
this.label_address.Size = new System.Drawing.Size(240, 29);
this.label_address.Text = "127.0.0.1:700";
this.label_address.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.label_address.Visible = false;
//
// label_info
//
this.label_info.BackColor = System.Drawing.SystemColors.WindowText;
this.label_info.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Bold);
this.label_info.ForeColor = System.Drawing.SystemColors.Window;
this.label_info.Location = new System.Drawing.Point(3, 265);
this.label_info.Name = "label_info";
this.label_info.Size = new System.Drawing.Size(240, 22);
this.label_info.Text = "Tap on Screen to connect!";
this.label_info.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.label_info.Visible = false;
//
// Form_StartScreen
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(240, 320);
this.ControlBox = false;
this.Controls.Add(this.button_Cancel);
this.Controls.Add(this.label_info);
this.Controls.Add(this.label_address);
this.Controls.Add(this.label2);
this.Controls.Add(this.label_header);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Location = new System.Drawing.Point(0, 0);
this.MinimizeBox = false;
this.Name = "Form_StartScreen";
this.TopMost = true;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ResumeLayout(false);

NorbertThek at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...