 |
|
 |
How can i use it with windows CE 5.0 Device
|
|
|
|
 |
|
 |
I am a newbi to this stuff, but is there any easy way to get this working on Compact Framework
Best Regards
Mikael
|
|
|
|
 |
|
|
 |
|
 |
This solution works for me
public class ThisApp : Form
{
private const int WM_ACTIVATE = 0x0006;
private const int WA_ACTIVE = 1;
public static void Main(string[] args)
{
IntPtr prevInstance = FindWindow(IntPtr.Zero, "This app name"); // this will find also hidden forms
if (prevInstance != IntPtr.Zero)
PostMessage(prevInstance, WM_ACTIVATE, WA_ACTIVE, 0);
else
Application.Run(new ThisApp());
}
public ThisApp()
{
loaded = false;
// do initialization here
loaded = true;
}
protected override void OnActivated(EventArgs e)
{
if (loaded)
{
// do what you want to do if somebody runs this app again (eg. Visible = true; etc.)
}
base.OnActivated(e);
}
[DllImport("coredll.dll", SetLastError=true)]
private static extern int PostMessage(IntPtr hWnd, int nMsg, int wParam, int lParam);
[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr FindWindow(IntPtr wClass, string title);
}
|
|
|
|
 |
|
 |
Hi,
I saw the unanswared question and I still needs it. Anyone knows what can be done to show an application that is hidden in the notification area? Is there a way to raise an event on this application and hande it?
Thanks
|
|
|
|
 |
|
|
 |
|
 |
:-> I need to do this on a PDA, so how do I do it on Windows CE??
|
|
|
|
 |
|
 |
With stuff like remote desktop you could have multiple user using on different location running on the same PC.
thus user A could bring windows of user B and fail it launch on his desktop, if you see what I mean.
What do you think of that?
Any work around?.... maybe this new SessionId in 2.0 ?....
|
|
|
|
 |
|
 |
hi,
Anybody try to change the name of the application. Suppose the app name is "abc.exe", I copy this one into another place and named "ac.exe". For the code uses GetProcessByName, there is always 1 item in array, and 2 instance of 2 1-code-base-but-different-name-app instances.
I've looked at another solution that using GetProcessByID and also do simple test by running abc.exe and ac.exe, 2 instance create 2 different process id.
It seems a solution that assign a specific process id when create instance (i didn't try) but it sounds bad.
Using MainWindowHandle, do you mean to get the handle of the main window of the app (as documented: "Gets the window handle of the main window of the associated process")? What if my app does not start by create an instance of a form but I have some initialization before. I mean, if get the handle of the window, it's too late for I initialize my variables (or something else) before.
Any solution for this?
(Sorry for my poor English
wdyl
|
|
|
|
 |
|
 |
Hello,
In addition to bringing the application into the foreground I
need the window to be "active". Specifically, my form hosts
a WebBrowser control and has a page up. The HTML components on
the page can be navigated using the arrow keys (from a keyboard
or those on an infrared remote control) to go from one
component to the next. I need the control selected in order for
this to work and I've tried everying (well, everything I could
think of).
The only way I have been able to activate it is to click on it
with a mouse and I need to avoid that as I use the infrared
remote control to move around the page and interact with it.
Can anyone help?
Thanks
|
|
|
|
 |
|
 |
Is there a 100% NET way to do this. I mean without importing functions from user32.dll?
|
|
|
|
 |
|
 |
The only solution I can think of involves mutexes and possibly a UI thread that when signalled tells the application to put itself in the foreground.
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
 |
|
 |
Hi,
There is an easier way to detect single instance by using a Mutex.
Example code (c#)
bool wasCreated;
Mutex MyMutex = new Mutex(true,"myappshouldrunonce",out wasCreated);
if (!wasCreated)
{
return;
}
// .. continue with app as planned
|
|
|
|
 |
|
 |
Guido_d wrote:
There is an easier way to detect single instance by using a Mutex.
Functionally, this is different. The code I presented brings the other application to the foreground. The code you suggest simply exits the current application. Imagine the deluge of technical support calls "I keep clicking on the icon, and nothing happens!" Even a "this application is already open" message is a sad excuse--if the program can detect that the same app is running, then why not help the user out a bit?
This is the difference between programmer oriented thinking and user oriented thinking--sure, your code is easier for the programmer, but it isn't easier for the user.
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
 |
|
 |
In my app(just like yahoo/msn messenger) i hide the window when the user minimises, so when he he tries to open a new instance
"processes[n].MainWindowHandle" will always return 0...
Any easy solution for this ???????
right now i do a Findwindow then do a sendmessage
"SendMessage(FindWindow(0,"My app"),786,0,0);"
then do a override of winproc , capture the message and do a .Show() there
Regards,
Neo
|
|
|
|
 |
|
 |
Hi, Extracted from MSDN Library:
You can get the MainWindowHandle property only for processes that are running on the local computer. The MainWindowHandle property is a value that uniquely identifies the window that is associated with the process.
A process has a main window associated with it only if the process has a graphical interface. If the associated process does not have a main window, the MainWindowHandle value is zero.
|
|
|
|
 |
|
 |
Hi,
First of all thanks for a great article that clearly explains how to solve the presented problem. I've implemented the code in a real life solution and thereby came across the following problem.
There is a slight problem with the Process class when the name of the process exeeds 15 characters. Process.ProcessName wil only return the first 15 characters of the name, but passing these 15 characters to Process.GetProcessesByName wil return no processes as this method needs the full name.
As far as I'm able to see the only solution to the problem is to keep the name of the process below 15 characters.
|
|
|
|
 |
|
 |
Try GetProcessByID() instead to overcome this limitation.
|
|
|
|
 |
|
 |
Your code is now included in RSS Bandit 1.0d.
Added code to ensure that only one instance of RSS Bandit can be launched at a given time. Used code from http://www.codeproject.com/csharp/oneProcessOnly.asp
RSS Bandit[^]
Don't and drive.
|
|
|
|
 |
|
 |
Hello all highly friends,;P
The article is very good, but I have a small question If I close the application but it doesn't exit completely. It just goes to the right of the task bar. And then I had made a new proccess with the same application, of course it didn't make a new proccess but the application doesn't restore So how can I restore it?
Thanks alot for your reading
Qui
|
|
|
|
 |
|
 |
Does anyone figure out how to do this????
Panda
|
|
|
|
 |
|
|
 |
|
 |
public class ProcessRunning
{
public ProcessRunning(){}
public static void InstanceCheck()
{
// get the name of our process
string proc=Process.GetCurrentProcess().ProcessName;
// get the list of all processes by that name
Process[] processes=Process.GetProcessesByName(proc);
// if there is more than one process...
if (processes.Length > 1)
{
// get our process
Process p=Process.GetCurrentProcess();
if(MessageBox.Show("There is already another instance of this app Running, Would you like to end it and Contine with this one?","App already Running",MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes)
{
//Loop throught and kill the other processes
for(int j=0;j |
|
|
|
 |
|
 |
Yes, this is a good idea for certain applications where it would be wierd to simply pop up an already running app. I guess I wanted to leave this option to the specific programmer's requirement, instead of hardcoding it in this class. Of course, what I really should have done is made this into a function that returns a bool indicating whether the app is already running!
Marc
|
|
|
|
 |
|
 |
right -- this is a great solution!
I have some apps that only run in UI mode if they are not scheduled. And now I can kill the scheduled app if it is running and let the IT admins run the app manually when necessary.
|
|
|
|
 |