flat assembler
Message board for the users of flat assembler.

Index > Windows > AnimateWindow() worst f at all

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
revolution, are you ok today? You see that example code. GetLastError IS the next API already.
Post 19 Aug 2020, 16:00
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
But you showed that you ignore the result in RAX from calling AnimateWindow. That is not correct.

So does AnimateWindow return zero or some other value?
Post 19 Aug 2020, 16:01
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Test one test two means two different compilations, just to make sure you are satisfied. Both results, both rax zeroed
Post 19 Aug 2020, 16:03
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Why don't you check it out for yourself if you think I'm stupid?
Post 19 Aug 2020, 16:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
Show the code that you actually ran, and the results.

I can't believe that RAX=0 (failed) AND the last error code is zero (success). Not possible. So far you have only shown incorrect error checking code, so I don't trust the values you got are correct.
Post 19 Aug 2020, 16:07
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
Overclick wrote:
Why don't you check it out for yourself if you think I'm stupid?
I can't run Windows code.

It isn't about stupidity, it is about getting it correct so we don't deceive ourselves.
Post 19 Aug 2020, 16:08
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Microsoft says it's possible you believe that or not. I'm tired of proving my steps, have to ask someone else...

"If the thread does not own the window. Note that, in this case, AnimateWindow fails but GetLastError returns ERROR_SUCCESS."
Post 19 Aug 2020, 16:23
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Ok I find:
Code:
   sc_restore:
        invoke  ShowWindow,[hWnd],SW_RESTORE
        invoke  ShowWindow,[hWnd],SW_HIDE
        invoke  AnimateWindow,[hWnd],DWORD 1000,0x00060004
    

Now it is working but I cannot hide window completely before animation -- frame still exist. Problem was hWnd disabled or something when it is minimized. I have to activate hWnd before AnimateWindow() somehow

Actually my program doesn't have window frame, solution works fine. But let me know if there is better way to activate window.
Post 19 Aug 2020, 16:38
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 821
Location: Belarus
DimonSoft
Overclick wrote:
I created little example code special for revolution

Please, note that you’re wrong: you’ve created it for yourself to increase the chance that anyone helps you. And, as you can see, it was your fault in the code you didn’t want to show. And AFAICT this is not the first time it ends up this way.

Maybe it’s a language barrier, but to me the quoted phrase just looks somewhat rude. Maybe it’s time to change your attitude towards people who are willing to help?
Post 19 Aug 2020, 21:26
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
DimonSoft, what fault you talking about? Did you read the code? Do you understand it at all? Do you know better solution for this situation? Sure you don't. That is not my fault revolution doesn't trust people here and my measuring was absolutely correct.
AFAICT is you are local troll that for sure )) Don't message me that way. All you saying around the forum is only spam and flood.
Post 19 Aug 2020, 21:56
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
AnimateWindow() is quite broken function. It also drops a styles for my EditText items until mouse over it.
The fastest solution I've got is to do the same to reload that styles after all. Just one update to ShowWindowAsync -- it works fast and perfect no more artifacts on animation.
Code:
sc_restore:
                invoke  ShowWindowAsync,[hWnd],SW_RESTORE
                invoke  ShowWindowAsync,[hWnd],SW_HIDE
                invoke  AnimateWindow,[hWnd],DWORD 200,0x00020010
                invoke  ShowWindowAsync,[hWnd],SW_HIDE
                invoke  ShowWindowAsync,[hWnd],SW_SHOW    

The same solution I use to initialize Dialogue
Code:
wminitdialog:
                invoke  AnimateWindow,[hWnd],DWORD 200,0x00020010
                invoke  ShowWindowAsync,[hWnd],SW_HIDE
                invoke  ShowWindowAsync,[hWnd],SW_SHOWDEFAULT    
Post 19 Aug 2020, 23:06
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3050
Location: vpcmipstrm
bitRAKE
This is what you need to fix your message processing:
Code:
wmshowwindow:
        test r8d,r8d
        jz do_default
        invoke AnimateWindow,[hWnd],2000,0x00040004
do_default:
        invoke  DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        xor eax,eax
        ret    
WM_SYSCOMMAND is not the correct place to get the effect you want, imho. That is why you get an error. As your window is not present and the system is controlling things. You seem intelligent enough to be able to plug this code into your work - despite communication being difficult.

