YaelS

Hi,

I'm tring to set Resize able to mt dialog, but if I drag the border I get runtime error:

Unhandled exception at 0x0040a91e in QmAgent.exe: 0xC0000005: Access violation reading location 0x0000001c.

afxwin2.inl - (here it's break)

_AFXWIN_INLINE void CWnd::GetWindowRect(LPRECT lpRect) const

{ ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }

I don't know why It's happend !

Thank's




Re: Visual C++ General About dialog Resizing properties border

Bite Qiu - MSFT

Try debug into it, and make sure all pointers or handles are properly initialized with valid values.




Re: Visual C++ General About dialog Resizing properties border

YaelS

Thank's,

I get:

+ m_hWnd CXX0017: Error: symbol "" not found HWND__ *

How to inisialize m_hWnd heandel






Re: Visual C++ General About dialog Resizing properties border

Bite Qiu - MSFT

Could you provide more context of the problematical code Preferablely all code that will be executed when draging border.




Re: Visual C++ General About dialog Resizing properties border

YaelS

in afxwin2.inl file:

Code Snippet

_AFXWIN_INLINE UINT CWnd::ArrangeIconicWindows()

{ ASSERT(::IsWindow(m_hWnd)); return ::ArrangeIconicWindows(m_hWnd); }

_AFXWIN_INLINE int CWnd::SetWindowRgn(HRGN hRgn, BOOL bRedraw)

{ ASSERT(::IsWindow(m_hWnd)); return ::SetWindowRgn(m_hWnd, hRgn, bRedraw); }

_AFXWIN_INLINE int CWnd::GetWindowRgn(HRGN hRgn) const

{ ASSERT(::IsWindow(m_hWnd) && hRgn != NULL); return ::GetWindowRgn(m_hWnd, hRgn); }

_AFXWIN_INLINE void CWnd::BringWindowToTop()

{ ASSERT(::IsWindow(m_hWnd)); ::BringWindowToTop(m_hWnd); }

_AFXWIN_INLINE void CWnd::GetWindowRect(LPRECT lpRect) const

{ ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }

I think my problem is that it's win32 project and I add to the code MtDialog dlg, dlg.DoModel()

MtDialog is CDialog..wrote in mfc.






Re: Visual C++ General About dialog Resizing properties border

Bite Qiu - MSFT

Sorry that I didn't explain it clearly, I mean your code not the code in afxwin2.inl, this is where the assertion happens, but the real cause is outside this file, so I need to see the problematical code in your project, not in this file. You can use debugger to find where exactly the assertions happens, and paste out these code with enough context. If the project you have is not very big, you can think about paste them all here.




Re: Visual C++ General About dialog Resizing properties border

YaelS

Sorry to, Ill explain mtself:

If I'm jest resizing the dialog, everything is ok!

My problem is when I resize the controns in my dialog:

I'm using this like this project: http://www.codeproject.com/dialog/easysize.asp

I think is about the mapping...I found my problem. :ES_HCENTER

So I'm OK!!!

EASYSIZE(IDC_STATIC3,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,ES_BORDER,ES_HCENTER)

this is my code:

in stdafx.h I add

#include "easysize.h"

Code Snippet

class CListViewDlg : public CDialog

{

DECLARE_EASYSIZE

// Construction

public:

CListViewDlg(CWnd* pParent = NULL); // standard constructor

///...

}

Code Snippet

// ListViewDlg.cpp : implementation file

// the dialog implementation

#include "stdafx.h"

#include "ListViewDlg.h"

#include ".\listviewdlg.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CListViewDlg dialog

CListViewDlg::CListViewDlg(CWnd* pParent /*=NULL*/)

: CDialog(CListViewDlg::IDD, pParent)

{

//{{AFX_DATA_INIT(CListViewDlg)

// NOTE: the ClassWizard will add member initialization here

//}}AFX_DATA_INIT

matarotIcon = AfxGetApp()->LoadIcon(IDI_SMALL);

}

void

CListViewDlg::DoDataExchange (CDataExchange* pDX)

{

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CListViewDlg)

// NOTE: the ClassWizard will add DDX and DDV calls here

DDX_Control(pDX, IDC_LIST1, taskList);

DDX_Control(pDX, IDC_LIST2, msgList);

DDX_Control(pDX, IDC_COMBO1, timeCombo);

DDX_Control(pDX, IDC_TAB1, tabList);

//}}AFX_DATA_MAP

} // DoDataExchange

