15,978
社区成员
发帖
与我相关
我的任务
分享
BOOL CProgramDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect clientRect;
GetClientRect(&clientRect);
CView* pNewView;
pNewView = new CProgramWin;//ProgramWin为编辑区EditView
// Creation of the view window
afxTraceEnabled=FALSE;
if(! pNewView->Create(NULL, NULL, WS_VISIBLE | WS_CHILD, CRect(clientRect.left,clientRect.top,clientRect.right-180,clientRect.bottom+90), this, 1000))//编辑区的大小
{
TRACE0( "Failed view creation\n" );
}
afxTraceEnabled=TRUE;
pNewView->OnInitialUpdate();
return TRUE; // return TRUE unless you set the focus to a control
}
int CWinProPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: 在此添加您专用的创建代码
CRect rectDummy;
rectDummy.SetRectEmpty();
//创建选项卡窗口:
if (!m_ProDlg.Create(IDD_PROGRAM,this))
{
TRACE0("未能创建输出选项卡窗口/n");
return -1;//未能创建
}
m_ProDlg.ShowWindow(SW_SHOW);
return 0;
}
void CWinProPane::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
// TODO: 在此处添加消息处理程序代码
//选项卡控件应覆盖整个工作区
m_ProDlg.SetWindowPos(this,-1,-1,cx,cy,SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
m_ProDlg.ShowWindow(SW_SHOW);
}
if(pNewView1)
{
CRect rect; //获取控件变化前大小
pNewView1->GetWindowRect(&rect);
ScreenToClient(&rect);//将控件大小转换为在对话框中的区域坐标
// cx/m_rect.Width()为对话框在横向的变化比例
rect.left=rect.left*cx/m_rect.Width();//调整控件大小
rect.right=rect.right*cx/m_rect.Width();
rect.top=rect.top*cy/m_rect.Height();
rect.bottom=rect.bottom*cy/m_rect.Height();
pNewView1->MoveWindow(rect);//设置控件大小
}
GetClientRect(&m_rect);//将变化后的对话框大小设为旧大小
,可以改变大小,但是没有滚动条了,在pNewView->Create函数中添加滚动条样式,程序只显示一行。是不是要自行添加OnVScroll()函数和OnHScroll()函数啊??if(pNewView1)
{
CRect rect; //获取控件变化前大小
pNewView1->GetWindowRect(&rect);
ScreenToClient(&rect);//将控件大小转换为在对话框中的区域坐标
// cx/m_rect.Width()为对话框在横向的变化比例
rect.left=rect.left*cx/m_rect.Width();//调整控件大小
rect.right=rect.right*cx/m_rect.Width();
rect.top=rect.top*cy/m_rect.Height();
rect.bottom=rect.bottom*cy/m_rect.Height();
pNewView1->MoveWindow(rect);//设置控件大小
}
GetClientRect(&m_rect);//将变化后的对话框大小设为旧大小
用这种方法可以改变大小,但是没有滚动轴,是不是要在函数里面加OnVScroll()函数和OnHScroll()函数啊?? CRect rx(10,10,300,200);
TxEdit.Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_AUTOVSCROLL|ES_MULTILINE|WS_BORDER,rx,this,10082);
rx.MoveToY(310);
if(!TxEdView) TxEdView=new CEditView;
TxEdView->Create(NULL,NULL,WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_MULTILINE|WS_BORDER,rx,this,10083);
CEdit TxEdit
CEditView TxEdView*
View类应该使用指针,否则..........................................