flat assembler
Message board for the users of flat assembler.

Index > Windows > I like print text on static windows. But blink staticHwnd.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 2111
Roman 16 Aug 2026, 11:43
I like static window. Creating without regclass and simple easy.

But blinking static windows when i do
Code:
invoke SendMessage,[StaticInfoHwnd],WM_SETTEXT,0,TextBuffer    


How fixing blinking ? I try do Sleep(60) but sometimes blinking static window.
Post 16 Aug 2026, 11:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 21055
Location: In your JS exploiting you and your system
revolution 16 Aug 2026, 11:50
The recommend way to repaint without "blinking" is to create an in-memory bitmap, erase/paint/update the bitmap. Then BitBlt to the screen, overwriting the previous pixels without erasing them first.

IIRC there is an OWNERDRAW property to have Windows call the custom update code, instead of using the default library code.
Post 16 Aug 2026, 11:50
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2111
Roman 16 Aug 2026, 12:03
I try do this.
Code:
proc StaticWndProc  hwnd, msg, wParam, lParam
        .if [msg] = WM_PAINT

        invoke  BeginPaint,[hwnd],ps
        rept 0 {

            invoke GetDesktopWindow
            invoke GetWindowDC,eax
            }
            ;invoke GetDC,[StaticInfoHwnd]
            mov [.DC],eax
            invoke GetClientRect,[hwnd],.rect
            invoke CreateCompatibleDC,[.DC]
            mov [.memDC],eax
            mov ecx,[.rect+8]
            sub ecx,[.rect]
            mov edx,[.rect+12]
            sub edx,[.rect+4]
            push edx ecx
            invoke CreateCompatibleBitmap,[.DC], ecx, edx
            mov ebx,eax
            invoke SelectObject,[.memDC], eax
            ;draw
            ;invoke FillRect,[.memDC],.rect,COLOR_WINDOW+2
            inc byte [.txt]
            invoke SetBkColor,[.memDC],0
            invoke SetTextColor,[.memDC],0x00ffffff
            invoke TextOut,[.memDC], [.rect], 100,  .txt , 17
            ;invoke Sleep,1200
            pop ecx edx
            invoke BitBlt,[.DC], 0, 0, ecx, edx,[.memDC], 0, 0, SRCCOPY
            invoke SelectObject,[.memDC],0
            invoke EndPaint,[hwnd],ps
        invoke DeleteObject,ebx
        invoke DeleteDC,[.memDC]
        ;invoke UpdateWindow,[hwnd]
        ;invoke  ShowWindow,[hwnd],1
        xor eax,eax
        ret
        .endif

        invoke  DefWindowProc, [hwnd], [msg], [wParam], [lParam]
        ;invoke CallWindowProc, GWL_WNDPROC ,[hwnd], [msg], [wParam], [lParam]
        ;mov eax,0
        ret
        .txt    db "0 Text of text out",0
        .rect   dd 0,0,0,0
        .DC     dd 0
        .memDC  dd 0
        ps      dd 0,0,0,0,0,0
        StaticInfoHwnd dd 0
endp   

invoke  CreateWindowEx, WS_EX_TOPMOST, 'static', "",SS_CENTER+WS_VISIBLE+SS_OWNERDRAW,\
                900, 0,dword 340, dword 580, 0, 0,0, 0
mov [StaticInfoHwnd],eax
    

        invoke SetWindowLong,eax, GWL_WNDPROC, StaticWndProc 
    


Last edited by Roman on 16 Aug 2026, 14:03; edited 2 times in total
Post 16 Aug 2026, 12:03
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2111
Roman 16 Aug 2026, 14:02
In main loop we do(for redraw Static window)
invoke InvalidateRect, [StaticInfoHwnd],0,1
invoke UpdateWindow,[StaticInfoHwnd]
Post 16 Aug 2026, 14:02
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 895
Ali.Z 16 Aug 2026, 20:44
Roman wrote:
invoke InvalidateRect, [StaticInfoHwnd],0,1

in general erasing bkgnd is very expensive operation, it is the root cause for flickering.

_________________
Asm For Wise Humans
Post 16 Aug 2026, 20:44
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2111
Roman 17 Aug 2026, 06:15
This variant not have flickering.
I tested. Work good.
Post 17 Aug 2026, 06:15
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.