How to maximize a target handle ?

  • Thread starter Thread starter Boki
  • Start date Start date
B

Boki

Hi All,

I want to force a window ( form, handle ) become foreground, I use:


FindWindow

and

SetForegroundWindow

but, sometimes, it is still in the taskbar, it should be minimize
status, how can I force it become maximize ?

Thanks a lot!
Best regards,
Boki.
 
Boki said:
Hi All,

I want to force a window ( form, handle ) become foreground, I use:


FindWindow

and

SetForegroundWindow

but, sometimes, it is still in the taskbar, it should be minimize
status, how can I force it become maximize ?

Thanks a lot!
Best regards,
Boki.


Hi Boki,

you should send Window Messages to be 100% sure that the window
will be in maximized state. Use the native Windows API "SendMessage"
with the WM_SIZE Message and SIZE_MAXIMIZED Parameter. You can
do nearly anything with "SendMessage" Api and Window Messages to
Windows regarding Window Operations. Take a closer look at it. Since
you know that Windows and the Window Manager is a Event Driven Part
of the OS, you really can do so many things with SendMessage and
APIs like "CallWindowProc". You can even inject Assembler Coder to
your application with Apis like "CallWindowProc",...really!


Beste Gruse / Best regards / Votre bien devoue

Kerem Gumrukcu
 
* Kerem Gumrukcu wrote, On 29-6-2007 6:46:
Hi Boki,

you should send Window Messages to be 100% sure that the window
will be in maximized state. Use the native Windows API "SendMessage"
with the WM_SIZE Message and SIZE_MAXIMIZED Parameter. You can
do nearly anything with "SendMessage" Api and Window Messages to
Windows regarding Window Operations. Take a closer look at it. Since
you know that Windows and the Window Manager is a Event Driven Part
of the OS, you really can do so many things with SendMessage and
APIs like "CallWindowProc". You can even inject Assembler Coder to
your application with Apis like "CallWindowProc",...really!

Be very careful with this API under Windows Vista. It's no longer
allowed to send window messages from one application to another.

Jesse
 
* Kerem Gumrukcu wrote, On 29-6-2007 6:46:






Be very careful with this API under Windows Vista. It's no longer
allowed to send window messages from one application to another.

Jesse

That's really bad.
I am using Vista.

Boki.
 
Jesse Houwing said:
* Kerem Gumrukcu wrote, On 29-6-2007 6:46:

Be very careful with this API under Windows Vista. It's no longer allowed
to send window messages from one application to another.

Jesse

Hi Jessi,

what do you recommend us to communicate with other applications?
Sure you will have problems with sendmessage on vista because of
User Interface Privilege Isolation (UIPI) and UAC but you can work
around:

Found in another post from Frank Dzaebel:
[ChangeWindowMessageFilter Function]
http://msdn2.microsoft.com/en-us/library/ms632675.aspx

[UIPI (GUI- Teil der Benutzerkontenkontrolle)]
http://www.microsoft.com/germany/msdn/library/windows/windowsvista/Wi...

[Developer Best Practices and Guidelines for Applications in a Least
Privileged Environment]
http://msdn2.microsoft.com/en-us/library/aa480150.aspx
(s. User Interface Privilege Isolation Overview)

[What is User Interface Privilege Isolation (UIPI) on Vista]
http://blogs.msdn.com/vishalsi/archive/2006/11/30/what-is-user-interf...

[Understanding and Working in Protected Mode Internet Explorer]
http://msdn2.microsoft.com/en-us/library/bb250462.aspx


There are endless ways to communicate with other applications, even with
injecting code and processes and manipulating application memory directly.
Its up to you. But a easy way and also "mannaged" would be a use of the
NativeWindow-Class.


But i am interessted in what Jessi recommends,...


Beste Gruse / Best regards / Votre bien devoue

Kerem Gumrukcu
 
* Kerem Gümrükcü wrote, On 30-6-2007 12:01:
Jesse Houwing said:
* Kerem Gumrukcu wrote, On 29-6-2007 6:46:
Be very careful with this API under Windows Vista. It's no longer allowed
to send window messages from one application to another.

Jesse

Hi Jessi,

what do you recommend us to communicate with other applications?
Sure you will have problems with sendmessage on vista because of
User Interface Privilege Isolation (UIPI) and UAC but you can work
around:

Found in another post from Frank Dzaebel:
[ChangeWindowMessageFilter Function]
http://msdn2.microsoft.com/en-us/library/ms632675.aspx

[UIPI (GUI- Teil der Benutzerkontenkontrolle)]
http://www.microsoft.com/germany/msdn/library/windows/windowsvista/Wi...

[Developer Best Practices and Guidelines for Applications in a Least
Privileged Environment]
http://msdn2.microsoft.com/en-us/library/aa480150.aspx
(s. User Interface Privilege Isolation Overview)

[What is User Interface Privilege Isolation (UIPI) on Vista]
http://blogs.msdn.com/vishalsi/archive/2006/11/30/what-is-user-interf...

[Understanding and Working in Protected Mode Internet Explorer]
http://msdn2.microsoft.com/en-us/library/bb250462.aspx


There are endless ways to communicate with other applications, even with
injecting code and processes and manipulating application memory directly.
Its up to you. But a easy way and also "mannaged" would be a use of the
NativeWindow-Class.


