Search code examples
c++winapifontsc++builder-6

How to increase size of font in MessageBox c++ builder


*I'm using c++ builder (bcb6)

I would like enlarge font size of message box without creating custom message box.

I searched over google and find that it's possible to use by WM_SETFONT.

I tried doing:

HWND hWnd = CreateWindowEx(0,"WC_DIALOG","Questions!", WS_OVERLAPPEDWINDOW | WS_VISIBLE,400, 100, 100, 100,NULL, NULL, NULL, NULL);
HFONT hFont=CreateFont (30, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial");
SendMessage (hWnd, WM_SETFONT, WPARAM (hFont), TRUE);
MessageBox(hWnd,message.c_str(),"Info",MB_OK | MB_ICONINFORMATION);

And it dorsn't work..

Any suggestions please?

Your help is very appreciated.


Solution

  • There is nothing specific in C++Builder for changing font in a MessageBox. Your options are:

    • Make a custom dialog
    • Use window hooks to change the default MessageBox, via the Windows API.

    Both of these are described in more detail with linked examples on this thread. If you have tried something from that thread and it didn't work then post the code that you tried as a new question.