Dialog Button Color

I am unable to get the background color of a dialog button to match that of the dialog. I am using the following code:

invoke GetDlgItem, hWnd, IDC_ABOUTCLOSE
            mov    hButtonClose, eax
            invoke SetWindowPos, hButtonClose, 0, 253, 220, 70, 20, NULL
            invoke SendMessage,  hButtonClose, WM_SETFONT, hAboutFont, NULL
            
            invoke SetProp, hButtonClose, ADDR FGRND, 0
            
            RGB 185, 185, 185
            
            mov    BtnColor, eax
            
            invoke SetProp, hButtonClose, ADDR BGRND, addr BtnColor
            
            invoke GetProp, hButtonClose, ADDR BBRUSH
            mov hBrush, eax
            
            RGB 185, 185, 185
            invoke CreateSolidBrush, eax            
            invoke SetProp, hButtonClose, ADDR BBRUSH, addr BtnColor
            
            .if hBrush
                  invoke DeleteObject, hBrush
            .endif
            invoke InvalidateRect, hButtonClose, NULL,TRUE

I have tried everything I can think of, or I find on the net.
Bruce PeasleeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sarabandeCommented:
actually, i never seen assembly code for dialog handling before ... what is the advantage? even windows is using c and winapi ....

nevertheless, i would assume, that the above coding wouldn't work in c or mfc either. i think the InvalidateRect to the button window will not cause any painting action since the dialog is responsible for painting its children.

you either could try to calculate the rectangle where the button was located relative to the dialog client window and invoke InvalidateRect for the dialog window using passing the address of the rectangle as argument, or, you hide/show the button. both actions might cause the button to be redrawn. if the color nevertheless was not changing, i would try again but not deleting the brush created.

Sara
Bruce PeasleeAuthor Commented:
The solution is much simpler than what I was trying. Use a bitmap button.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bruce PeasleeAuthor Commented:
It worked and was simple.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Assembly

From novice to tech pro — start learning today.