Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dialog box with white background

Posted on 1999-07-17
23
Medium Priority
?
403 Views
Last Modified: 2013-12-03
I am building an interface by window programming in C. I have created a dialog box. But the background of the dialog box is white. I want the background to be light gray. So do the background of the others component on the dialog box (radio buttons, track bars etc). What should I do?
0
Comment
Question by:jessicalim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 10
23 Comments
 
LVL 6

Accepted Solution

by:
WxW earned 60 total points
ID: 1403161
You process WM_CTLCOLORDLG and return a HBRUSH with the color you want to paint the dialog .
0
 

Author Comment

by:jessicalim
ID: 1403162
WxW,
It's works. How am I want to change the background color of the others components in the dialog box? The background color of the components are still white?
0
 
LVL 6

Expert Comment

by:WxW
ID: 1403163
You can process all WM_CTLCOLOR*** messages : WM_CTLCOLORDLG , WM_CTLCOLOREDIT , WM_CTLCOLORLISTBOX , WM_CTLCOLORMSGBOX , WM_CTLCOLORSCROLLBAR and WM_CTLCOLORSTATIC .
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:jessicalim
ID: 1403164
I tried to use the WM_CTLCOLORBTN to change the radio button's background. But the description of the radio button didn't change.
0
 
LVL 6

Expert Comment

by:WxW
ID: 1403165
What do you mean "description"
0
 

Author Comment

by:jessicalim
ID: 1403166
I create radio buttons. The description I meant is the word at the right side of  the radio button that descripe the radio button like rotation, alpha, red... etc.

The background of the sliders that I have been created are also white.

Please help me.
0
 
LVL 6

Expert Comment

by:WxW
ID: 1403167
I don't think that the WM_CTL messages can change all background colors . Try processing WM_ERASEBACKGROUND for the dialog, and/or try using owner draw radio button .
0
 

Author Comment

by:jessicalim
ID: 1403168
I create radio buttons. The description I meant is the word at the right side of  the radio button that descripe the radio button like rotation, alpha, red... etc.

The background of the sliders that I have been created are also white.

Please help me.
0
 

Author Comment

by:jessicalim
ID: 1403169
WxW,
Do you have any idea of changing the track bar or slider's background color? The slider is located in the dialog box but I created it by using the CreateWindow(), not in the resource file.
0
 
LVL 6

Expert Comment

by:WxW
ID: 1403170
When do you call CreateWindow() ? In process of WM_INITDIALOG ?
0
 

Author Comment

by:jessicalim
ID: 1403171
Yes. I called the CreateWindow() in the WM_INITDIALOG.
0
 
LVL 6

Expert Comment

by:WxW
ID: 1403172
As I told before , not all controls can be repainted using the WM_CTL** messages . Your chance is to enable WS_OWNERDRAW for the control and while processing WM_DRAWITEM , draw the bacground yourself and let windows do the rest of the drawing .

0
 

Author Comment

by:jessicalim
ID: 1403173
WxW,
There is no WS_OWNERDRAW in window style.
0
 
LVL 6

Expert Comment

by:WxW
ID: 1403174
You can check the resource editor if it has an "owner draw" option for a control . If it doesn't ( and the track bar hasn't ) , your only chance is to create your own control , OR subclass the trackball and process the drawing messages it receives .

Its a tough work , I suggest you create a simple static control and use HDC functions to draw a status bar like I did .
0
 

Author Comment

by:jessicalim
ID: 1403175
I don't understand what do you mean by creating a static control n use the HDC. I want to change the track bar (slider)'s background from white to light gray, can I use that method also?

Where can I find the resource editor? What do you mean by resource editor actually?

If I want to create my own control, I use the CreateWindow(), right?

How do I want to subclass the track bar n process the drawing messages?



0
 
LVL 6

Expert Comment

by:WxW
ID: 1403176
The resource editor is the tool that you create the dialog box with .
To subclass the track bar you must use SetWindowLong with a new class procedure . Its not very easy , but I think its the only way for you to change the colors since the track bar does not accept WM_CTL*** messages .
0
 

Author Comment

by:jessicalim
ID: 1403177
I didn't create the dialog box with any resource editor. I created it by myself in the resource file.
0
 

Author Comment

by:jessicalim
ID: 1403178
WxW,
After I used the SetWindowLong with a new WndProc for the trackbar, what kind of WM... command should I use to change the trackbar's background color?
0
 

Author Comment

by:jessicalim
ID: 1403179
WxW,
After I ran the program, I couldn't see the trackbar. The trackbar is not visible. But when I click on the area of the trackbar, there is reaction of the trackbar.

How do I want to solve this problem?
0
 
LVL 6

Expert Comment

by:WxW
ID: 1403180
You subclassed ?
ITs WM_NC** messages .
However I still suggest you use HDC functions instead of common controls . Get the HDC of the dialog using GetDC() and start painting .
0
 

Author Comment

by:jessicalim
ID: 1403181
In the subclass, I used the WM_NCPAINT. But there is still no any changing of the background color.

case WM_NCPAINT:
hTBDC= GetDC(hTrackWnd1);
//SetBkColor(hTBDC, RGB(192,192,192));
//SetBkMode(hTBDC, TRANSPARENT);
hbrush = GetStockObject(LTGRAY_BRUSH);
//DeleteObject(hbrush);
return (LRESULT) hbrush;

What's wrong with the source code?
Now, the trackbar is visible.

0
 
LVL 6

Expert Comment

by:WxW
ID: 1403182
I am afraid that the common control won't allow you to change its bg .
0
 

Author Comment

by:jessicalim
ID: 1403183
WxW,
I tried it many times already. The background color still be changed to light gray. I think you are right, the common control won't let change the background color.

Is somebody else can help me?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question