Hi,
I am using Dev-C++ 4.9.9.2 with g++ compiler.
I recently made a DLL in c++ that shows a window using Windows API. I discovered that the text shown inside are large and bold, which aren't looking very good. I want to change this, so I used the following code (similar):

#include <windows.h>

//... sonething else ...

HFONT hf = CreateFont(nHeight,
    nWidth,
    nEscapement,
    nOrientation,
    fnWeight,
    fdwItalic,
    fdwUnderline,
    fdwStrikeOut,
    fdwCharSet,
    fdwOutputPrecision,
    fdwClipPrecision,
    fdwQuality,
    fdwPitchAndFamily,
    lpszFace
);

SendDlgItemMessage(myHwnd,
    IDC_TEST,
    WM_SETFONT,
    (WPARAM) hf,
    (LPARAM) true
);
//... other stuff ...

I got this error:

[Linker error] undefined reference to `CreateFontA@56'

That seems not the problem of my source, but a problem around wingdi.h and libgdi32.a. I've searched through G**gle but I can't find one suitable solution.

May I use this code but be able to link it? Or is there other solutions to change the font? Hopefully I wouldn't have to get a new library.

Could anyone help, I would be thankful.

Thanks,
alvinwong

I did a quick google search and found the answer on the GameDev.Net forums. You need to link with the following:
-lwinmm
-lgdi32

Wow! I don't understand. Why I need to use extra library? I thought I have already had libgdi32.a and wingdi32.h?

I only have these two files that contains "gdi". Where am I be able to get it work? I am not familiar to the linker...

Oh, well, I finally managed to do it.

I am creating a DLL, so that some windows library aren't included automatically.

To tell others how to do this, if you are using Dev-C++, click "Project"->"Project Options"->"Parameters" tab->"Add Library or Object"->select the library file (located at <devcpp's dir>\lib, usually similar to the header file: eg. wingdi.h->libgdi32.a)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.