|
It may also be the fact that the GZipStream in the framework is managed and might be slowing things down slightly whereas the one in explorer is unmanaged.
Just a thought although I think the previous comment is more likely.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
I have a program (which I didn't write) which I run from a shell (which I did write).
The program I didn't write minimizes to the system tray upon startup.
In my shell I would like to create a method to restore the program from the system tray. I have the process handle, but I'm not sure what I should do with it. I suspect I have to do some fancy windows API stuff, but not sure what.
Any pointers in the right direction would be really helpful
Cheers
triff
|
|
|
|
|
this will require several PInvokes to Win32 functions; I do not know all the details, but
this I can tell you:
you need to get a handle to the main window of that process,
then send a message to that window with ShowWindow(SW_SHOWNORMAL).
Getting the main window is not straightforward,
you probably need EnumWindows() which enumerates all top-level windows,
and then some means to recognize the one you need,
either based on its title or its main thread's ID (GetWindowThreadProcessId)
Careful though, there is a Thread.ID in .NET, I am not sure it corresponds to the
Win32 thread ID.
Luc Pattyn
|
|
|
|
|
triff wrote: fancy windows API stuff
I believe you would have to use the SendMessage() API which of course requires a HWND, so you need to look into the API's for Processes and Threads to get the HWND from the Process Handle. Something like EnumThreadWindows() maybe.
led mike
|
|
|
|
|
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.
|
|
|
|