But i am interessted in what Jessi recommends,...

I have no real recommendation for you. We've decided to upgrade our
applications to use named pipes to communicate, but as you can imagine,
this is only possible if you control both sides of the communication.

Yes there are ways to communicate between applications, even in Vista,
but they are a lot more restricted and I'd guess that these restrictions
will only become tighter in the future.

Pick the one that solves your problem the easiest way. Ours was to
change the channel. Yours might be to jump through all the hoops
Microsoft is holding in front of you.

Jesse
 
Jesse Houwing said:
* Kerem Gümrükcü wrote, On 30-6-2007 12:01:
Jesse Houwing said:
* Kerem Gumrukcu wrote, On 29-6-2007 6:46:
Hi All,

I want to force a window ( form, handle ) become foreground, I use:


FindWindow

and

SetForegroundWindow

but, sometimes, it is still in the taskbar, it should be minimize
status, how can I force it become maximize ?

Thanks a lot!
Best regards,
Boki.


Hi Boki,

you should send Window Messages to be 100% sure that the window
will be in maximized state. Use the native Windows API "SendMessage"
with the WM_SIZE Message and SIZE_MAXIMIZED Parameter. You can
do nearly anything with "SendMessage" Api and Window Messages to
Windows regarding Window Operations. Take a closer look at it. Since
you know that Windows and the Window Manager is a Event Driven Part
of the OS, you really can do so many things with SendMessage and
APIs like "CallWindowProc". You can even inject Assembler Coder to
your application with Apis like "CallWindowProc",...really!
Be very careful with this API under Windows Vista. It's no longer
allowed to send window messages from one application to another.

Jesse

Hi Jessi,

what do you recommend us to communicate with other applications?
Sure you will have problems with sendmessage on vista because of
User Interface Privilege Isolation (UIPI) and UAC but you can work
around:

Found in another post from Frank Dzaebel:
[ChangeWindowMessageFilter Function]
http://msdn2.microsoft.com/en-us/library/ms632675.aspx

[UIPI (GUI- Teil der Benutzerkontenkontrolle)]
http://www.microsoft.com/germany/msdn/library/windows/windowsvista/Wi...

[Developer Best Practices and Guidelines for Applications in a Least
Privileged Environment]
http://msdn2.microsoft.com/en-us/library/aa480150.aspx
(s. User Interface Privilege Isolation Overview)

[What is User Interface Privilege Isolation (UIPI) on Vista]
http://blogs.msdn.com/vishalsi/archive/2006/11/30/what-is-user-interf...

[Understanding and Working in Protected Mode Internet Explorer]
http://msdn2.microsoft.com/en-us/library/bb250462.aspx


There are endless ways to communicate with other applications, even with
injecting code and processes and manipulating application memory
directly.
Its up to you. But a easy way and also "mannaged" would be a use of the
NativeWindow-Class.


But i am interessted in what Jessi recommends,...

I have no real recommendation for you. We've decided to upgrade our
applications to use named pipes to communicate, but as you can imagine,
this is only possible if you control both sides of the communication.

Yes there are ways to communicate between applications, even in Vista, but
they are a lot more restricted and I'd guess that these restrictions will
only become tighter in the future.

Pick the one that solves your problem the easiest way. Ours was to change
the channel. Yours might be to jump through all the hoops Microsoft is
holding in front of you.

Jesse

Hi Jesse,

using Pipes is a good solution, in nearly every aspect and it will be
more difficult in future to talk between applications but also it will
be more easy to do this with things like e.g. .net remoting. There
will be always a solution for any problem,.......except death. ;-)
Working in Kernel-Mode breaks all chains, even in Vista. You
are free to control the complete operating system, moving your
memory pointer to any location and altering any code!


Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
 
Kerem,
you should send Window Messages to be 100% sure that the window
will be in maximized state. Use the native Windows API "SendMessage"
with the WM_SIZE Message and SIZE_MAXIMIZED Parameter.

Why do you say that? What's wrong with calling the ShowWindow API with
SW_MAXIMIZE?

WM_SIZE is a notification message sent to a window after its size has
changed. It's not a command message used to request sizing of the
window.


Mattias
 
Mattias Sjögren said:
Kerem,


Why do you say that? What's wrong with calling the ShowWindow API with
SW_MAXIMIZE?

WM_SIZE is a notification message sent to a window after its size has
changed. It's not a command message used to request sizing of the
window.


Mattias



Hi Matthias,

maybe i said something wrong. Yes your approach works fine. This is
no excuse if i said something wrong, but i think i am a little bit out of
shape since i wrote my last line of (C/C++) code for windows api
2 months ago.

The truth is that i got a some very bad and incurable eye disease in both
eyes and that i have serious problems in reading and writing anything
and it is sometimes impossible to concentrate on even one single line of
code. I quit coding due to the fact that i cant concentrate on programming
anylonger. I was a passionated programmer and developer and it is really
hard for me to stop on coding. I got this disease day to day and with no
warnings two months ago. Try to figure this out: I am a professional
developer and IT-Trainer for Windows and Linux Systems beside my
programmer career and now i have to stop it all.

I must apologize if my first idea was wrong,...the last weeks i am
very confused and do a lot of mistakes, including this! Yes your
ShowWindows is absolutely correct!


Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
 
Back
Top