not full screen window

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I write an .NET CF Application in C# which should show an additional form in
a not full screen window.

The first question:
Only if I set FormBorderStyle= None I get a not full screen form.
I can center it if I set its Location
this.Location = new Point((screen.Width - this.Width) / 2, (screen.Height -
this.Height ) / 2);
But is has absolutely no frame, because I set it to none.
Is there an other way, I do not see, to get the form not full screened?

If there's no pssibility here is my second question:
Can I use an other control which is showing afrem in the background? It has
to be moveable and resizable.
MessageBox which shows a small window dosn't work because it has only the
static Show() method and is no object. An inputbox dosn't exist in C#.
Is there some window- control?
 
Hello
You can try this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using OpenNETCF.Win32;

namespace Example.Client {
public partial class NotFullScreenView : Form {

public NotFullScreenView () {
InitializeComponent();
this.Capture = true;
IntPtr hWnd = Win32Window.GetCapture();
this.Capture = false;
int style = (int)(WS.BORDER | WS.CAPTION | WS.DLGFRAME);
Win32Window.SetWindowLong(hWnd, GWL.STYLE, style);
Rectangle screen = Screen.PrimaryScreen.WorkingArea;
Win32Window.SetWindowPos(hWnd, HWND.TOP, ((screen.Width - this.Width)
/ 2), ((screen.Height - this.Height) / 2), this.Width, this.Height,
SWP.NOACTIVATE);
}

private void InitializeComponent() {
[...] - code generated via VS
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(195, 171);
this.ControlBox = false;
this.Controls.Add(this.glownyPnl);
this.Font = new System.Drawing.Font("Tahoma", 8.25F,
System.Drawing.FontStyle.Regular);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "NotFullScreenView ";
this.Text = "Title";
this.glownyPnl.ResumeLayout(false);
this.ResumeLayout(false);
}

}

The piece of code in method InitializeComponent shows you how properties
were set in designe time...
If you want display OK button on caption you can look at method:
Win32Window.SetWindowLong(hWnd, GWL.EXSTYLE, style);
For example:
int style = (int)(WS.BORDER | WS.CAPTION | WS.DLGFRAME);
Win32Window.SetWindowLong(hWnd, GWL.STYLE, style);
style = (int)(WS_EX.DLGMODALFRAME | WS_EX.CAPTIONOKBUTTON);
Win32Window.SetWindowLong(hWnd, GWL.EXSTYLE, style);

Cheers
Papros Marcin
 
Back
Top