
Introduction
I was writing a program on PPC 2002 and the program UI required a dialog with a bitmap image background. As I was designing the dialog in the eVC++ 3.0 dialog template editor, I added controls like static texts, group boxes and etc. I checked the transparent option in the property of each of the controls that I have added to the dialog. But on PPC 2002 the transparent option does not work like it does on PC Platform OSes. On CE, transparent windows behave as if they have WS_CLIPCHILDREN style set. You can see through the parent dialog window itself. Definately not the effect I was hoping for.
There is an article for making transparent static texts at http://www.pocketpcdn.com/ and http://www.pocketpcdn.com/articles/transparent_static.html. It basically draws all of the static text in the WM_PAINT handler of the parent dialog procedure. But if you have other controls such as group boxes, you will have to draw the group boxes yourself.
To solve this problem, I used the WM_CTLCOLORSTATIC message handler. I first created a pattern brush with the bitmap image to be used as the backround for the dialog window. And in the WM_CTLCOLORSTATIC message handler in the dialog procedure, I returned the brush handle I created previously. The downside to this method is that you'll have to create separate brushes for each of the controls that are to be transparent which means more memory usage. But you get the desired effect.
| You must Sign In to use this message board. |
|
| | Msgs 1 to 10 of 10 (Total in Forum: 10) (Refresh) | FirstPrevNext |
|
 |
|
|
 |
|
 |
When there are about 600 or so controls, each w/ its own CBrush, eventually a message box is displayed that states "Required Resource was" There is still a good amount of memory, but I seem to be running into a resource limit? Ideas?
thanks!
-- modified at 10:18 Wednesday 29th March, 2006
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
First of all congratulations on a very good article. But your article only works for a static background image you know beforehand. What happens when you have a dynamic background ? I have tried copying the background of the parent window, but alas I only get the background of the parent window (because of the CLIPCHILDREN peculiarity of windows CE). Is the solution to handle all painting of my controls from the paint event of the parent dialog (so everything will be painted on the same dc) ?
|
| Sign In·View Thread·PermaLink | 2.50/5 (3 votes) |
|
|
|
 |
|
 |
You can create new brush from the changed bitmap and return it as the return value of WM_CTLCOLORSTATIC handler. I haven't tested it with an actual code but i think it will work.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
I'm using this principe of building brushes for each transparent control in my form and return theim in the WM_CTLCOLORSTATIC message handler. It works great ! Thanks.
But...
What about the comboboxes ? It seems to does not work so fine ;-( . The arrow, on the right, the borders are transparent but the label is not. I suppose it's because no brush is made for the lable contained in the combobox 
Any solution ?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
I want to use this sample only with myu seond dialog box. There is no matter to load the BMP, but all the static controls aren't transparent.
Do you know why button can't be transparent?
Thank you
Sorry for My poor English 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Buttons are whole different kind of controls.. You should ownder draw the button with the backgound image.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
ON_MESSAGE( WM_CTLCOLORBTN, OnCtlColorButton ) try to rewrite the handler to this message
hah
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
You can have only one brush with background image.
HBRUSH g_hBkBrush;
....
case WM_CTLCOLORSTATIC: { HDC hStaticDC=(HDC)wParam; HWND hStaticWnd=(HWND)lParam; RECT rc;
::GetWindowRect(hStaticWnd,&rc); ::MapWindowPoints(hStaticWnd,hWnd,(POINT*)&rc,2); ::SetBrushOrgEx(hStaticDC,-rc.left,-rc.top,NULL);
return (LRESULT)g_hBkBrush; } break;
...
|
| Sign In·View Thread·PermaLink | 1.75/5 (4 votes) |
|
|
|
 |
|
 |
Dic wrote: You can have only one brush with background image
No. Keep track of which control a particular WM_CTLCOLORSTATIC belongs to and asssociate separate brushes for each control if you have a bg image you want show hrough the control.
-- Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. (Douglas Adams)
|
| Sign In·View Thread·PermaLink | 2.75/5 (4 votes) |
|
|
|
 |
|
|
General
News
Question
Answer
Joke
Rant
Admin