The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: hfheatherfox07 on August 31, 2011, 10:14:36 PM

Title: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on August 31, 2011, 10:14:36 PM
Hi,
I was wondering what command can I use to have the buttons move position relative to the window size when the window gets maximized?
also is there such command in the rsrc.rc with ReSED?

Thank you....
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: qWord on August 31, 2011, 10:39:03 PM
hi,
It is your job to move/size the controlls if wished.
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on August 31, 2011, 10:45:16 PM
Quote from: qWord on August 31, 2011, 10:39:03 PM
hi,
It is your job to move/size the controlls if wished.

Not aware of how to do that ....
I found http://win32assembly.online.fr/tut9.html

invoke CreateWindowEx,NULL, ADDR ButtonClassName,ADDR ButtonText,\
                        WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
                        75,70,140,25,hWnd,ButtonID,hInstance,NULL
mov  hwndButton,eax


is this what you mean ? or is there another way ....
the reason that I am asking is that ...this example is a bare bones thing .... eventually I will be making a vista skin window with image buttons
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: Gunner on August 31, 2011, 10:48:02 PM
MoveWindow, SetWindowPos come to mind...
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on August 31, 2011, 11:02:08 PM
Quote from: qWord on August 31, 2011, 10:39:03 PM
hi,
It is your job to move/size the controlls if wished.

Just had a thought .....

is there a way to move the controls relative to a fix potion , other wise would it not appear different on each computer screen? would I have to get system metrics first?
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on August 31, 2011, 11:03:03 PM
Here is my bare bones example
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on August 31, 2011, 11:06:50 PM
WM_SIZE gives some info in wParam

wParam tells you if it's maximized or minimized - you really don't need that
although - no need to do anything if minimized   :P

then, GetWindowRect
subtract the widths to set the positions
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on August 31, 2011, 11:20:29 PM
Quote from: dedndave on August 31, 2011, 11:06:50 PM


then, GetWindowRect
subtract the widths to set the positions


I am not sure I get that....what widths?

I found this   http://www.suite101.com/content/windows-gui-programming-resize-tip-a54796   is that what you mean?

Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on August 31, 2011, 11:25:45 PM
I found this ...I will have too look at it .... http://www.masm32.com/board/index.php?topic=12268.0
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on August 31, 2011, 11:41:14 PM
here - try this one.....
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: qWord on August 31, 2011, 11:43:00 PM
if you want to keep the proportions, you must store the the controls position as factors relative to the client ares size. This calculation can be done at initialization. If the window gets resized, you must recalculate and applie all positions and sizes.
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on August 31, 2011, 11:50:03 PM
I found another use for "WM_SIZE"

elseif uMsg == WM_SIZE
        invoke SendMessage,hToolBar,TB_AUTOSIZE,0,0
        invoke MoveWindow,hStatus,0,0,0,0,TRUE


from hutch's old page here : http://www.movsd.com/masm.htm

I am going to have to make up Project.inc when I get home tonight ( I have dbmacros.asm, errormac.asm )
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on August 31, 2011, 11:54:19 PM
Quote from: dedndave on August 31, 2011, 11:41:14 PM
here - try this one.....

thanks   :U....
curious ...how come you use ebx for the handle (hwnd) ?
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on August 31, 2011, 11:57:00 PM
saves a few bytes, is all   :P
we use the handle 5 times
so, it saves ~5 bytes
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on September 01, 2011, 12:08:38 AM
Quote from: dedndave on August 31, 2011, 11:57:00 PM
saves a few bytes, is all   :P
we use the handle 5 times
so, it saves ~5 bytes

:U

Cool.... I will try that tonight on the round corners  version I have it working but with hWnd
That is something to keep in mind from now on

Thanks again
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on September 01, 2011, 12:22:42 AM
i just realized that the box is the client
this one is a little simpler

on the first one, i got the window rectangle and converted the coordinate to a client coordinate
this one - i just get the client rectangle
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: qWord on September 01, 2011, 12:38:05 AM
maybe not exactly what ask for, but looks nice  :bg
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on September 01, 2011, 12:51:07 AM
Thank you all so much for your help...
If anything , I noticed a few posts about how to create a custom title bar ( a window without one) ....
at least now we have a bare bones example that people can work of off... add title , icon , etc...

I have a great example using .PNG to skin buttons with libs for minimal code in the asm ... but it is not ready yet ... I still have to figure how to crop the buttons with  2 corners on one side.... so far I can only crop square LOL
Well when I finish the vista window skin I will post it .....

I found something for VB in the Aero ( which is the name for the vista theme), to bad we do not have something like that for MASM http://www.remnantmods.com/forums/viewtopic.php?f=5&t=1650

I am not sure how that works yet ...

thank you for all your help  :U
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on September 01, 2011, 03:42:49 AM
Quote from: qWord on September 01, 2011, 12:38:05 AM
maybe not exactly what ask for, but looks nice  :bg

:U
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on May 08, 2012, 01:00:21 AM
This worked fine until I added buttons with bitmap ...why?

I am trying to ultimately do this example with re-size   http://www.masm32.com/board/index.php?topic=18823.0


I will also add the example from masm11 of skin3 if that helps
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on May 08, 2012, 01:56:09 AM
i swear we already did this once   :lol

go back and review Reply #'s 6-9

better hurry before the attachment vanishes - lol
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on May 08, 2012, 02:00:04 AM
yes all works fine with buttons in the resource but not with painted buttons and I don't know why .... :(
I will look at hutches example and try to see if I can make it work
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on May 08, 2012, 02:59:48 AM
the problem(s) seems to be related to the .IF/.ELSEIF/.ENDIF structure

