Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I've been recently toying around with DllImports and P/Invoke calls in my C# WPF application, and have found them to be quite useful. However, I was wondering, is it possible to use this to change the behavior of a window when it is maximized? Like, change the client window which it is being maximized in?
For example, when a window is maximized, it takes up the full screen area minus the taskbar at the bottom. For my application, I wish to create a toolbar that docks at the top of the screen. I have already set it as the bottommost form, that makes the taskbar disappear when it loads. Yet when a window is maximized, it simply overlaps the toolbar. I want my toolbar to act as if it were the taskbar docked to the top of your screen. I want the window to resize so it's top position is aligned with the bottom of the toolbar, and it resizes to take up the full window minus my toolbar. I hope this is all making sense... any ideas? Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 29-May-13 19:38pm    
No need for that, not at all.
—SA

You don't need to use P/Invoke to implement such behavior. It's pretty bad thing to use P/Invoke without some really compelling reason. You seriously risk platform compatibility, especially for future, when — who knows? — WPF might be implemented for many other (non-Microsoft) platforms, as it happened to System.Windows.Forms for Mono. Even if you don't care about it, it increase the change of other incompatibilities or just bugs.

You layout should be fluid enough and work for nearly all window sized, even if you don't maximize. If you want to dock something, there are the dock panels. Please see: http://wpftutorial.net/DockPanel.html[^].

There are many other layout features, so the problem of keeping proper layout while the window changes the size is totally out of scope. This is not a problem at all. If it's not the case in your design, it's wrong from the very beginning. Note that you even don't need to write any code to handle resize events, but this is another possibility. You just don't need it for your purpose. This is about one topic: "how to forget P/Invoke and start programming". By learning layout and other basics.

Good luck,
—SA
 
Share this answer
 
Take a look at handling the WM_GETMINMAXINFO and/or the WM_NCCALCSIZE messages. You should then be able to do what you want.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 29-May-13 19:37pm    
Totally redundant stuff for the purpose. Please see my answer.
—SA
RadXPictures 2-Jun-13 16:55pm    
I've investigated both of these and realized that they're both variables, not actual functions. Which functions would I pair these with? Could you point me in the right direction?
PJ Arends 2-Jun-13 19:02pm    
These are messages sent by the windows OS to your applications window.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900