Click to See Complete Forum and Search --> : Change of a bitmap on static control


sgergo
October 21st, 2008, 05:23 AM
Hello to all!

I am developing a small application and I am working on its GUI. It is a pump control application and it has several buttons (on/off, port change, direction etc.). For a nicer look I decided to implement some static controls with bitmaps just to show that the particular button is in which state. It is basically an empty static field where I would like to change the bitmap depending on the state of the button.

I couldn't find the solution, so now, I always create a new static control when the user pushes the button - and these controls probably end up lying on each other and allocating memory at every push. It's not nice. The code here:

#define ST_OP_ON CreateWindowEx(0, "static", "STOPON", WS_VISIBLE | WS_CHILD | SS_BITMAP, 200, 30, 100, 5, hwnd, (HMENU)OP_ST, hInst, NULL);

#define ST_OP_OFF CreateWindowEx(0, "static", "STOPOFF", WS_VISIBLE | WS_CHILD | SS_BITMAP, 200, 30, 100, 5, hwnd, (HMENU)OP_ST, hInst, NULL);


I'm looking for a solution how to change the bitmap on static controls OR how to kill child windows at runtime. All help would be highly appreciated.

Cheers, sg

Krishnaa
October 21st, 2008, 05:53 AM
You should subclass(using SetWindowLong API) the static control and paint the required image by yourself.

fred100
October 21st, 2008, 11:23 AM
You absolutely don't need subclassing (!)
Just use STM_SETIMAGE (basic standard message...)

sgergo
October 22nd, 2008, 06:32 AM
Thx guys for the input.

Managed to solve my problem with fred100's tip, rep went to him.

Cheers!