Click here to Skip to main content
15,881,881 members
Articles / Mobile Apps

Transparent controls with custom image backgrounds on PocketPC

Rate me:
Please Sign up or sign in to vote.
3.53/5 (15 votes)
15 Aug 2003CPOL1 min read 119K   1.5K   60   10
Transparent Controls with custom image backgrounds on PocketPC

Sample Image - transparent_controls.jpg

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Korea (Republic of) Korea (Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 2 Pin
dadahacker19-Jun-09 18:15
dadahacker19-Jun-09 18:15 
GeneralException when there are many, many objects Pin
acp92329-Mar-06 4:17
acp92329-Mar-06 4:17 
QuestionWhat if you have a dynamic bitmap background ? Pin
ghostve28-Dec-04 3:29
ghostve28-Dec-04 3:29 
AnswerRe: What if you have a dynamic bitmap background ? Pin
Anonymous28-Dec-04 3:59
Anonymous28-Dec-04 3:59 
GeneralThe WM_CTLCOLORSTATIC message handler and comboboxes. Pin
De Nys, FX11-Apr-04 10:47
De Nys, FX11-Apr-04 10:47 
GeneralApply this sample only on the second DlgBox Pin
GuilhemMtp31-Mar-04 5:25
GuilhemMtp31-Mar-04 5:25 
GeneralRe: Apply this sample only on the second DlgBox Pin
Anonymous14-Apr-04 2:33
Anonymous14-Apr-04 2:33 
GeneralRe: Apply this sample only on the second DlgBox Pin
wqter25-Jun-04 0:12
wqter25-Jun-04 0:12 
GeneralYou can have only one brush... Pin
Dic27-Oct-03 3:47
Dic27-Oct-03 3:47 
GeneralRe: You can have only one brush... Pin
Johann Gerell30-Oct-03 23:19
Johann Gerell30-Oct-03 23:19 
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)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.