S
S
s2sk2018-09-07 14:29:52
C++ / C#
s2sk, 2018-09-07 14:29:52

How to change the default view of controls in Windows?

Hi all.
Even I can not figure out how to change the default view of windows.
Let's say I created an input field CreateWindow("EDIT", ...); how now to round off the edges, make a shadow, change the background, set the color of the stroke and the text in it? And the same goes for buttons.
Please don't suggest QT and stuff

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SerJook, 2018-09-07
@SerJook

In Winapi, you cannot flexibly change the appearance of controls, as you can do in HTML/CSS.
I can say about the button.
Set its style to BS_OWNERDRAW, and in the parent window handle the WM_DRAWITEM message and draw the button however you like. That is, you essentially have to repeat the behavior of the button from scratch in all its states (cursor hovered/pressed/released/disabled, etc.). Depending on what you want to achieve, you can use GDI/GDI+ or another graphics library for rendering. If you want the button to look like a standard button, use the Visual Styles API.
With Edit control it is more difficult. It does not support ownerdraw. To remove a border, make sure it doesn't have the WS_BORDER and WS_EX_CLIENTEDGE styles.
To change the text or background color, handle WM_CTLCOLOREDIT in the parent window. You can manually draw the shadow and border around the edit control in the parent window.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question