C++ - win32: can i change the window controls font?

Started by
3 comments, last by cambalinho 7 years, 6 months ago

for change the wiindow controls font:


void setFont(HFONT font)
        {
            SendMessage(hwnd, WM_SETFONT, WPARAM (font),  MAKELPARAM(TRUE, 0));
        }

i don't understand how can i test the SendMessage() failling, but the window font isn't changed. why? did i miss something?

Advertisement

It is impossible to answer your question with so little details, we need more context. I suggest you read the remark section in the MSDN page about WM_SETFONT message :

https://msdn.microsoft.com/en-us/library/windows/desktop/ms632642(v=vs.85).aspx

Have you tried to call GetLastError to determine why it is failing if it is really failing ? To get details about the error code returned by GetLastError, you can use Error Lookup in Visual Studio Tool menu.

We think in generalities, but we live in details.
- Alfred North Whitehead

the GetLastError() it's zero(no error).

after more search's and information, i found that the font can, only, be changed on control creation or on owner drawed control(WM_DRAWITEM and WM_PAINT messages(on menus, the WM_MEASUREITEM is for change menu item size))

but please try to answer to anotherthing: when i use the SendMessage(), how i can test it if it's failling?(i'm confused)

https://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx

"The return value specifies the result of the message processing; it depends on the message sent."

can you, please explain more? i'm confused :(

As explained in https://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx, how to interpret the return value for SendMessage depends on the message sent. With many window messages, it will return 0 if the target didn't process the message. It doesn't necessarily mean an error occured but simply that the target didn't process the message (often because that target doesn't process that kind of message).

In general, you have to consult the documentation for the specific message to know how to interpret the return value of SendMessage.

We think in generalities, but we live in details.
- Alfred North Whitehead

thank you so much

This topic is closed to new replies.

Advertisement