News:

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

Sizing windows....

Started by prodigy, August 12, 2006, 07:38:45 AM

Previous topic - Next topic

prodigy

My efforts seem futile in sizing windows...

I havea lot rects and when I try to set a window below another window...

I can just use rect.bottom I have to do something along these lines:

mov eax, rect.bottom
sub eax, rect.top

and eax has the height of the window....

But when I do this it doesn't work.... Any suggestions on how to get the exact height of a window...

I even tried switching...

mov eax,rect.top
sub eax, rect.bottom

help!!

TNick

#1
GetWindowRect returns screen coordinates of the upper left and lower right corners of your window. Are you using thisfunction? Because if you are, you must also use ScreenToClient function. Note that MoveWindow use the coordinates of the upper left corner and also the weight and the height.

Anyway, if you just need the weight and\or the height of a window, use GetWindowRect and substract coresponding values. The result will be the exact height\width.

Hope this is what you need.
Nick

ToutEnMasm

#2
Hello,
A few things are to be know before resizing a window.
1)After you call the createwindowex, the WM_SIZE message resize the window.At create,sizing a window is useless if the WM_SIZE is define.
2) the most confusing thing is the definition of the RECT structure,use this one instead.
               FRECT   STRUCT
      min POINT <>
      max POINT <>
   FRECT ENDS
This is a natural definition who use x,y coordinates,and you can write:
               in pseudo code:
               width  = max.x - min.x
               Height = max.y - min.y
3)two functions give you all you need:
      GetWindowRect give coordinates relative to the Upper left corner of the screen
      GetClientRect give coordinate relatives to the mother window
You can convert each answer in the other with
      ScreenToClient and ClientToScreen
4)MoveWindow and createwindows don't use   the same retangle definition
in FRECT definition , the need of each function is (in the order)
              min.x,min.y,width,Height

                    ToutEnMasm


     
             



Mark Jones

Hello Prodigy, also check out the LimitWindowWidth and LimitWindowHeight macros in MACROS.ASM.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

prodigy

What include is FRECT<> defined???

Tedd

Quote from: prodigy on August 12, 2006, 10:47:23 PM
What include is FRECT<> defined???
It's not. It is defined in ToutEnMasm's reply - it is his definition :wink
Just copy the definition into your code file (a good place to put it is before the code actually starts) :wink
No snowflake in an avalanche feels responsible.

ToutEnMasm

Hello,
a little help

Quote
      .386            
      .model flat, stdcall      
      option casemap :none      
   
   include \masm32\include\windows.inc    ;general definitions for windows
   include macro.inc   
   LIB kernel32,user32,masm32,perso32,imagehlp
;definitions for this source can be put here
   FRECT   STRUCT
      min POINT <>
      max POINT <>
   FRECT ENDS

.const
;constantes for this source

.data
       rect FRECT <>
.code
....
...

       invoke GetWindowRect,Hwnd,addr rect
      mov eax,rect.max.x
      sub eax,rect.min.x                      ;the width is in eax


POINT is a structure defined in windows.inc
                                     ToutEnMasm


Shantanu Gadgil

QuoteMy efforts seem futile in sizing windows...
I havea lot rects and when I try to set a window below another window...
I agree, it also seemed quite frustrating to me in the beginning.

Just a note, you might have already seen it...different APIs return/expect different meanings in the "right" and "bottom" members of the RECT.

Some APIs return the _actual_ co-ordinates, some client area height/width values, some window height/width values, etc.

So just watch out...can get very frustrating...it did for me :green2 :green2 (

when you say:
Quoteone window below another
have you tried the SetWindowPos API ?

HTH,
Shantanu
To ret is human, to jmp divine!

prodigy

Sorry for not replying... That FRECT deffinition really helped me out. Thank you so very much... The psuedo code really help me understand it coming from a C++ Background.