0

I'd like to build a custom Windows button without subclassing it.

I simply want to draw it, like I would draw a rectangle by calling FillRect().

How do I call the window procedure registered by the BUTTON window class that performs the painting?

update

As noted in the comments, I want to draw an image that looks like a button without having a child window that is a button.

Alex
  • 34,581
  • 26
  • 91
  • 135
  • 4
    Old style: DrawFrameControl. New style: DrawThemeBackground, DrawThemeText, etc. – Andreas Rejbrand Apr 25 '19 at 11:39
  • 1
    @WeatherVane I understand the OP only wants to draw an image that looks like a button without \*really\* having a child window that is a button. – Swordfish Apr 25 '19 at 11:45
  • @Swordfish you are right, that's exactly what I want. – Alex Apr 25 '19 at 12:03
  • @AndreasRejbrand thanks! I love WinAPI. It has everything. It even has all possible states! Can you post an answer? – Alex Apr 25 '19 at 12:07
  • Do you actually want the thing to respond to user input? If you do, do subclass a BUTTON control. There's so much logic built in for you to use, that you may not even be aware of (e.g. mouse hovering logic, accessibility, etc.). – IInspectable Apr 25 '19 at 14:44
  • @IInspectable the reason I'm doing this is I'm playing with building an immediate mode GUI on top of Windows API :) So I'll have to handle the states myself. Luckily I can draw specific states with `DrawThemeBackground()` – Alex Apr 26 '19 at 11:20
  • 1
    Advice from someone, who has written Windows code for decades, and used a fair number of frameworks/toolkits that went with what you are trying to do: Every single one of them failed to deliver. You won't know how much logic is in even the simplest controls (like a button), until you start to replicate it. Just 2 examples: Click your button and while holding the mouse button pressed, move outside the button and back in. How would you account for proper state transitions here? Or, click your button, and while holding the mouse button pressed, hit [Esc]. There's more, **lots** more to consider. – IInspectable Apr 26 '19 at 11:58
  • You are right of course. This is a pure educational project. I just want to learn about immediate UI. – Alex Apr 26 '19 at 13:30

1 Answers1

0

By Andreas Rejbrand:

Old style: DrawFrameControl. New style: DrawThemeBackground, DrawThemeText, etc.

Alex
  • 34,581
  • 26
  • 91
  • 135