|
You could get the the Process object for that process by calling Process.GetProcesses[^] and then get the window handle of the process using Process.MainWindowHandle[^] property. Once you have the window handle, you could P/Invoke ShowWindow, passing the window handle and the corresponding message (SW_SHOWNORMAL = 1) as the parameter.
|
|
|
|
|
I like that, but you can still improve it:
rather than getting a collection of processes, and searching for the right handle,
you could obtain the process ID (a simple PInvoke to GetProcessId),
then use Process.GetProcessByID().
Luc Pattyn
|
|
|
|
|
I can't make it work, here is my try:
Process[] localByName = Process.GetProcessesByName("****");
if (localByName.GetLength() > 0)
{
IntPtr hWnd = localByName[0].MainWindowHandle;
if (!hWnd.Equals(IntPtr.Zero))
{
if (IsIconic(hWnd))
{
ShowWindow(hWnd, SW_RESTORE);
}
SetForegroundWindow(hWnd);
}
}
I have also try SW_RESTORE, SW_MAXIMIZE, SW_NORMAL, all failed.
Any ideas?
every art is science
every science is art
|
|
|
|
|
Lots of ideas:
- I dont recognize your approach; the original question had the process handle available,
and my original suggestion was to get all processes and search for the one with the
matching handle; you seem to rely on process names instead.
- I dont expect a process ever is named ****
- you must realize the process name should not include the ending ".exe" (unlike what is
shown by task manager)
- finding a process by name is not very safe, there could be many, even some you dont
expect; the original question was on a process known by ID (which is unique).
- getLength() needs one int parameter, your code would not even compile
- if it runs but fails to do what you hope, it is time to add log statements showing
intermediate values (the length of the process array, the process name,
the window handle, etc.), so you have a good chance of spotting the problems
if and when they arise. Actually you should add those statements before your first run,
since the first try is bound to fail anyway.
- I expect Process.MainWindowHandle to return zero for invisible windows, so when
iconified it wont work that way.
- Search CP for MainWindowHandle or use old Win32 functions and PInvoke (as in my
original reply).
Luc Pattyn
|
|
|
|
|
woow, a very profound reply. thumb
Yes, I should use getLength(0) rather than getLength(); You are absolutely right.
In our problem, basically we want to maximize another process window, which only allowed one instance.
Maybe use GetProcessbyId() is better, but in our case, I suppose the process handle I have got is also unique.
At the end of the day, I realized the problem was the **** application, which is also implemented by someone else(not me), disabled all system message except SW_MINIMIZE.
Anyway, thanks for all replies.
every art is science
every science is art
|
|
|
|
|
Hi,
Been searching on how to connect to a microsoft access db database located on a server like http://www.blablabla.se/myFolder/database.mdb
My working connection string is something like:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb";
and it works locally.
But how do i set up the connection string to a remotehost location with login and pwd?
Daniel S
|
|
|
|
|
You can not connect to an Access database via the HTTP protocol.
If you have the database on a different server, you need direct access to the server via the file system, so that you can use a path like "\\servername\folder\database.mdb", or map the folder on the server to a local drive letter.
---
Year happy = new Year(2007);
|
|
|
|
|
Hmm,
This is what i have to connect against ftp.infografix.nu and then i have login/pwd...
could you please supply how the connectionstring would look like cause i cant seem to get it to work
|
|
|
|
|
That looks more like an FTP account. You can't connect to an Access database using the FTP protocol either.
Do you have direct file access to the server where the database is? The database driver needs direct access to the database file through the file system.
---
Year happy = new Year(2007);
|
|
|
|
|
I have a c# listbox control that I want the ToolTip to vary depending on the item selected. How can I implement this?
Thanks
|
|
|
|
|
Make sure that
YourListView.ShowItemToolTips = true;
Then,
whenever you create an item, set its ToolTipText property to whatever you want, then add the item to the ListView, e.g.:
<br />
ListViewItem item = new ListViewItem("Something");<br />
item.ToolTipText = "...";<br />
YourListView.Items.Add(item);<br />
SkyWalker
|
|
|
|
|
SkyWalker:
Thanks but, myListBox does not have a property for ShowItemToolTips? I did put the toolTip control on the form. What am I doing wrong?
Thanks
|
|
|
|
|
Sorry for the misunderstanding, I was speaking of a ListView
SkyWalker
|
|
|
|
|
|
Hi.
Is it possible to display the text of a label control on more than one line?
I mean something like the multiline property of a textbox.
Thanks.
|
|
|
|
|
Have you tried adding Environment.NewLine?
|
|
|
|
|
Just like many other controls, Label knows about word wrapping, and it understands
the newline character (or better yet Environment.NewLine). It is all about giving it
an appropriate size, and let it do the work... Also keep an eye on the AutoSize property.
Luc Pattyn
|
|
|
|
|
What is the property or method that returns the row that the > pointer on the left hand side of the DataGridView? For example if a user clicks on a row the pointer moves to that row. Then if the user clicks a button to the side of the data grid view I want to know what row the > is pointing to.
|
|
|
|
|
DataGridView.CurrentRow returns the Row that contains the currently selected DataGridViewCell.
In addition, if you handle the DataGridView.RowHeaderClick event, you can check the e.RowIndex Property to see the row number that was clicked.
|
|
|
|
|
|
Hi
Anybody knows what is the difference between Application.Run(myForm) and myForm.Show()?
Thanks in advance
Muthu.
|
|
|
|
|
Application.Run(form) runs a message loop, it only return when the form closes.
Luc Pattyn
|
|
|
|
|
To Support what Luc said.
Application.Run(myForm);
MessageBox.Show("whee!");
Would wait for your form to close to display "whee!", while
myForm.Show()
MessageBox.Show("whee!");
Would open your form, then immediately show the messagebox.
If I have child forms in windows applications I'm running, I generally use Form.Show() Form.ShowDialog() depending on what I need. ShowDialog acts similarly to Application.Run(), in that it must return before code is executed in the parent, while Show() allows for parallel interaction.
|
|
|
|
|
I seem to remember that you can only have one message pump running per single threaded apartment. So Application.Run would bomb if a form was already loaded in the same apartment, whereas you could open as many form instances as you want with form.show()
Russell
|
|
|
|
|
Ah, you're right. I was trying to give an example of something visual that the user would see.
|
|
|
|