Darn, that doesn't appear to work right either. Windows will only animate from a hidden state it seems. This makes me want to try it on a regular window - dialog boxes give me so many problems when I try to push them beyond the basic functionality.
Post 20 Aug 2020, 00:52
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
I still working on it. Problem is not resolved. I have random focus lose even if SetFocus or it's daughter SetActiveWindow used after ShowWindow. And I still have some visual artifacts randomly.

bitRAKE, I cannot use your example as ShowWindowAsync calls this messages in loop. Without my trick I lose styles for items. And yes, it's working for new created window only, the minimized needs to be called somehow else. Also I tried to minimize window by different keys -- no difference. But any way WM_SHOWWINDOW is good place to keep SetFocus,[hWnd] there, still testing for focus lose.
Post 20 Aug 2020, 02:00
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3050
Location: vpcmipstrm
bitRAKE
I had another go at it - love a good mystery:
Code:
format PE64 GUI 5.0
entry start
include 'win64a.inc'
section '.text' code readable executable
  start:
        push    rbp
        invoke  GetModuleHandle,0
        mov [hModule],rax
        invoke  GetDesktopWindow
        mov [hDesktop],rax
        invoke  DialogBoxParam,[hModule],37,[hDesktop],DialogProc,0
        invoke  ExitProcess,0

proc DialogProc uses rbx rsi rdi,hWnd,wMsg,wParam,lParam
        mov             [hWnd],rcx
        mov             [wMsg],rdx
        mov             [wParam],r8
        mov             [lParam],r9

        cmp     [wMsg],WM_COMMAND
        je      wmcommand
        cmp     [wMsg],WM_CLOSE
        je      wmclose

        cmp     [wMsg],WM_SHOWWINDOW
        je      wmshowwindow
        cmp     [wMsg],WM_SYSCOMMAND
        je      wmsyscommand
        xor     rax,rax
        jmp     finish
wmshowwindow:
        test r8d,r8d
        jz do_default
        invoke AnimateWindow,[hWnd],1000,0x00040004
do_default:
        invoke  DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        xor eax,eax
        ret

wmsyscommand:
        cmp     [wParam],SC_RESTORE
        je      sc_restore
        invoke  DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        ret
   sc_restore:
        invoke ShowWindowAsync,[hWnd],SW_HIDE
        invoke ShowWindowAsync,[hWnd],SW_SHOWDEFAULT
        invoke DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        mov     rax,1
        ret

wmcommand:
        cmp     [wParam],BN_CLICKED shl 16 + IDOK
        jne     processed
        invoke  ShowWindowAsync,[hWnd],SW_MINIMIZE
        ret
wmclose:
        invoke  EndDialog,[hWnd],0
processed:
        mov     rax,1
finish:
        ret
endp


section '.data' data readable writeable
hModule         rq 1
hDesktop        rq 1

section '.idata' import data readable writeable
  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL'
  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess',\
         GetLastError,'GetLastError'
  import user,\
         DialogBoxParam,'DialogBoxParamA',\
         CheckRadioButton,'CheckRadioButton',\
         GetDesktopWindow,'GetDesktopWindow',\
         GetDlgItemText,'GetDlgItemTextA',\
         IsDlgButtonChecked,'IsDlgButtonChecked',\
         MessageBox,'MessageBoxA',\
         DefWindowProc,'DefWindowProcA',\
         EndDialog,'EndDialog',\
         AnimateWindow,'AnimateWindow',\
         ShowWindowAsync,'ShowWindowAsync'

ID_EDIT_CODE=123
section '.rsrc' resource data readable
  directory RT_DIALOG,dialogs
  resource dialogs,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration
  dialog demonstration,'Create message box', 70,70,190,175,\
  WS_CAPTION or WS_POPUP or WS_SYSMENU or DS_MODALFRAME or DS_CENTER
       dialogitem 'EDIT','<focus me please>',ID_EDIT_CODE,4,4,182,146,\
       WS_TABSTOP\; needed to get default focus
       or WS_VISIBLE or WS_HSCROLL or ES_MULTILINE or ES_NOHIDESEL or ES_WANTRETURN or ES_AUTOVSCROLL
       dialogitem 'BUTTON','OK',IDOK,5,155,45,15,\
       WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
  enddialog    
...even without explicitly setting the focus to the edit box - windows seemed to do the right thing. I kept AnimateWindow in the WM_SHOWWINDOW in order to animate if possible.

