-
Window Background Color
Hello,
I am reading this tutorial: http://http://www.functionx.com/win32/Lesson01b.htm on how to set a window background color.
I have tried:
Code:
wincl.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(0,255,0));
and
wincl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
Both methods give me the following errors:
[Linker error] undefined reference to `CreateSolidBrush@4'
and
[Linker error] undefined reference to `GetStockObject@4'
I am using Dev Cpp version 4.9.9.2 and attempting to compile a known working program as a windows project.
Why can't I perform this simple operation..?!?!?! :confused:
-
You need to include Gdi32.lib in your linker settings.
-
I just completed some googling on how to add .lib's to dev cpp and haven't found anything yet.. I have however, added a winsock library in the under, "project options" in the past, so I have a little experience; but at this point it is not possible because the 'project options' menu is not available to me (inactive).
Any tips on how to add Gdi32.lib in Dev Cpp..?? :confused:
-
I Just downloaded Dev-C++, but it doesn't seem to provide the library files. You will be needing those.
Anyway, for adding them, right click on your project in the tree menu at the left, and select 'Project Options', then select the 'Parameters' tab and push the 'Add Library or Object' button. Then browse to where you have stored the library files.
I guess you could get the library files by downloading a windows SDK, or you may for instance download Code::Blocks IDE - which I would deem as a decent alternative to Dev-C++ - available here. Or at least just for the libraries, anyway. I know Code::Blocks will provide you with the those (in [Install directory]\lib). In this case they all have a 'lib'-prefix and an 'a'-suffix (e.g. libgdi32.a).
-
Thanks for your help Eirik..
The solution I have come up with thus far, is to copy and paste the default window template that is automatically generated by dev cpp for windows projects and copy/paste it into codeblocks. Then, I was able to affect the background attribute of the window.
Why do they make it so hard to do just simple things.... 2 days wasted on just setting background color. :rolleyes: