15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Problem with readonly CEdit on bitmapped Dialog

Greg Powers -- pow@cruzio.com
Tuesday, January 28, 1997

Environment: Win95, VC++ 4.2b

I'm having a problem with edit boxes which are set "read only"
(ES_READONLY) when they are placed on a dialog with a bitmap background.
The edit box contents do not seem to get erased properly when I either
replace the text, or even just erase, resulting in a real garbled mess
when new contents are written into the control.

This is behavior is happening whether I use member variables and DDX, or
SetDlgItemText(). 

(I guess a hint is that edit boxes marked read only don't ever get their
background colored; that is, they retain the background bitmap coloring.
Only trouble is, I don't know what to make of this hint...)


The OnCtlColor() code used to color edit box text backgrounds: 

        case CTLCOLOR_EDIT      :
                CDialog::OnCtlColor (pDC, pWnd, nCtlColor);
                pDC->SetBkMode (OPAQUE);
                pDC->SetBkColor (RGB (some value));
                return CFillBrush();
                break;

where CFillBrush() returns an (HBRUSH) of (for now) the same (RGB (some
value)). FillBrush() does use a CBrush member variable, initialized just
once, and yes it returns an HBRUSH). The code works great for all CEdit
controls not in possession of the ES_READONLY attribute. It just doesn't
like these readonly CEdits... and it also works fine if I don't paint a
bitmap on the dialog background.

Any help greatly appreciated.

Greg
-- 


<<<< Greg Powers, pow@cruzio.com, Entriade Systems >>>>



Jim Lawson Williams -- jimlw@mail.ccur.com.au
Friday, January 31, 1997

G'day!
This may give you an idea:

void CMyDialog::ForceRepaint()
{
	CWnd* pWnd = GetDlgItem(IDC_READONLY_EDIT);
	pWnd->GetClientRect(&rect);
	InvalidateRect(&rect);
}

Regards,
Jim LW


At 02:50 PM 28/01/97 -0800, Greg Powers  wrote:
>Environment: Win95, VC++ 4.2b
>
>I'm having a problem with edit boxes which are set "read only"
>(ES_READONLY) when they are placed on a dialog with a bitmap background.
>The edit box contents do not seem to get erased properly when I either
>replace the text, or even just erase, resulting in a real garbled mess
>when new contents are written into the control.
>
>This is behavior is happening whether I use member variables and DDX, or
>SetDlgItemText(). 
>
>(I guess a hint is that edit boxes marked read only don't ever get their
>background colored; that is, they retain the background bitmap coloring.
>Only trouble is, I don't know what to make of this hint...)
>
>
>The OnCtlColor() code used to color edit box text backgrounds: 
>
>        case CTLCOLOR_EDIT      :
>                CDialog::OnCtlColor (pDC, pWnd, nCtlColor);
>                pDC->SetBkMode (OPAQUE);
>                pDC->SetBkColor (RGB (some value));
>                return CFillBrush();
>                break;
>
>where CFillBrush() returns an (HBRUSH) of (for now) the same (RGB (some
>value)). FillBrush() does use a CBrush member variable, initialized just
>once, and yes it returns an HBRUSH). The code works great for all CEdit
>controls not in possession of the ES_READONLY attribute. It just doesn't
>like these readonly CEdits... and it also works fine if I don't paint a
>bitmap on the dialog background.
>
>Any help greatly appreciated.
>
>Greg
>-- 
>
>
><<<< Greg Powers, pow@cruzio.com, Entriade Systems >>>>
>


>From the BBC's "Barchester Chronicles":

    "I know that ultimately we are not supposed to understand.
    But I also know that we must try."

       -- the Reverend Septimus Harding, crypt-analyst, clog-dancer, C++ programmer



George Pavlou -- georgep@MPGN.COM
Tuesday, February 04, 1997

A read only edit box behaves like a static text with client edge. The only
difference between these two is that the edit box can get focused.

You get that mess because you have the static texts transparent to the
background. The background bitmap makes the mess, but it's not the problem 

You could just replace the read only edit box with a static text or (if you
need it to get focused) you need to have a special case in OnCtrlColor in
the case of CTLCOLOR_STATIC something like:

case CTLCOLOR_STATIC:
	if (pWnd->m_hWnd != GetDlgItem(IDC_READONLY_EDIT)->m_hWnd) {
		//Your code for Static texts here
		break;
	}
case CTLCOLOR_EDIT:
	//Your code here
	...

if you want the read only edit box to look like a normal edit box.

George

George Pavlou                    georgep@tansoft.com         
PC Software Specialist        www.mpgn.com
Tantalus, Inc                       Key West, FL


----------
> From: Greg Powers 
> To: MFC Mailing List 
> Subject: Problem with readonly CEdit on bitmapped Dialog
> Date: Tuesday, January 28, 1997 5:50 PM
> 
> Environment: Win95, VC++ 4.2b
> 
> I'm having a problem with edit boxes which are set "read only"
> (ES_READONLY) when they are placed on a dialog with a bitmap background.
> The edit box contents do not seem to get erased properly when I either
> replace the text, or even just erase, resulting in a real garbled mess
> when new contents are written into the control.
> 
> This is behavior is happening whether I use member variables and DDX, or
> SetDlgItemText(). 
> 
> (I guess a hint is that edit boxes marked read only don't ever get their
> background colored; that is, they retain the background bitmap coloring.
> Only trouble is, I don't know what to make of this hint...)
> 
> 
> The OnCtlColor() code used to color edit box text backgrounds: 
> 
>         case CTLCOLOR_EDIT      :
>                 CDialog::OnCtlColor (pDC, pWnd, nCtlColor);
>                 pDC->SetBkMode (OPAQUE);
>                 pDC->SetBkColor (RGB (some value));
>                 return CFillBrush();
>                 break;
> 
> where CFillBrush() returns an (HBRUSH) of (for now) the same (RGB (some
> value)). FillBrush() does use a CBrush member variable, initialized just
> once, and yes it returns an HBRUSH). The code works great for all CEdit
> controls not in possession of the ES_READONLY attribute. It just doesn't
> like these readonly CEdits... and it also works fine if I don't paint a
> bitmap on the dialog background.
> 
> Any help greatly appreciated.
> 
> Greg
> -- 
> 
> 
> <<<< Greg Powers, pow@cruzio.com, Entriade Systems >>>>




| Вернуться в корень Архива |