_________________
¯\(°_o)/¯ unlicense.org
Post 20 Aug 2020, 06:24
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3050
Location: vpcmipstrm
bitRAKE
Moving from WM_SYSCOMMAND to WM_SIZE might be the way to go -- in the hope that however the window is being restored that it has a chance to animate.
Code:
wmsize:
        cmp [wParam],SIZE_RESTORED
        jnz wmsize_process
        invoke ShowWindowAsync,[hWnd],SW_HIDE
        invoke ShowWindowAsync,[hWnd],SW_SHOWDEFAULT
   wmsize_process:
        invoke DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        xor eax,eax
        ret    
...I ran Microsofts' Spy++ to look at the message queue. These diagnostics helps greatly in solving triggering problems. Hopefully, you have a similar tool to log what is actually happening.
Post 20 Aug 2020, 07:22
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
bitRAKE, what is a diference? You move funcs form one place to another but it still need to be run.
ShowWindowAsync sends new message to wmshowwindow for every single instance. It is loop if wmsize run after that. Otherwice I loose styles and no point to use ShowWindowAsync before animation at all.

What I have:
1) ShowWindowAsync combination needed after animation to fix styles
2) ShowWindowAsync cause focus loss
3) ShowWindow combination needed before animation to restore window
4) Usage of ShowWindow and even ShowWindowAsync cause artifacts
5) ShowWindowAsync is much faster but random artifacts still happens

Focus losing only for one of opened applications. Usually right side.


Description:
Filesize: 41.56 KB
Viewed: 616 Time(s)

Capture.PNG


Description: reloaded styles
Filesize: 2.4 KB
Viewed: 616 Time(s)

OkStyles.PNG


Description: lost styles (for editText only)
Filesize: 1.55 KB
Viewed: 616 Time(s)

LostStyles.PNG


Post 20 Aug 2020, 09:52
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Focus Loss fixed (I hope) by:
Code:
invoke  SendMessage,[hWnd],WM_LBUTTONDOWN,MK_LBUTTON,0
invoke  SendMessage,[hWnd],WM_LBUTTONUP,MK_LBUTTON,0    

It wasn't normal focus losing. It's some strange bug. I find that child item still marked by focus also window can be moved under popped up one. That mean SetFocus helps nothing and the best way is to send fake click on window.

Can someone recognise what kind of style AnimateWindow forces to me? I'm ready to use it like that and give up to find better solution.
Post 20 Aug 2020, 11:05
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Button solution doesn't work. Any way I found new one. No more artifacts on initialisation. Just from time to time at restore. I have to let it be like that. Everything else works smooth as requested.
Code:
sc_restore:
        invoke  ShowWindow,[hWnd],SW_RESTORE
        invoke  InvalidateRect,[hWnd],0,TRUE     ;increases smooth chance I think
        invoke  ShowWindow,[hWnd],SW_HIDE
        invoke  AnimateWindow,[hWnd],200,0x00020010
        invoke  InvalidateRect,[hWnd],0,FALSE   ;reloads items with corrupted by animation styles
        invoke  UpdateWindow,[hWnd]                

Code:
wm_initdialog:
        invoke  AnimateWindow,[hWnd],DWORD 200,0x00020010
        invoke  InvalidateRect,[hWnd],0,FALSE
        invoke  UpdateWindow,[hWnd]    
Post 20 Aug 2020, 16:59
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
Try
invoke AnimateWindow,[hWnd],DWORD 200,DWORD 0x00020010
Post 20 Aug 2020, 17:26
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3050
Location: vpcmipstrm
bitRAKE
Overclick wrote:
bitRAKE, what is a diference? You move funcs form one place to another but it still need to be run.
ShowWindowAsync sends new message to wmshowwindow for every single instance. It is loop if wmsize run after that. Otherwice I loose styles and no point to use ShowWindowAsync before animation at all.
We have a range of time in which a message can give the desired result. One the of strategies I use when trying to debug messages is to move them closer to where they are actually used - the latest possible response.

Also, I'm lazy and would rather use the default processing when possible. For example, if the default dialog handler is invalidating the window then I would position my changes around that so I don't need to invalidate again. Definately not required though.

There is no loop in the code I posted - not sure why you keep mentioning this.

_________________
¯\(°_o)/¯ unlicense.org
Post 21 Aug 2020, 11:06
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.