An alternative for (small) Modal Dialog Box in compact framework ?

G

Guest

Hi,

I'd like to add to my PPC app a kind of modal dialog window, which does NOT
stretch over the whole display. Unfortunately, that's exactly what all new
forms in compact framework do by default. (This default rule perpahs made
sense with small displays, but currently on PPC with 640x480..?) The only
workaround I found so far is to set

form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

but then the form/window is borderless, has no caption, etc.
So my idea is to use WinCE APIs DialogBox(), EndDialog(), and
GetDlgItemxxx(). However, I can't figure out how to test this in emulator,
because it is not clear in which LIB or DLL these APIs are exported. I tried
COREDLL and DLGMGR, but without success.
Also, I didn't find a way how to make my VS 2005 PPC project aware of my
compiled resource file (res) with dialog window template. I can add it to
the project as a file, that's not the problem, but then I would expect to see
and be able to use defines from this resource in other project files, but it
does not work :-(
So I would be really gretaful if someone could post a code snippet, or point
me to a doc, which explains this.

Many thanks !
 
S

s_alexander04

Maybe to set

form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

and then paint the caption and borders by yourself in the Paint event?
I dont think it's difficult.
You can place on this form Panel control leaving enough room for
caption and borders. This Panel would be client area for controls of
your form.

Aleks
 
S

s_alexander04

try to play with this form :
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace SmartDeviceApplication1 {
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form {
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label Caption;
private System.Windows.Forms.Panel panel1;

public Form2() {
//
// Required for Windows Form Designer support
//
InitializeComponent();
button1.DialogResult=DialogResult.OK;
//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <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.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.Caption = new System.Windows.Forms.Label();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.Window;
this.panel1.Controls.Add(this.button1);
this.panel1.Location = new System.Drawing.Point(1, 22);
this.panel1.Size = new System.Drawing.Size(182, 121);
//
// button1
//
this.button1.Location = new System.Drawing.Point(56, 72);
this.button1.Text = "OK";
//
// Caption
//
this.Caption.Font = new System.Drawing.Font("Microsoft Sans Serif",
9F, System.Drawing.FontStyle.Regular);
this.Caption.ForeColor =
System.Drawing.SystemColors.ActiveCaptionText;
this.Caption.Location = new System.Drawing.Point(6, 4);
this.Caption.Size = new System.Drawing.Size(172, 18);
this.Caption.Text = "Caption";
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
//
// Form2
//
this.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.ClientSize = new System.Drawing.Size(184, 144);
this.Controls.Add(this.panel1);
this.Controls.Add(this.Caption);
this.Location = new System.Drawing.Point(50, 50);
this.Text = "Form2";
this.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.Form2_MouseDown);
this.MouseUp += new
System.Windows.Forms.MouseEventHandler(this.Form2_MouseUp);
this.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.Form2_MouseMove);

}
#endregion
int Xdif,Ydif;
bool moving=false;
private void Form2_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e) {
moving=true;
Xdif=e.X;
Ydif=e.Y;
}

private void Form2_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e) {
moving=false;
}
private void Form2_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e) {
if(moving)
Location=new Point(Location.X+e.X-Xdif,Location.Y+e.Y-Ydif);
}
}
}
 
S

s_alexander04

or with this


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

namespace SmartDeviceApplication1 {
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form {
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label Caption;
private System.Windows.Forms.Panel panel1;

public Form2() {
//
// Required for Windows Form Designer support
//
InitializeComponent();
button1.DialogResult=DialogResult.OK;
//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <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.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.Caption = new System.Windows.Forms.Label();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.Window;
this.panel1.Controls.Add(this.button1);
this.panel1.Location = new System.Drawing.Point(1, 22);
this.panel1.Size = new System.Drawing.Size(182, 121);
//
// button1
//
this.button1.Location = new System.Drawing.Point(56, 72);
this.button1.Text = "OK";
//
// Caption
//
this.Caption.Font = new System.Drawing.Font("Microsoft Sans Serif",
9F, System.Drawing.FontStyle.Regular);
this.Caption.ForeColor =
System.Drawing.SystemColors.ActiveCaptionText;
this.Caption.Location = new System.Drawing.Point(6, 4);
this.Caption.Size = new System.Drawing.Size(172, 18);
this.Caption.Text = "Caption";
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
//
// Form2
//
this.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.ClientSize = new System.Drawing.Size(184, 144);
this.Controls.Add(this.panel1);
this.Controls.Add(this.Caption);
this.Location = new System.Drawing.Point(50, 50);
this.Text = "Form2";
this.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.Form2_MouseDown);
this.MouseUp += new
System.Windows.Forms.MouseEventHandler(this.Form2_MouseUp);

}
#endregion

int Xdif,Ydif;
private void Form2_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e) {
Xdif=e.X;
Ydif=e.Y;
}
private void Form2_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e) {
Location=new Point(Location.X+e.X-Xdif,Location.Y+e.Y-Ydif);
}

}
}
 

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