编译没有error,运行“内存不足”,调试运行到AddPage就提示“内存不足”。哥们,告诉我原因吧,怎么修改?
BOOL CEastRDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About... " menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu-> AppendMenu(MF_SEPARATOR);
pSysMenu-> AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application 's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
//加入标签,标签名由各个子对话框的标题栏决定
m_sheet.AddPage(&m_page1);//到这就“内存不足”
m_sheet.AddPage(&m_page2);
m_sheet.AddPage (&m_page1);
//用Create来创建一个属性页
m_sheet.Create(this, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT);
RECT rect;
m_sheet.GetWindowRect(&rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
//调整属性页的大小和位置
m_sheet.SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
m_List.InsertColumn (0, "机号 ",LVCFMT_CENTER,50);
m_List.InsertColumn (1, "波特率 ",LVCFMT_CENTER,60);
m_List.InsertColumn (2, "端口号 ",LVCFMT_CENTER,60);
m_List.InsertColumn (3, "机型 ",LVCFMT_CENTER,50);
DWORD dwStyle = GetWindowLong(m_List.GetSafeHwnd(),GWL_STYLE);
dwStyle &= ~LVS_TYPEMASK;
dwStyle |= LVS_REPORT;
SetWindowLong(m_List.GetSafeHwnd(),GWL_STYLE,dwStyle);
SetRedraw(TRUE);
Invalidate();
m_List.SetExtendedStyle(LVS_EX_CHECKBOXES);
m_List.SetCheck(0,true);
return TRUE; // return TRUE unless you set the focus to a control
}
------解决方案--------------------------------------------------------
加内存? 增加页面文件大小?
说实话我没有仔细看你代码.