News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Static window sizes

Started by Tight_Coder_Ex, November 26, 2007, 05:51:00 AM

Previous topic - Next topic

Tight_Coder_Ex

I've chosen to fix window sizes as main window has a sizing border, but I only want to allow the vertical size to be changed from maximum screen height to a value or 37% or 384 which ever is greater.

In .data ; Specify fixed values in case somebody is using 640 x 480 resolution, then these
; become the default values

  StaticWidth dd 384 ; Minimum static width of screen
  MinHeight dd 384 ; Default minimum height
  MaxHeight dd 480 ; Default maximum height


In Start: ; Calculate screen extents applicable to this applications.
; Height = 75%, Min 37.5% or 384 which ever is greater Max 100%
; Width = 37.5% or minimum of 480

push SM_CXSCREEN ; Get width of current screen
call GetSystemMetrics
cmp ax, 640 ; Is anybody using this anymore!
jbe @F ; Nothing to do

shr eax, 1 ; Width = Width / 2
mov ecx, eax
shr ecx, 2 ; Skew = 1/2 Width / 4
sub eax, ecx ; EAX = 37.5% of current width
mov StaticWidth, eax

push SM_CYSCREEN ; Get height of current screen
call GetSystemMetrics
mov MaxHeight, eax
shr eax, 1
mov ecx, eax ; Set above
shr ecx, 2
sub eax, ecx
mov MinHeight, eax ; Values set for WM_GETMINMAXINFO


and in WM_GETMINMAXINFO event  MinMaxInfo: mov edi, [esi + 4] ; Pointer to MINMAXINFO
add edi, 24 ; Bump to ptMinTrackSize
mov esi, offset StaticWidth ; Get pointer to previously calculated params
lodsd ; Get static width of window

stosd ; Store @ ptMinTrackSize.x
mov [edi + 4], eax ; Store @ ptMaxTrackSize.x
lodsd ; Get Minimum height
stosd ; Store @ ptMinTrackSize

stc
ret

zooba

I don't believe WM_GETMINMAXINFO will do what you want.

Have a look at WM_SIZING and modifying the rectangle passed to that message.

Cheers,

Zooba :U

Tight_Coder_Ex

Quote from: zooba on November 26, 2007, 07:19:19 AM
I don't believe WM_GETMINMAXINFO will do what you want.

Sorry zooba, I'll try to be a little more succinct with future posts as I'm not asking a question but sharing code as I'm developing it which is about to become a doubly linked list project. In this case WM_GETMINMAXINFO does exactly what I require. Thanks for the input, WM_SIZE will play a significant role in proportionately sizing one of the child windows of this application when the parent is being resized.

I do look forward however to input on how my apps can be improved space and secondarily speed.

zooba

Quote from: Tight_Coder_Ex on November 26, 2007, 03:46:18 PM
Quote from: zooba on November 26, 2007, 07:19:19 AM
I don't believe WM_GETMINMAXINFO will do what you want.

Sorry zooba, I'll try to be a little more succinct with future posts as I'm not asking a question but sharing code

Sorry, my bad.

hutch--

tc,

We are more than pleased to see you code but understand that the Laboratory is where code is disected and discussed so it is normal in here for members to make comments on your code.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: Tight_Coder_Ex on November 26, 2007, 03:46:18 PM
WM_SIZE will play a significant role in proportionately sizing one of the child windows

The WM_SIZE message is sent to a window after its size has changed.

The WM_SIZING message is sent to a window that the user is resizing. By processing this message, an application can monitor the size and position of the drag rectangle and, if needed, change its size or position.

For a window with fixed width, you need the latter.

Tight_Coder_Ex

jj2007
I stand corrected and agree WM_SIZING would accomplish the same and have done the same with WM_LBUTTONDOWN and then testing which border is attempting to be moved.
Is there a particular reason  you would choose WM_SIZING over WM_GETMINMAXINFO.

hutch
Poor wording on my part, but I just wanted to qualify that the algo is doing what I wanted it too, now whether it is the best choice that could be debatable.

jj2007

Quote from: Tight_Coder_Ex on November 27, 2007, 01:57:07 PM
Is there a particular reason  you would choose WM_SIZING over WM_GETMINMAXINFO.
As far as I can see, this is the message sent when you try to size your window. So this is the only place where you can prevent the user from changing the width while he is trying. But I have not tested your code...

MichaelW

AFAICT, with regard to limiting the size of the window, the code behaves just like code based on WM_SIZING. When I try to drag the borders beyond the limits there is no apparent motion and no flicker. For what this code does, I feel that WM_GETMINMAXINFO is the correct choice.

[attachment deleted by admin]
eschew obfuscation

jj2007

Quote from: MichaelW on November 27, 2007, 03:42:08 PM
AFAICT, with regard to limiting the size of the window, the code behaves just like code based on WM_SIZING. When I try to drag the borders beyond the limits there is no apparent motion and no flicker. For what this code does, I feel that WM_GETMINMAXINFO is the correct choice.

In practice, both messages will do the job. Here is the best distinction I could find, from
http://vbnet.mvps.org/index.html?code/subclass/aspectratio.htm

The key to the WM_GETMINMAXINFO technique is the fact that this message is sent to a window when the size or position of the window is about to change, providing the opportunity to set the minimum or maximum allowable size of the window.

Along with the WM_GETMINMAXINFO, the WM_SIZING message is also sent to the WindowProc during a resize event. And although this message also passes a RECT structure as part of the message parameters, it differs from WM_GETMINMAXINFO in that it is sent to a window that the user is currently resizing. By processing this message we can not only monitor the size and position of the window's drag rectangle, we can also change the drag rectangle's size or position by adjusting the values in the RECT structure passed

Which means WM_SIZING offers more flexibility, but that's not what tc wanted, so I surrender and give the points to MichaelW & tc  :U

Tight_Coder_Ex

One of the major reasons I use WM_GETMINMAXINFO is that for windows that allow to be maximized I can control the size of the window more effortlessly than using WM_NCLBUTTONDOWN and and then testing to see what part of the non client area I'm in and use WM_SIZING.

Thanks for the link jj2007