So far, I've been able to change the default color of the background of
the entire dialog box and modify all text colors. However, modifying
colors for specific boxes and making changes based on values called
from those boxes is a bit challenging for me. If anyone could give me
any tips or ideas on how I might approach this, I would be very
grateful.
Kind regards,
Marcus
>So far, I've been able to change the default color of the background of
>the entire dialog box and modify all text colors.
Presumably you're doing that by handling WM_CTLCOLOR?
>However, modifying
>colors for specific boxes and making changes based on values called
>from those boxes is a bit challenging for me. If anyone could give me
>any tips or ideas on how I might approach this, I would be very
>grateful.
The WM_CTLCOLOR (OnCtlColor) handler is passed a CWnd pointer to the
control so use that and the nCtlColor parameter something like this:
if ( nCtlColor == CTLCOLOR_EDIT )
{
// It's an edit control - get the value
int Val = GetDlgItemInt( pWnd->GetWindowLong( GWL_ID ) )
// Do something with the value
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
You should handle a WM_CTLCOLOR message in dialog box. Editboxes sends this
message to its parent window for painting parameters.
Asko.
HBRUSH CTestAPIDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch (nCtlColor) {
case CTLCOLOR_STATIC:
{
int Val = GetDlgItemText( IDC_BOX1, FALSE, FALSE );
if( Val = '0' )
{
pDC->SetTextColor(RGB(255, 255, 255));
pDC->SetBkColor(RGB(16, 53, 120));
}
////
Unfortunately, this code paints all static control boxes instead of the
particualr box IDC_BOX1. I'm uncertain how to proceed in colorizing
this, or any specific box. I'm sure it's somewhat easy to do, but I
just can't get my head around it. Any suggestions would be very
valuable.
Best regards and many thanks,
Marcus
Thanks agin you guys.
Marcus
The GetDlgItemText does not get any text because you are not passing it
a buffer. The return Val would be the number of bytes copied to the
buffer, which isn't going to mean anything useful here. And then you
attempt to compare the number with a character, which is apples and
oranges. But the comparison is actually an assignment (= vs. ==) which
will always return true.
In other words, you're having a whole lot of trouble with language
basics here. It is much easier to learn the language first, practicing
with simple console programs from a C++ textbook, before diving in to
the intricacies of Windows and MFC.
--
Scott McPhillips [VC++ MVP]
Thanks for the suggestions, but I tend to jump right in... I have
experience with other languages, so syntax I feel I can learn on the
fly.
Best regards,
Marcus