BEGIN_MESSAGE_MAP(CListViewDlg, CDialog)

//{{AFX_MSG_MAP(CListViewDlg)

ON_WM_DESTROY()

//}}AFX_MSG_MAP

ON_WM_CTLCOLOR()

ON_WM_QUERYDRAGICON()

ON_WM_PAINT()

ON_WM_MOUSEMOVE()

ON_WM_SIZING()

ON_WM_SIZE()

END_MESSAGE_MAP()

//EASYSIZE(control,left,top,right,bottom,options)

BEGIN_EASYSIZE_MAP(CListViewDlg)

EASYSIZE(IDOK,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,ES_BORDER,0)

EASYSIZE(IDOK2,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,ES_BORDER,0)

EASYSIZE(IDC_BUTTON1,ES_KEEPSIZE,ES_BORDER,ES_BORDER,ES_BORDER,0)

EASYSIZE(IDC_BUTTON2,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,ES_BORDER,0)

EASYSIZE(IDC_BUTTON3,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,ES_BORDER,0)

EASYSIZE(IDC_STATIC3,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,ES_BORDER,ES_HCENTER)

EASYSIZE(IDC_COMBO1,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,ES_BORDER,0)

EASYSIZE(IDC_LIST1,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)

EASYSIZE(IDC_LIST2,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)

EASYSIZE(IDC_TAB1,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,ES_BORDER,0)

END_EASYSIZE_MAP

/////////////////////////////////////////////////////////////////////////////

// CListViewDlg message handlers

BOOL

CListViewDlg::OnInitDialog()

{

CDialog::OnInitDialog();

if(this->appIsOpen)

{

GetDlgItem(IDC_STATIC3)->SetWindowText("");

GetDlgItem(IDCANCEL)->SetWindowText("OK");

GetDlgItem(IDOK)->ShowWindow(FALSE);

GetDlgItem(IDCANCEL)->MoveWindow(120,260,80,25); //x,y,w,h

}

else

{

GetDlgItem(IDCANCEL)->SetWindowText("Cancel");

GetDlgItem(IDOK)->ShowWindow(TRUE);

GetDlgItem(IDCANCEL)->MoveWindow(180,260,80,25);

GetDlgItem(IDOK)->MoveWindow(50,260,80,25);

}

initList ();

initTab();

INIT_EASYSIZE; // Here it's break!!!

return TRUE;

}

void

CListViewDlg::initTab()

{

// set tabs items

tabList.InsertItem(0, _T("TAB1");

tabList.InsertItem(1, _T("TAB2));

}

void

CListViewDlg::initList()

{

// set lists column headers

taskList.InsertColumn(0, "Col1",LVCFMT_CENTER, 70);

taskList.InsertColumn(1, "Col2",LVCFMT_CENTER, 280);

msgList.InsertColumn(0, "Col1",LVCFMT_CENTER, 70);

msgList.InsertColumn(1, "Col2",LVCFMT_CENTER, 40);

msgList.InsertColumn(2, "Col3",LVCFMT_CENTER, 280);

msgList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_SHOWSELALWAYS);

taskList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);

}

void

CListViewDlg::OnDestroy ()

{

CDialog::OnDestroy();

} // OnDestroy

void CListViewDlg::OnSizing(UINT fwSide, LPRECT pRect)

{

CDialog::OnSizing(fwSide, pRect);

CDialog::OnSizing(fwSide, pRect);

EASYSIZE_MINSIZE(280,250,fwSide,pRect);

// TODO: Add your message handler code here

}

void CListViewDlg::OnSize(UINT nType, int cx, int cy)

{

CDialog::OnSize(nType, cx, cy);

UPDATE_EASYSIZE;

// TODO: Add your message handler code here

}