Click to See Complete Forum and Search --> : [RESOLVED] displaying the today screen from code.
Ramakin
Jun 6th, 2007, 06:38 AM
I wish to be able to minimise any and all application running on a Windows Mobile 5+ device and display the today screen but this seems to be getting the better of me.
Does anyone have any thoughts or ideas how to do this?:confused:
Phade
Jun 7th, 2007, 09:12 AM
I don't do to much programming with VB.NET So I really haven't made anything for my phone but I do use WisBar Advance and WisBar Desktop. Basicly you can customize the whole desktop use custom text (Example %Batt% to display the percentage of battery left etc) I find it's a really good customize tool for a PocketPC. Really good for skinning and also provides a taskbar so you can minimize or really and truley (X) close out a program. Hope this helps.
Links to program http://www.lakeridgesoftware.com/products.php?prod=WisBar+Advance
Ramakin
Jun 7th, 2007, 11:43 AM
Thank you for your reply but it doesnt help me in what I want to do. however I am sure it will help others as they read through these posts.
I really need to be able to either minimise an already running program or call the Today screen so it displays that instead of the application in other word forces it to minimise by putting the Today screen first.
sapator
Jun 8th, 2007, 04:06 AM
Here is a code sample i've found that minimizes a form.
I have not tested it so i cannot say if it's accurate but you can try it.
using System;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
public class Test : System.Windows.Forms.Form
{
CheckBox ckMinimizeBox;
public Version CLRVersion = null;
public Test()
{
this.Text = "click on the (x)";
// this is the default value
this.MinimizeBox = true;
CLRVersion = System.Environment.Version;
Label label = new Label();
label.Text = string.Format("NETCF ver {0}.{1}.{2}.{3}",
CLRVersion.Major,
CLRVersion.Minor,
CLRVersion.Revision,
CLRVersion.Build);
label.Parent = this;
label.Bounds = new Rectangle(10, 10, 200, 30);
ckMinimizeBox = new CheckBox();
ckMinimizeBox.Parent = this;
ckMinimizeBox.Bounds = new Rectangle(10, 50, 200, 30);
ckMinimizeBox.Text = "MinimizeBox";
ckMinimizeBox.Checked = this.MinimizeBox;
ckMinimizeBox.CheckStateChanged += new EventHandler(this._Checked);
Button bClose = new Button();
bClose.Parent = this;
bClose.Bounds = new Rectangle(10, 90, 200, 30);
bClose.Text = "Form.Close()";
bClose.Click += new EventHandler(this._Click);
}
void _Checked(object o, EventArgs e)
{
this.MinimizeBox = ckMinimizeBox.Checked;
}
void _Click(object o, EventArgs e)
{
this.Close();
}
protected override void OnClosing(CancelEventArgs e)
{
DialogResult result = MessageBox.Show("allow form to close?",
"Application Exiting",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1
);
e.Cancel = (result != DialogResult.Yes);
}
static void Main(string[] args)
{
Test x = new Test();
Application.Run(x);
}
}
Ramakin
Jun 8th, 2007, 04:22 AM
Thank you again, but if my reading of C# is right then this is to minimise a form within your own application.
Again I am really thankful for any and all help, its really kind of you to take time out of your day and try and help me and will eat my words and send you some virtual chocolates if I have misread this, however I need to be able to minimise an external application.
Very much like you can do in WinXP using the shell command Shell(i.e. "C:\Program Files\OtherApp\OtherApp.exe", AppWinStyle.MinimizedNoFocus))
however Shell is not supported on CF2.0 that I can see, everything MSDN says not supported and if you try and use Shell it just returns with "File Not Found" exception.
So I use Process.Start (i.e. Process.Start("\Program Files\OtherApp\OtherApp.exe")) this works 100% on a Pocket PC but like I said before I really want to run this minimised or find a way to get hold of the application and minimise it once it is running OR better still find out what exe or dll is used in displaying the Today Screen and call that so it minimises all applications currently running on my device so I just get the Today Screen showing.
sapator
Jun 8th, 2007, 05:35 AM
ACtually you can use the "CreateProcess" API function of the coreDll of windows mobile, to open an application
Overloads Declare Function CreateProcess Lib "CoreDll.dll" (ByVal imageName As String, ByVal cmdLine As String, ByVal lpProcessAttributes As IntPtr, ByVal lpThreadAttributes As IntPtr, ByVal boolInheritHandles As Int32, ByVal dwCreationFlags As Int32, ByVal lpEnvironment As IntPtr, ByVal lpszCurrentDir As IntPtr, ByVal si As Byte(), ByVal pi As ProcessInfo) As Integer]
im not sure if it take a minimize parameter.
Also there i"SetWindowPos"
Declare Auto Function SetWindowPos Lib "user32" (ByVal hWnd As IntPtr, _
ByVal hWndInsertAfter As IntPtr, _
ByVal X As Integer, _
ByVal Y As Integer, _
ByVal cx As Integer, _
ByVal cy As Integer, _
ByVal uFlags As UInteger) As Boolean
I know that you can minimize objects with public const int SWP_HIDEWINDOW = 0x0080;
Again not sure if you can minimize an application. Probably you must get the handle of the application (this.handle or something like that) and try...
Here is a sample from pinvoke
Consts
public const int SWP_ASYNCWINDOWPOS = 0x4000;
public const int SWP_DEFERERASE = 0x2000;
public const int SWP_DRAWFRAME = 0x0020;
public const int SWP_FRAMECHANGED = 0x0020;
public const int SWP_HIDEWINDOW = 0x0080;
public const int SWP_NOACTIVATE = 0x0010;
public const int SWP_NOCOPYBITS = 0x0100;
public const int SWP_NOMOVE = 0x0002;
public const int SWP_NOOWNERZORDER = 0x0200;
public const int SWP_NOREDRAW = 0x0008;
public const int SWP_NOREPOSITION = 0x0200;
public const int SWP_NOSENDCHANGING = 0x0400;
public const int SWP_NOSIZE = 0x0001;
public const int SWP_NOZORDER = 0x0004;
public const int SWP_SHOWWINDOW = 0x0040;
Code:
public void HideStartBar()
{
IntPtr handle;
try
{
// Find the handle to the Start Bar
handle = FindWindowW("HHTaskBar", null);
// If the handle is found then hide the start bar
if (handle != IntPtr.Zero)
{
// Hide the start bar
SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);
}
}
catch
{
MessageBox.Show("Could not hide Start Bar.");
}
}
public void ShowStartBar()
{
IntPtr handle;
try
{
// Find the handle to the Start Bar
handle = FindWindowW("HHTaskBar", null);
// If the handle is found then show the start bar
if (handle != IntPtr.Zero)
{
// Show the start bar
SetWindowPos(handle, 0, 0, 0, 240, 26, SWP_SHOWWINDOW);
}
}
catch
{
MessageBox.Show("Could not show Start Bar.");
}
}
If that doesn't work try to use some other functions from the Core.dll
sapator
Jun 8th, 2007, 05:53 AM
Also have a look
http://msdn2.microsoft.com/en-us/library/aa453662.aspx
Ramakin
Jun 8th, 2007, 10:41 AM
thanks sapator, your code has helped me work out exactly what I wanted to do.
sapator
Jun 8th, 2007, 05:38 PM
No problem ( i want my virtual chocolates now :) )
You can mark this thread as resolved if you like, for better reading.
Ramakin
Jun 11th, 2007, 02:21 AM
I have thank you and I am e-mailing the virtual salesman, to sort out your virtual chocolates...
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.