1 Attachment(s)
Scroll Multiline Edit Box overwrites text within???
Boy, I've never seen this before... and it only happens on one EditBox within this application. At this point, I am at a loss as to what is going on.
We have an "error" reporting feature. It contains a MultiLine EditBox that has a CString variable assigned to it via the ClassWizard.
The variable is initialized as follows:
Code:
CErrDlg dlg;
dlg.m_sError=sThisError;
dlg.DoModal();
sThisError is a CString variable as well that is loaded elsewhere with the actual error and debugging information.
When the dialog opens, it looks fine... can read the scrollable box, no problem. BUT, when you start scrolling it (with a mouse, with the scrollbar, with whatever)... as the text in the box starts overwriting what is there... making it unreadable. (see attached picture)
If you "highlight" the screwed up text in the box and drag through it, miraculously it becomes readable.
If you minimize the application or open another application over it... when you go back to it, you can read it as well.
At this point, I am at a total loss... I've never seen anything like this.
Suggestions...
Re: Scroll Multiline Edit Box overwrites text within???
Could you show the CErrDlg declaration and implementation files?
Don't forget to use Code tags aground code snippets.
Re: Scroll Multiline Edit Box overwrites text within???
I believe this is what you are looking for....
Code:
class CErrDlg : public CDialog
{
// Construction
public:
CErrDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CErrDlg)
enum { IDD = IDD_ERR };
CString m_sError;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CErrDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CErrDlg)
virtual BOOL OnInitDialog();
afx_msg void OnBtnfaq();
afx_msg void OnBtnforum();
afx_msg void OnBtnwebsite();
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
As for implementation... that was in the code example of the original post.
Hope that helps....
Re: Scroll Multiline Edit Box overwrites text within???
Quote:
Originally Posted by
pbrama
As for implementation... that was in the code example of the original post.
Hope that helps....
No, there was no any CErrDlg implementation code (it's what you usually have in correspondent .cpp file) in your OP.
Re: Scroll Multiline Edit Box overwrites text within???
Whoops... sorry.... try this....
Code:
// ErrDlg.cpp : implementation file
//
#include "stdafx.h"
#include "skybot.h"
#include "ErrDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CErrDlg dialog
CErrDlg::CErrDlg(CWnd* pParent /*=NULL*/)
: CDialog(CErrDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CErrDlg)
m_sError = _T("");
//}}AFX_DATA_INIT
}
void CErrDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CErrDlg)
DDX_Text(pDX, IDC_ERROR, m_sError);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CErrDlg, CDialog)
//{{AFX_MSG_MAP(CErrDlg)
ON_BN_CLICKED(IDC_BTNFAQ, OnBtnfaq)
ON_BN_CLICKED(IDC_BTNFORUM, OnBtnforum)
ON_BN_CLICKED(IDC_BTNWEBSITE, OnBtnwebsite)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CErrDlg message handlers
BOOL CErrDlg::OnInitDialog()
{
int iPos1,iPos2;
CDialog::OnInitDialog();
// Remove any specific library data for anonymity
iPos1=m_sError.Find("LibraryLogReport");
if (iPos1>=0)
{
iPos2=m_sError.Find("Language",iPos1);
if (iPos2>=0)
{
iPos2=m_sError.Find("\r\n",iPos2);
if (iPos2>=0)
{
m_sError.Delete(iPos1,iPos2-iPos1);
UpdateData(false);
}
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CErrDlg::OnBtnfaq()
{
HINSTANCE hInst = ShellExecute(NULL, "open", "http://www.ourwebsite.com/faqs.htm", NULL, NULL, SW_SHOWNORMAL);
}
void CErrDlg::OnBtnforum()
{
HINSTANCE hInst = ShellExecute(NULL, "open", "http://forum.ourwebsite.com", NULL, NULL, SW_SHOWNORMAL);
}
void CErrDlg::OnBtnwebsite()
{
HINSTANCE hInst = ShellExecute(NULL, "open", "http://www.ourwebsite.com", NULL, NULL, SW_SHOWNORMAL);
}
void CErrDlg::OnClose()
{
// Close Dialog
CDialog::OnOK();
}
Let me know if you need anything else.
Re: Scroll Multiline Edit Box overwrites text within???
So does anyone have any ideas on this?
Re: Scroll Multiline Edit Box overwrites text within???
I had this same issue only with a RichEdit control.
You could try making a control variable to the edit box and use ::ReplaceSel with the second parameter as 0.
m_EditControl.ReplaceSel(sThisError,0);
UpdateWindow();
This worked for me in the RichEdit control.
Re: Scroll Multiline Edit Box overwrites text within???
Can you show the properties (windows styles) of the edit box? Open the resource editor (IDD_ERR) and look at the properties of the edit box.
You open the error dialog without a parent window. That is legal, but sometimes not the best choice. E.g. your error message can be hidden behind your application. But I guess that's not the reason for your problem.
Does your main app change the behaviour of this dialog in a miracolous way? E.g. is there a call to LockWindowUpdate? Are you hooking some messages? Does the behaviour occur on different systems/computers? Which system is it? Version?