if you are going to use them - good idea to indent to match them up
personally - i don't care for either - lol

but.....
    .elseif  uMsg == WM_COMMAND
        mov eax,wParam
        mov edx,eax
        shr edx,16
        and eax,0ffffh
        .if edx == BN_CLICKED
            .if  eax ==IDC_BTN1 ; Minimize Window Button   
                invoke ShowWindow,hWnd,SW_MINIMIZE
            .endif
        .endif
    .if edx == BN_CLICKED
        .if  eax ==IDC_BTN2 ; MaximizeBox/MinimizeBox Button 
            .if WindowSz==1
                mov WindowSz,0
                invoke ShowWindow,hWnd,SW_MAXIMIZE
                invoke ImageButton,hWnd,244,2,403,401,402,IDC_BTN2 ;custom image button (JPG,BMP,PNG) Left,Up,DownID,UpID,OverID
                mov hMinBox,eax
                ;invoke SetFocus,hMinBox

            .elseif WindowSz==0
                mov WindowSz,1

                invoke ShowWindow,hWnd,SW_SHOWNORMAL ; Restore Window to defult size (MinimizeBox)
                invoke ImageButton,hWnd,244,2,603,601,602,IDC_BTN2 ;custom image button (JPG,BMP,PNG) Left,Up,DownID,UpID,OverID
                mov hMax,eax
            .endif
        .endif
    .endif
.endif
.if edx == BN_CLICKED
    .if  eax ==IDC_BTN3   ; Exit Button
        invoke SendMessage,hWnd,WM_CLOSE,0,0
    .endif

things aren't matched up, here
i don't think you ever get to the WM_SIZE test   :P

EDIT - ok - it does get there once when you call it in WM_INITDIALOG - but that's it
and - you call it before the buttons have been created, so the handles are all 0
i added message boxes for a quick check....
invoke  GetDlgItem,ebx,IDC_BTN3
push eax
invoke MessageBox,0,uhex$(eax),0,0
pop  eax
sub     esi,edi
invoke  MoveWindow,eax,esi,0,edi,edi,TRUE
invoke  GetDlgItem,ebx,IDC_BTN2
push eax
invoke MessageBox,0,uhex$(eax),0,0
pop  eax
sub     esi,23
invoke  MoveWindow,eax,esi,0,edi,edi,TRUE
invoke  GetDlgItem,ebx,IDC_BTN1 
push eax
invoke MessageBox,0,uhex$(eax),0,0
pop  eax
sub     esi,23
invoke  MoveWindow,eax,esi,0,edi,edi,TRUE

you can see that it doesn't get called for WM_SIZE
(you have to "include \masm32\macros\macros.asm" in order to use "uhex$")
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on May 08, 2012, 03:02:32 AM
Thank you ....I will try this out  :U
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on May 09, 2012, 07:42:52 PM
Arg ...
the buttons wont work  :(
I tried adding a separate flag 4 different ways .....


; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤
.data?
ButoonFlag  dd  ?

invoke ImageButton,hWnd,244,2,603,601,602,IDC_BTN2 ;MaximizeBox ;custom image button (JPG,BMP,PNG) Left,Up,DownID,UpID,OverID
mov hMax,eax
mov ButoonFlag,TRUE

.elseif uMsg==WS_MAXIMIZEBOX
.if ButoonFlag == TRUE
invoke ImageButton,hWnd,244,2,603,601,602,IDC_BTN2 ;MaximizeBox ;custom image button (JPG,BMP,PNG) Left,Up,DownID,UpID,OverID
mov hMax,eax
mov ButoonFlag,FALSE
.elseif ButoonFlag == FALSE
invoke ImageButton,hWnd,244,2,403,401,402,IDC_BTN2 ;custom image button (JPG,BMP,PNG) Left,Up,DownID,UpID,OverID
mov hMinBox,eax
mov ButoonFlag,TRUE
.endif




why wont this work? is it the size-window proc?

Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on May 09, 2012, 07:45:03 PM
here is 2 more that I tried
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on May 09, 2012, 10:17:52 PM
1st - the box with one box over another is called "restore"   :P

2nd - after you create the maximize button, you have...
        mov hMax,1
oops !

i renamed some of the picture files
re-organized the resource files and ID's

i indented and fixed all the if/else/endif stuff

another problem - in certain cases, you created a new button using the same ID without destroying the old one
now - you have several buttons with the same ID

the way to fix that problem is to create all 4 buttons to begin with
then - hide the one you do not want to show
also - you can set all their initial positions to 0 - and let the size code take care of it   :U

i used the IsZoomed function to see if the window is maximized
it is cleaner than using the WindowSz flag
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: hfheatherfox07 on May 09, 2012, 11:39:13 PM
That is really clever I did not  think to do it that way .....  :U I even tried adding the button flags in the size box proc

Thank you so much !

I will add the Areo glass skin add this example to the Aero Glass Vista Buttons With Frame and Shadow thread so we have a template to use

http://www.masm32.com/board/index.php?PHPSESSID=88ace34383c3f8d9f0b6179143247cf8&topic=18823.0
Title: Re: Buttons don't move with SW_MAXIMIZE
Post by: dedndave on May 10, 2012, 02:59:51 AM
well - there might be another option....

you could create only 3 buttons, then switch the images
i did not try sending a BM_SETIMAGE message to the button to swap images
it seems a bit messy, because each button has 3 images associated with it   :P