473,471 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to determine if a window is maximized?

Hi all.

I'm writing a small utility that can move a window from one of my
monitors to the other, when a system hotkey is pressed. I want to keep
the windowstate (maximized or normal) when the window is moved, but I
need to know the windowstate in order to move it properly.

I'm using some P/Invoke calls to get the window handles and the window
placement, which all works well, but I can't find a way to determine if
a window is maximized or minimized. I need to know that so I can know
which bits of the WINDOWPLACEMENT struct to read to get position data.

Thanks.

--
jeremiah();
Jul 16 '06 #1
4 10099
"jeremiah johnson" wrote:
I need to know the windowstate in order to move it properly.
Hello Jeremiah,

You can use the USER API GetWindowPlacement to obtain the current status of
a given window -- the showCmd field of the returned WINDOWPLACEMENT structure
should be equal to SW_MAXIMIZE (3) if the window is maximized.

You can find the P/Invoke signature and structure information at
http://www.pinvoke.net/default.aspx/...indowPlacement

--
Best regards,

Stanimir Stoyanov
ad***@nospam.stoyanoff.info
Jul 16 '06 #2
Deborah Kurata has an article in the latest CoDe magazine titled "Retaining
Multiple Sets of User Settings" While the topic isn't directly related to
your question, she uses a sample that stores window size and state (max/min)
upon application exit for each user of the system.

Essentially, she uses the Form.WindowState, Form.FormSize, and
Form.RestoreBounds properties to persist a form's state and size.

--
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"jeremiah johnson" wrote:
Hi all.

I'm writing a small utility that can move a window from one of my
monitors to the other, when a system hotkey is pressed. I want to keep
the windowstate (maximized or normal) when the window is moved, but I
need to know the windowstate in order to move it properly.

I'm using some P/Invoke calls to get the window handles and the window
placement, which all works well, but I can't find a way to determine if
a window is maximized or minimized. I need to know that so I can know
which bits of the WINDOWPLACEMENT struct to read to get position data.

Thanks.

--
jeremiah();
Jul 16 '06 #3
I had found this page before, but oddly I never thought to check
showCmd. Thank you.

One last thing (that I thought I'd figured out already, but haven't) is
how to determine which screen a window is on *when it is maximized*
using the Win32 API. It is easy to figure it out when it is not
maximized, the placement coordinates give that away, but when a window
is maximized, the Win32 API seems to tell me that the window origin is
-1, -1 no matter which screen the window in question is maximized on.

To clarify, I'm not worried about the form for the program I'm writing
now, its every other window on the user's desktop that I'm interested in
moving around, which is why I have to use user32.dll and P/Invoke to
move them around.

Thanks.

Stanimir Stoyanov wrote:
"jeremiah johnson" wrote:
>I need to know the windowstate in order to move it properly.

Hello Jeremiah,

You can use the USER API GetWindowPlacement to obtain the current status of
a given window -- the showCmd field of the returned WINDOWPLACEMENT structure
should be equal to SW_MAXIMIZE (3) if the window is maximized.

You can find the P/Invoke signature and structure information at
http://www.pinvoke.net/default.aspx/...indowPlacement
--
jeremiah();
Jul 16 '06 #4
I figured it out.

To move a maximized window, you must first restore it to the normal
state (not maximized nor minimized,) move it to the window you want,
then maximize it again.

using a little WINDOWPLACEMENT manipulation I got it all working.

if anyone wants to see my code I'd be happy to share it.

Thanks.

jeremiah johnson wrote:
I had found this page before, but oddly I never thought to check
showCmd. Thank you.

One last thing (that I thought I'd figured out already, but haven't) is
how to determine which screen a window is on *when it is maximized*
using the Win32 API. It is easy to figure it out when it is not
maximized, the placement coordinates give that away, but when a window
is maximized, the Win32 API seems to tell me that the window origin is
-1, -1 no matter which screen the window in question is maximized on.

To clarify, I'm not worried about the form for the program I'm writing
now, its every other window on the user's desktop that I'm interested in
moving around, which is why I have to use user32.dll and P/Invoke to
move them around.

Thanks.

Stanimir Stoyanov wrote:
>"jeremiah johnson" wrote:
>>I need to know the windowstate in order to move it properly.

Hello Jeremiah,

You can use the USER API GetWindowPlacement to obtain the current
status of a given window -- the showCmd field of the returned
WINDOWPLACEMENT structure should be equal to SW_MAXIMIZE (3) if the
window is maximized.

You can find the P/Invoke signature and structure information at
http://www.pinvoke.net/default.aspx/...indowPlacement
--
jeremiah();
Jul 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lkrubner | last post by:
I've come up with a non-frame version of this site: http://www.lauradenyes.com/ However, the owner doesn't like my version because the content in the center sits too high in the center part,...
1
by: Beacher | last post by:
Hi all, I have a form set to maximize on load (docmd.maximize) but when i open another form by clicking a button on my main form, it restores itself to its default window size, is there anyway I...
1
by: Yatharth | last post by:
Its a Web application. I am developing an application in which my page is refreshing continuosly.In that there is a textbox which is filled from the database ,and changed when i changed the ...
2
by: JohnJohnUSA | last post by:
I am new to Python. How do I get the following program to appear initially with the window maximized? Thanks for your help! from Tkinter import * # set up the window itself top = Tk() F =...
1
by: gimme_this_gimme_that | last post by:
I want to disable scrolling when a window is maximized on IE... Is there a way to tell if the window is maximized? Thanks.
7
by: Bill Nguyen | last post by:
This has been posted before but received no response: I need to arrange window screens on the total area of a mulitple-mopnitor desktop. As an example, below is the bound info for my 2-monitor...
4
by: arajunk | last post by:
In Firefox this opens a full size window (maximized) . In IE it opens the partial window requiring user to click restore (upper right) to maximize. What am I missing ? var...
2
by: Samuel | last post by:
The application is MDI, as soon as the application loads I create a new child window (maximized), within the child window there is a tab control almost the size of the child window The problem...
1
by: Thom Little | last post by:
Using C# 3.5 (including using System.Runtime.InteropServices) ... .... if the window is Minimized (IsIconic) ... I would like to ... If the window was Normal and then Minimized I would like to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.