is there any way to change the background of a windows application?
thanks in advance.
is there any way to change the background of a windows application?
thanks in advance.
yes.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
lol maybe, I can be more specific than the other two fellas there..
The window proprerty when you set up a window called.
windowClass.hbrBackground;
can be set to other colors previoiusly defined in windows.h
I'm not sure of all of the possibilities, but it has to be of the HBRUSH type.
try googling it.
My Favorite Programming Line:
Code:#define true ((rand() % 2) ? true : false)
@JJRMJR
He only asked if it were possible
OS: Windows 7, XUbuntu 11.10, Arch Linux
IDE: CodeBlocks
Compiler: GCC
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
i want to be able to change the color to something other than gray, white, or black. i am currently making a program intended for children, and it would be more appealing if it were colorful.
one way is to handle the WM_ERASEBKGND message by selecting an HBRUSH into the target window's device context, then calling PatBlt() to paint to the window, and finally returning 1 (ie: true) from the callback procedure to indicate that you do not want the operating system to clear the window with the default brush.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Also you can setup the background color on the 'WNDCLASSEX' struct (before register it), take a lok at the 'hbrBackground' parameter: it's an HBRUSH type, so you can assign any color in this type
I think that the right way for the second method is to create a global brush, and free it before quit the programCode://for a white background: wc.hbrBackground=HBRUSH)GetStockObject(WHITE_BRUSH); //or in red: wc.hbrBackground=(HBRUSH)CreateSolidBrush(0x000000ff);
(I have omited a lot of code, only left the important part). The 'reb' brush is declared as global, and before end I free the memory used.Code:static HBRUSH red=(HBRUSH)CreateSolidBrush(0x000000ff); WINAPI WinMain(...) { WNDCLASSEX wc; ... wc.hbrBackground=red; ... MakeTheLoopHere(); //free all and return DeleteObject(red); return msg.wParam; }
Hope that helps.
Niara