Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

OpenIcon not restoring to previous size

Posted on 2007-07-25
3
Medium Priority
?
391 Views
Last Modified: 2013-12-17
Using C# - Visual Studio 2005

The documentation for OpenIcon says that it will restore a window to its previous size
and location. This isn't happening - it is restoring the window, but It only restores it to its previous size/location if it was not maximized. I want it to go back to however it was displayed before the user sent it to the taskbar. Is there something extra that needs to be done when calling it from C#?
The ReturnValue indicates success.

My original code:

[DllImport("user32.dll")]
static extern bool OpenIcon(IntPtr hwnd);
...
IntPtr wHandle = process.MainWindowHandle;
bool ReturnValue = OpenIcon (wHandle);
 
On suggestion, I modified the code to:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
        [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool OpenIcon(HandleRef hwnd);
...
HandleRef HandleReference = new HandleRef(new Object(), process.MainWindowHandle);
OpenIcon (HandleReference);

This behaves the same way, which was not that surprising to me since it doesn't appear to be a
problem with the garbage collector/object not being found.

0
Comment
Question by:mrnbnf
3 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1800 total points
ID: 19568048
Try using ShowWindow() with SW_RESTORE instead:
http://msdn2.microsoft.com/en-us/library/ms633548.aspx
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 200 total points
ID: 19568067
From my understanding of OpenIcon, it restores a minimized window to its previous size and location, and not the window state.

Are you working with windows outside of your application?  

Bob
0
 

Author Comment

by:mrnbnf
ID: 19568356
Works - Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question