Hi all,
I'm developing an MFC application. I create a new window in my main window
with the following code:
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
m_pTerm = new CTermWnd();
m_pTerm->Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
CRect(CPoint(0, 0), CSize(200, 200)), this, ID_TERMSCREEN);
return 0;
}
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
class CTermWnd : public CWnd
{
public:
CTermWnd();
virtual ~CTermWnd();
protected:
//{{AFX_MSG(CTermWnd)
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CWnd* m_pTerm;
static CBrush ms_bkgndBrush;
public:
HWND m_hTermWnd;
};
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
CBrush CTermWnd::ms_bkgndBrush;
CTermWnd::CTermWnd()
{
strTermClass = AfxRegisterWndClass(NULL, NULL,
(HBRUSH) ::GetStockObject(LTGRAY_BRUSH), NULL);
}
CTermWnd::~CTermWnd()
{
}
BEGIN_MESSAGE_MAP(CTermWnd,CWnd )
//{{AFX_MSG_MAP(CTermWnd)
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////////////////
/
// CTermWnd message handlers
void CTermWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
}
BOOL CTermWnd::OnEraseBkgnd(CDC* pDC)
{
CRect rc;
GetClientRect(&rc);
pDC->FillSolidRect(&rc, RGB(192,192,192));
return TRUE; // Erased
}
int CTermWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
/* Most of OnCreate code is useless since I can't pass the GCL_HBRBACKGROUND
parameter to SetClassLong*/
CDC *pDC = this->GetWindowDC();
//ms_bkgndBrush.CreateSolidBrush(LTGRAY_BRUSH);
ms_bkgndBrush.CreateSolidBrush(RGB(192, 192, 192));
DWORD style = ::GetClassLong(m_hWnd, GCL_STYLE);
//::SetClassLong(m_hWnd, pDC->SetBkColor(RGB(192, 192, 192)), (LONG)
(HBRUSH) ms_bkgndBrush);
::SetClassLong(m_hWnd, GCL_STYLE, (LONG) (HBRUSH) ms_bkgndBrush);
DWORD errno = GetLastError();
UpdateWindow();
return 0;
}
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
I also used AfxRegisterWndClass to create the child window with the
following code, but that , too, stopped at the debugbreak() function:
int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
CString strTermClass;
strTermClass = AfxRegisterWndClass(NULL, NULL,
(HBRUSH) ::GetStockObject(LTGRAY_BRUSH), NULL);
m_pTerm = new CWnd();
m_pTerm->Create(strTermClass, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
CRect(CPoint(0, 0), CSize(200, 200)), this, ID_TERMSCREEN);
return 0;
}
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
Whenever I start my application I get the following debug message:
4294813649 PID:a1ef5b5a TID:e1e68756 0x81e4b000: Unknown: DEBUGCHK failed in
file d:\jameson\private\winceos\coreos\gwe\controls\imgctl\.\imagelist.cpp
at line 905
and the code jumps to kfuncs.h, line 102 where it calls "debugbreak();"
#elif defined(x86)
_inline void DebugBreak() {
__asm int 3
}
I checked my pc and I don't have any imagelist file, but I have a imgctl lib
file and checking that (as much as it's possible to check!) I somehow
figured out that these lines are in the lib file, which might be related
with my problem:
"application passed invalid ILC_color flags to imagelist_create imagelist
out of near memory imagelist can't create bitmap imagelist unable to
initialize APPLICATION ERROR exited with Imagelist not destroyed"
If I press F5 I can continue to debug and the application initializes as if
nothing has happened. I don't get these messages when I open / close dialog
windows in my application. I get it only at the initialization stage. Also I
don't get any error messages while working with eVC on the standard SDK
Emulator. Since I don't know why this error comes, I can't handle it with
any kind of exception handling procedure.
My aim is to create a window in the view area and to display the characters
I receive from the serial com port in this window. Could you tell me what is
wrong with my code?
Thank you very much already.
Selin