flat assembler
Message board for the users of flat assembler.

Index > Windows > Redraw item over system button

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



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 05 Aug 2020, 18:14
Hi
How can I redraw some item (image) over system button on DialogBox?
It hides my item when system button redraws itself, anytime mouse over it.
Show it by Timer is not very good idea
Code:
invoke  GetDlgItem,[hWnd],1002
mov     [hItem],rax
invoke  ShowWindow,[hItem],SW_HIDE
invoke  ShowWindow,[hItem],SW_SHOW
    


Description:
Filesize: 1.7 KB
Viewed: 13793 Time(s)

Capture.PNG


Post 05 Aug 2020, 18:14
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: 20453
Location: In your JS exploiting you and your system
revolution 05 Aug 2020, 22:50
You didn't show how you are defining the button, or indeed anything, but there is a flag ownerdraw that you can set to draw your own graphics.
Post 05 Aug 2020, 22:50
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 05 Aug 2020, 23:59
As I said it is a system button BS_PUSHBUTTON it cannot be BS_OWNERDRAW at same time. I need trick to renew my picture over it in time when it redraws itself.
Post 05 Aug 2020, 23:59
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: 20453
Location: In your JS exploiting you and your system
revolution 06 Aug 2020, 03:05
You might be able to sub-class it and capture the paint message.
Post 06 Aug 2020, 03:05
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 06 Aug 2020, 04:27
Can't you use the BS_BITMAP style and set the image with BM_SETIMAGE when you initialise the dialog box?
Post 06 Aug 2020, 04:27
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 06 Aug 2020, 12:46
BS_PUSHBUTTON buttons have its own nice animation that why I want to use them. Nothing I can do with them directly even change colors. Tell me how if you know.

revolution, does it mean I will prevent its own redrawing? I have to do something after it. Or maybe force my picture to be always on top somehow...

sinsi, Resourse redactor don't let me to set BS_BITMAP or BS_ICON to BS_PUSHBUTTON, I'll try to force it...
Post 06 Aug 2020, 12:46
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: 20453
Location: In your JS exploiting you and your system
revolution 06 Aug 2020, 12:50
Overclick wrote:
revolution, does it mean I will prevent its own redrawing? I have to do something after it. Or maybe force my picture to be always on top somehow...
When you capture the paint message then you can decide what to do. You can draw something first then pass on the message, or you can pass the message first then draw later, or you can draw your own and never pass the message on. Depends upon your requirements.
Post 06 Aug 2020, 12:50
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 06 Aug 2020, 13:38
revolution, Any example? How can I change class for given by res file item? Does it mean to create child window for button separately? BS_PUSHBUTTON have only WM_COMMAND messages doesn't it?
Post 06 Aug 2020, 13:38
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2568
Furs 06 Aug 2020, 14:43
Try to handle NM_CUSTOMDRAW notifications? Sounds like exactly what you're looking for. Make sure you use a manifest for buttons:
MSDN wrote:
Custom draw is also supported for button controls if you have an application manifest to ensure that Comctl32.dll version 6 is available.
That's how the Windows XP calculator draws its buttons, btw.
Post 06 Aug 2020, 14:43
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 06 Aug 2020, 18:45
Furs, seems you're right, I need to use CDDS_POSTPAINT or CDDS_ITEMPOSTPAINT.
How to find NMCUSTOMDRAW structure? I find NMHDR only. Or have I declare it first? Then how?

Code:
wmnotify:
        mov             rax,[r9+8]     ;r9 is [lParam] by default
        cmp             rax,ID_ON
        je              notify_id_on
        xor             rax,rax
        ret
        notify_id_on:
                mov             eax,[r9+16]
                cmp             eax,NM_CUSTOMDRAW
                jne             nothing
                        mov             eax,[r9+??????]
                        cmp             eax,CDDS_POSTPAINT
                        jne             nothing
    
Post 06 Aug 2020, 18:45
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 09 Aug 2020, 04:56
Code:
wmnotify:
        mov             rax,[r9+8]
        cmp             rax,ID_ON
        je              notify_id_on
        xor             rax,rax
        ret
        notify_id_on:
                mov             eax,[r9+16]
                cmp             eax,NM_CUSTOMDRAW
                jne             nothing
                        mov             eax,[r9+24]
                        cmp             eax,CDDS_PREPAINT
                        jne             @F
                                mov     rax,CDRF_NOTIFYPOSTPAINT
                                ret
                        @@:
                        cmp             eax,CDDS_POSTPAINT              
                        je              @F
                                mov     rax,CDRF_NOTIFYPOSTPAINT
                                ret
                        @@:
                        invoke  GetDlgItem,[hWnd],1002
                        mov     [hItem],rax
                        invoke  ShowWindow,[hItem],SW_HIDE
                        invoke  ShowWindow,[hItem],SW_SHOW
                        mov             rax,CDRF_SKIPDEFAULT
                        ret    

Still nothing. dwDrawStage returns only CDDS_PREPAINT and CDDS_PREERASE messages but never CDDS_POSTPAINT even ordered by CDRF_NOTIFYPOSTPAINT.

What am I doing wrong?
Post 09 Aug 2020, 04:56
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 09 Aug 2020, 05:08
You realize that BS_PUSHBUTTON=0, so it isn't really a style at all...BS_OWNERDRAW by itself is all you need.
Post 09 Aug 2020, 05:08
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 09 Aug 2020, 05:52
How that working here then?
example
Post 09 Aug 2020, 05:52
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 09 Aug 2020, 06:15
Post 09 Aug 2020, 06:15
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 09 Aug 2020, 06:44
I don't understand what you are trying to do. Showing a button with an image should be as simple as using BS_BITMAP.

Using owner draw or custom draw gives you more control over the button's appearance but is a lot of code.
Post 09 Aug 2020, 06:44
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 09 Aug 2020, 07:17
sinsi, could you create nice animation for me? No? Of course it's easy to create some choppy button. But I prefer to use default one.
Post 09 Aug 2020, 07:17
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 09 Aug 2020, 09:02
Ah, so animation.
Post 09 Aug 2020, 09:02
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2568
Furs 09 Aug 2020, 16:45
Overclick wrote:
Furs, seems you're right, I need to use CDDS_POSTPAINT or CDDS_ITEMPOSTPAINT.
How to find NMCUSTOMDRAW structure? I find NMHDR only. Or have I declare it first? Then how?
The header is at the start of the structure. See: https://docs.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmcustomdraw
Post 09 Aug 2020, 16:45
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 10 Aug 2020, 02:26
Furs I find it by memory scan then it dawned on me it's one structure))
It doesn't send POSTPAINT any way. I have to find another solution or search for nice pictured ownerdraw buttons.
Post 10 Aug 2020, 02:26
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2568
Furs 10 Aug 2020, 13:01
If you want to get CDDS_POSTPAINT, you have to return CDRF_NOTIFYPOSTPAINT from the CDDS_PREPAINT handler.
Post 10 Aug 2020, 13:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.