flat assembler
Message board for the users of flat assembler.

Index > Windows > Tooltip flickering issue

Author
Thread Post new topic Reply to topic
extra_12345



Joined: 21 Apr 2020
Posts: 45
extra_12345 12 Dec 2024, 23:49
So I created tooltip to be shown over my editbox and it works but the problem is that it keeps flickering and I got no idea how to fix it, I googled around and found nothing much related to this, this is the code:

this is how I initialize it:

Code:

invoke CreateWindowExA,WS_EX_TOPMOST or WS_EX_TRANSPARENT, class_tooltip,0,WS_POPUP or TTS_ALWAYSTIP or TTS_NOPREFIX, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, [hWnd], 0, [hInst] , 0
mov [hwnd_Tooltip_string], rax
invoke GetDlgItem, [hWnd], 10
stdcall SetToolTip, rax, tooltip_text_string, [hwnd_Tooltip_string]      



and SetToolTip proc:

Code:

proc SetToolTip, hwnd, tiptext, hwnd_tooltip

mov [hwnd],rcx
mov [tiptext],rdx
mov [hwnd_tooltip],r8

    ; Define tool info structure
    local ti:TOOLINFO

    mov [ti.cbSize], sizeof.TOOLINFO
    mov [ti.uFlags], TTF_SUBCLASS or TTF_IDISHWND
    mov [ti.hwnd], rcx
    mov [ti.uId], rcx
    mov [ti.hInst], 0
    mov [ti.lpszText], rdx

    ; Add the tooltip
    invoke SendMessageA, [hwnd_tooltip], TTM_ADDTOOL, 0,addr ti
    ret

endp     


also I'm using DialogBox if that makes any difference.
Post 12 Dec 2024, 23:49
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 13 Dec 2024, 03:10
I would first try WS_EX_NOACTIVATE.

Then does removing WS_EX_TRANSPARENT solve the flickering problem? (WS_EX_TOPMOST should be sufficient.) IIRC, This message links painting to updates of controls below the tooltip and those updates are triggering redraw of the tooltip. Nothing in the code fragment you've shown indicates a need for WS_EX_TRANSPARENT.

(In this example, I show the minimum required. The window hierarchy is sufficient to setup draw order - the parent is a dialog.)

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 13 Dec 2024, 03:10
View user's profile Send private message Visit poster's website Reply with quote
extra_12345



Joined: 21 Apr 2020
Posts: 45
extra_12345 13 Dec 2024, 09:49
bitRAKE wrote:
I would first try WS_EX_NOACTIVATE.

Then does removing WS_EX_TRANSPARENT solve the flickering problem? (WS_EX_TOPMOST should be sufficient.) IIRC, This message links painting to updates of controls below the tooltip and those updates are triggering redraw of the tooltip. Nothing in the code fragment you've shown indicates a need for WS_EX_TRANSPARENT.

(In this example, I show the minimum required. The window hierarchy is sufficient to setup draw order - the parent is a dialog.)


thanks for the reply, I removed WS_EX_TRANSPARENT but it's still flickering, so weird.

Code:
invoke CreateWindowExA,WS_EX_TOPMOST or WS_EX_NOACTIVATE, class_tooltip,0,WS_POPUP or TTS_ALWAYSTIP or TTS_NOPREFIX, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, [hWnd], 0, [hInst] , 0
mov [hwnd_Tooltip_string], rax
invoke GetDlgItem, [hWnd], 10
stdcall SetToolTip, rax, tooltip_text_string, [hwnd_Tooltip_string]     
Post 13 Dec 2024, 09:49
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1041
Location: Russia
macomics 13 Dec 2024, 11:05
Most likely, it's not about the flags. What is it that is so fast redrawing the window? There's not much to say without the window procedure code.

Maybe you have some kind of timer there that changes the states of child windows, which is why there are constant redraws?
Post 13 Dec 2024, 11:05
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1671
Location: Toronto, Canada
AsmGuru62 13 Dec 2024, 13:31
If 'class_tooltip' is your own window class --- probably should post here the WNDPROC for the class.

Also, I recall something from long ago (when I used tooltips system provided by Win API) --- there is an interesting fact
about WM_MOUSEMOVE message: lets say you have a mouse cursor on X,Y on some pixel on screen.
Then window pops up and covers that pixel. When that same window will disappear, the underneath window will receive the WM_MOUSEMOVE.
However, it is same X,Y --- no mouse movement was really done. Just by the other popup window appearing and disappearing, your
window will get WM_MOUSEMOVE on the same pixel.

