Maximized window cannot be minimized

K

Kai Zhang

In my application, I used

SetForegroundWindow hwnd

to bring the background window to front of desktop. It works fine in most of
the case. However, if the targeted background window is minimized, after
executing SetForegroundWindow hwnd to maximize this window, this window
cannot be minimized any longer(nothing happens when click the minimize
button on top-right corner of the window title bar)

I also tried this function:

ShowWindow hwnd, SW_SHOWMAXIMIZED

Same thing happens, can anyone give me some hint to make the minimize button
work again?



Thanks,



Kai
 
C

Cor Ligthert

"Herfried K. Wagner [MVP]"
... because it's something entirely different...
I did not know that you was asking your question in this newsgroup with
another pseudo, however can you explain to me what is different?

Cor
 
C

Carlos J. Quintero [.NET MVP]

Hi Cor,

Herfried may provide a better explanation, but AFAIK, TopMost establishes a
window in your app that will be always on top of the others, while
SetForegroundWindow is used to bring a normal window to the foreground, to
call the user's attention over it, if the OS allows it (because it can be
annoying, see
http://msdn.microsoft.com/library/d...rence/windowfunctions/setforegroundwindow.asp)

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
C

Cor Ligthert

Carlos,

Thanks,

However, in my idea can I by directly after each other setting topmost to
true and false doing this process. I have the idea that everybody thinks
this is a designer option.

However, if I see this wrong, I gladly like to know what I miss.

Cor
 
H

Herfried K. Wagner [MVP]

Cor,

Cor Ligthert said:
However, in my idea can I by directly after each other setting topmost to
true and false doing this process. I have the idea that everybody thinks
this is a designer option.

It doesn't work as expected. The form keeps standing in the foreground even
if you reset 'TopMost' and clicking another window won't bring this window
to front.
 
C

Cor Ligthert

"Herfried K. Wagner [MVP]" > "
It doesn't work as expected. The form keeps standing in the foreground
even if you reset 'TopMost' and clicking another window won't bring this
window to front.
I tested this of course in advance before I wrote this with a timer.

:)

Cor
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
I tested this of course in advance before I wrote this with a timer.

Well, I used a timer, but it still doesn't work as expected on my Windows XP
Professional SP2.
 
C

Cor Ligthert

This is my code

\\\
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Me.TopMost = True
Me.TopMost = False
Timer1.Enabled = False
End Sub
///

When the form shows I click on another program to give the front focus when
the Timer fires the form is showed.

Cor
 
H

Herfried K. Wagner [MVP]

Cor,

Cor Ligthert said:
This is my code

\\\
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Me.TopMost = True
Me.TopMost = False
Timer1.Enabled = False
End Sub
///

When the form shows I click on another program to give the front focus
when the Timer fires the form is showed.

I use exactly the same code. Start the VB.NET application, bring OE into
the front, then wait until the VB.NET form appears. Then click onto one of
the messages in OE. The VB.NET application remains on top and OE won't be
put into the foreground.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top