Window Background Color

This is a discussion on Window Background Color within the Windows Programming forums, part of the Platform Specific Boards category; 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 ...

  1. #1
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Question 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..?!?!?!
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    34
    You need to include Gdi32.lib in your linker settings.

  3. #3
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Question

    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..??
    Last edited by The Brain; 03-12-2009 at 05:00 PM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    34
    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).
    Last edited by Eirik; 03-12-2009 at 09:07 AM.

  5. #5
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    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.
    Last edited by The Brain; 03-12-2009 at 09:47 PM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 11:50 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  5. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 05:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21