Moberg
Moberg

Reputation: 5503

How do I get the handle to a brush, Win32 C++

I'm creating a Dialog window with some button controls. I want the buttons to be coloured individually. I've searched and found something that I think I should use, the WM_CTLCOLORBTN Message.

As stated the return value should be a "handle to a brush".

I can create a brush, for example like this:

HBRUSH blueBrush=CreateSolidBrush(RGB(0,255,0));

but how do I return the handle to this brush?

EDIT: My message handling function is defined as

LRESULT CALLBACK ClientDlgProc(...)

and if I try to return blueBrush I get this error:

error C2440: 'return' : cannot convert from 'HBRUSH' to 'LRESULT'

Upvotes: 0

Views: 1897

Answers (2)

David Heffernan
David Heffernan

Reputation: 612963

An HBRUSH is the handle to the brush. Return blueBrush.

Upvotes: 0

Rune Aamodt
Rune Aamodt

Reputation: 2611

I'm pretty sure the value returned by CreateSolidBrush is the handle (the H in HBRUSH stands for 'handle').

Upvotes: 3

Related Questions