Also, as I said, would be nice to see the WNDPROC, I am not sure if 'class_tooltip' is a WIN API class or yours?

Also #2: it is a good debugging trick to use OutputDebugString to print into debugger window.
When you deal with mouse and focuses and activation messages --- debugger stopping on a breakpoint will affect all those events.
To understand what is really happening --- you need to print and not stop on breaks.
Post 13 Dec 2024, 13:31
View user's profile Send private message Send e-mail Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1041
Location: Russia
macomics 13 Dec 2024, 14:11
AsmGuru62 wrote:
lets say you have a mouse cursor on X,Y on some pixel on screen.
Then window pops up and covers that pixel. When that same window will disappear, the underneath window will receive the WM_MOUSEMOVE.
However, it is same X,Y --- no mouse movement was really done. Just by the other popup window appearing and disappearing, your
window will get WM_MOUSEMOVE on the same pixel.
This is not WM_MOUSEMOVE, but WM_MOUSEFIRST. A signal that the cursor has appeared above the window.
Post 13 Dec 2024, 14:11
View user's profile Send private message Reply with quote
extra_12345



Joined: 21 Apr 2020
Posts: 45
extra_12345 13 Dec 2024, 15:51
This is the WindowProc:

proc MainProc uses rbx rsi rdi,hwnd,msg,wparam,lparam

local pt:POINT


mov [hwnd],rcx
mov [msg],rdx
mov [wparam],r8
mov [lparam],r9

.if [msg] = WM_CLOSE


invoke EndDialog,[hwnd],0
mov eax,1



.elseif [msg] = WM_INITDIALOG

invoke GetModuleHandle,0
invoke CreateWindowExA,WS_EX_TOPMOST or WS_EX_NOACTIVATE, class_tooltip,0,WS_POPUP or TTS_ALWAYSTIP or TTS_NOPREFIX, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, [hwnd], 0, rax , 0
mov [hwnd_Tooltip_string], rax
invoke GetDlgItem, [hwnd], 10
stdcall SetToolTip, rax, tooltip_text_string, [hwnd_Tooltip_string]

mov rax,[hwnd]
mov [hWnd],rax

mov eax,1

.else


xor eax,eax

.endif


ret

endp

and class_tooltip is just a string indicating tooltip class to be used to create the window:

class_tooltip db 'tooltips_class32',0 ; Tooltip class

not sure if it helps but when I press and hold a key let's say space then flickering goes away and tooltip appears.
Post 13 Dec 2024, 15:51
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1041
Location: Russia
macomics 13 Dec 2024, 16:15
Try use
Code:
invoke SetWindowPos, [hwnd_Tooltip_string], HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE    
w\o using WM_EX_TOPMOST

Otherwise it should work.
Post 13 Dec 2024, 16:15
View user's profile Send private message Reply with quote
extra_12345



Joined: 21 Apr 2020
Posts: 45
extra_12345 13 Dec 2024, 17:33
macomics wrote:
Try use
Code:
invoke SetWindowPos, [hwnd_Tooltip_string], HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE    
w\o using WM_EX_TOPMOST

Otherwise it should work.


I tried this too and it's still flickering unfortunately.
Post 13 Dec 2024, 17:33
View user's profile Send private message Reply with quote
extra_12345



Joined: 21 Apr 2020
Posts: 45
extra_12345 13 Dec 2024, 17:53
Figured what was the issue, it's the Windows resolution scaling (often found in Display Settings as "Scale and Layout"), when it's set to %150 then it starts flickering but it's fine on %125 and %100 and I got no idea how to fix it.
Post 13 Dec 2024, 17:53
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1041
Location: Russia
macomics 13 Dec 2024, 18:07
extra_12345 wrote:
Figured what was the issue, it's the Windows resolution scaling (often found in Display Settings as "Scale and Layout"), when it's set to %150 then it starts flickering but it's fine on %125 and %100 and I got no idea how to fix it.
Then all that remains is to create your own window with a hint or intercept the system window procedure and create a superclass.
Post 13 Dec 2024, 18:07
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 732
Ali.Z 15 Dec 2024, 15:44
i dont believe super/sub-class is needed, it is an overkill.

this is mostly dpi awareness and dpi behavior, by defaut on recent windows automatic dpi scaling for apps is handled by the system.

it is either you change ur dpi awareness during runtime, or manifest that define the dpi behavior.

a possible solution is right-click the exe, set who will handle dpi thing, app or system.

_________________
Asm For Wise Humans
Post 15 Dec 2024, 15:44
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.