The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: hfheatherfox07 on August 17, 2011, 01:46:19 AM

Title: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 01:46:19 AM
hi,

here is a silly question... when using AnimateWindow ...if you don't use a square frame in the rsrc,.rc and you have a standard rounded corners windows it seems that when the gui.exe starts there is a black square shadow behind it until you click on it and move it... Why?

is that a default setting with the windows AnimateWindow command? is there a way to fix that?
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 02:07:51 AM
our buddy MichaelW seems to have a fix....
http://www.freebasic.net/forum/viewtopic.php?p=122350&sid=8c74bd1d7ea0445517c00d5f7dcb10e7

and, he's on a different forum   :eek
Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 02:22:31 AM
Quote from: dedndave on August 17, 2011, 02:07:51 AM
our buddy MichaelW seems to have a fix....
http://www.freebasic.net/forum/viewtopic.php?p=122350&sid=8c74bd1d7ea0445517c00d5f7dcb10e7

and, he's on a different forum   :eek

Thank you ,
I will try this tonight when I get home....
Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 02:35:56 AM
I am not so sure how he got this to work ...am  I missing something?

I get an rc error

I have that defined like this :

LOCAL rc:RECT
.IF uMsg == WM_INITDIALOG
invoke  GetWindowRect( hDlg, @rc )
invoke MoveWindow( hDlg, rc.left, rc.top, _
            rc.right-rc.left, _
            rc.bottom-rc.top, true )
  INVOKE AnimateWindow, hWnd, 300, AW_CENTER
  INVOKE SetFocus,hWnd
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 02:55:02 AM
i didn't see that you initialized the RECT structure
it does not need to be a struct - just stick some constants in there to test it   :P
something other than CW_USEDEFAULT

at any rate, this is very similar to a problem i saw while making a child window in an MDI
if i created the child during WM_CREATE, i got the exact same effect as you have
so - i moved the child-create out of WM_CREATE, until after UpdateWindow, and it fixed it

i am not sure what the best way would be to apply that in a dialog window

this guy seems to have played with it a lot
he has several posts in that thread
hard to read - i would copy/paste all that stuff into a text file
maybe there is something in there that will help...
http://www.ionicwind.com/forums/index.php/topic,3495.0.html
Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 03:03:49 AM
I tried a rect structure following this http://www.feiesoft.com/masm32/asmintro/workingwithstructures.html  still an error  :(

Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 03:13:37 AM
 :bg

invoke  GetWindowRect( hDlg, @rc )
invoke MoveWindow( hDlg, rc.left, rc.top, _
            rc.right-rc.left, _
            rc.bottom-rc.top, true )


try this...
        INVOKE  GetWindowRect,hDlg,addr rc
        mov     eax,rc.right
        mov     edx,rc.bottom
        sub     eax,rc.left
        sub     edx,rc.top
        INVOKE  MoveWindow,hDlg,rc.left,rc.top,eax,edx,TRUE


if that doesn't fly, try FALSE (capital letters)   :P
Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 03:26:59 AM
That works with both TRUE and FALSE but does nothing for the black shadows?
Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 03:42:37 AM
maybe that  method only works when used with a WinMain proc and a WndProc... maybe this method does not apply that in a dialog window?
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 03:55:45 AM
that could be right
maybe you can combine another flag
not too many to choose from
ignore the directions - they don't apply
ignore the ones that do not combine with AW_CENTER
that should leave only a few to try   :P

not a very technical approach, but hey !

msdn says not to use it with a drop-shadow - that doesn't seem to apply
Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 03:59:32 AM
Well I am off home ... I will give that a try for sure ...
Coincidentally  I did mess around with AW_SLIDE instead of AW_CENTER to see what effect that had and I noticed it did nothing ???
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 04:05:28 AM
with slide, as well as some others, you must also specify a direction flag
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 04:07:44 AM
i am going to try a MoveWindow AFTER the Animate   :bg
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 04:13:24 AM
hmmmm
that didn't do what i expected
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 04:54:07 AM
lol
this isn't even close to what i was aiming for, but, the corner problem is gone   :bg

i tried Edgar's solution from this thread - then played with the numbers...
http://www.masm32.com/board/index.php?topic=16410.msg135986#msg135986
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 01:41:12 PM
ok - starting from scratch   :bg

first, let's have a look at the batch file
%MASMBINPATH%\link.exe /SUBSYSTEM:WINDOWS /OUT:"%file%.exe" %file%.obj rsrc.res
the MS linker requires an OBJ
PoLink can use a RES file

i prefer to end the batch file with PAUSE rather than running the program so you can see any errors before continuing
being a n00b, i get lots of errors   :P

now, for animated windows, i suspect we need to use InitCommonControls or InitCommonControlsEx
i usually make it the first thing in the program
        push    ICC_WIN95_CLASSES
        push    sizeof INITCOMMONCONTROLSEX
        INVOKE  InitCommonControlsEx,esp
        pop     ecx
        pop     edx

you could add
or ICC_STANDARD_CLASSES
but, not sure it's needed

after that, i tried using drizz's and Edgar's method with setting the window region
some of these functions require gdi32.inc/lib
for some reason, it changes the theme to the old "classic win95" theme
Edgar uses a WS_POPUP style - that may be the reason
Title: Re: AnimateWindow
Post by: ToutEnMasm on August 17, 2011, 02:24:02 PM
Found,
Quote
INVOKE AnimateWindow, hwnd, 300, AW_CENTER or AW_BLEND
No problem until we clic the window
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 02:51:36 PM
AW_BLEND cannot be combined with AW_CENTER

i give up - lol
Title: Re: AnimateWindow
Post by: ToutEnMasm on August 17, 2011, 02:53:59 PM
copy of msdn
I don't see that
Quote
AW_ACTIVATE
0x00020000 Activates the window. Do not use this value with AW_HIDE.

AW_BLEND
0x00080000 Uses a fade effect. This flag can be used only if hwnd is a top-level window.

AW_CENTER
0x00000010 Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used. The various direction flags have no effect.

AW_HIDE
0x00010000 Hides the window. By default, the window is shown.

AW_HOR_POSITIVE
0x00000001 Animates the window from left to right. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.

AW_HOR_NEGATIVE
0x00000002 Animates the window from right to left. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.

AW_SLIDE
0x00040000 Uses slide animation. By default, roll animation is used. This flag is ignored when used with AW_CENTER.

AW_VER_POSITIVE
0x00000004 Animates the window from top to bottom. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.

AW_VER_NEGATIVE
0x00000008 Animates the window from bottom to top. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.

Title: Re: AnimateWindow
Post by: ToutEnMasm on August 17, 2011, 03:07:48 PM

Msdn say that the windows must :
Quote
The window procedures for the window and its child windows should handle any WM_PRINT or WM_PRINTCLIENT messages. Dialog boxes, controls, and common controls already handle WM_PRINTCLIENT. The default window procedure already handles WM_PRINT.
But what to do with the WM_PRINT message ?
Title: Re: AnimateWindow
Post by: dedndave on August 17, 2011, 06:41:40 PM
i don't know where i saw it, Yves
but AW_BLEND overrides AW_CENTER
Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 10:03:38 PM
Quote from: dedndave on August 17, 2011, 04:54:07 AM
lol
this isn't even close to what i was aiming for, but, the corner problem is gone   :bg

i tried Edgar's solution from this thread - then played with the numbers...
http://www.masm32.com/board/index.php?topic=16410.msg135986#msg135986

No that does not solve the corner problem...you are using a tool model window (square one)
the idea is not to have the rounded corner window show the black corners ....
Title: Re: AnimateWindow
Post by: jj2007 on August 17, 2011, 10:43:47 PM
Try this in line 67. On Win XP SP3 it works fine. No black corners.

  invoke CreateRoundRectRgn,-1,-1,edx,eax,70,70
  invoke SetWindowRgn,hWnd,eax,TRUE
Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 11:15:30 PM
Quote from: jj2007 on August 17, 2011, 10:43:47 PM
Try this in line 67. On Win XP SP3 it works fine. No black corners.

  invoke CreateRoundRectRgn,-1,-1,edx,eax,70,70
  invoke SetWindowRgn,hWnd,eax,TRUE


Thanks that did it  :bg

Title: Re: AnimateWindow
Post by: hfheatherfox07 on August 17, 2011, 11:28:55 PM
Quote from: dedndave on August 17, 2011, 04:05:28 AM
with slide, as well as some others, you must also specify a direction flag

Yap  :bg

AW_SLIDE works with :

AW_HOR_POSITIVE
AW_HOR_NEGATIVE
AW_VER_POSITIVE
AW_VER_NEGATIVE

For example:

  INVOKE AnimateWindow, hWnd, 300,AW_SLIDE or AW_HOR_POSITIVE

:U
Title: Re: AnimateWindow
Post by: dedndave on August 18, 2011, 12:43:53 AM
nice job, Jochen   :U