MFC OnSize事件调用时间
来源:互联网 发布:软件研发部门简介 编辑:程序博客网 时间:2024/06/07 09:42
在Ocx控件被加载时,第一次调用OnSize事件实在控件中的各个部件未加载前,此时如果操作控件中的控件会出现控制针异常,需要提前判断。
int CTestCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: 在此添加您专用的创建代码
m_Mgr->WriteLog("1");
m_dlg.Create(IDD_DLG, this);
m_Mgr->WriteLog("2");
return 0;
}
BOOL CTestDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
m_mgr->WriteLog("1.1");
vlcPlayer_ = new VLCWrapper();
vlcPlayer_->SetOutputWindow(this->GetDlgItem(IDC_STATIC_VLC)->m_hWnd);
vlcPlayer_->SetEventHandler(&HandleVLCEvents, this);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CTestDlg::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
// TODO: 在此处添加消息处理程序代码
CString strLog;
strLog.Format("OnSize Change [cx:%d] [cy:%d]",cx,cy);
m_mgr->WriteLog(strLog);
RecalcLayout(cx,cy);
}
void CTestDlg::RecalcLayout(int cx, int cy)
{
if(cx==0 && cy==0)
{
CRect rect;
GetClientRect(&rect);
cx=rect.Width();
cy=rect.Height();
}
CWnd* _pWnd = this->GetDlgItem(IDC_STATIC1);
if(_pWnd != nullptr){
_pWnd->MoveWindow(CRect(1,1,cx-1, cy - 1));
}
}
日志如下:
2017-06-07 22:54:03 {----------------------OCX Init---------------------}
2017-06-07 22:54:03 {1}
2017-06-07 22:54:03 {OnSize Change [cx:467] [cy:359]}
2017-06-07 22:54:03 {1.1}
2017-06-07 22:54:04 {2}
2017-06-07 22:54:04 {OnSize Change [cx:100] [cy:50]}
2017-06-07 22:57:20 {------------------------------UnInit-----------------------}
2017-06-07 22:54:03 {1}
2017-06-07 22:54:03 {OnSize Change [cx:467] [cy:359]}
2017-06-07 22:54:03 {1.1}
2017-06-07 22:54:04 {2}
2017-06-07 22:54:04 {OnSize Change [cx:100] [cy:50]}
2017-06-07 22:57:20 {------------------------------UnInit-----------------------}
阅读全文
0 0
- MFC OnSize事件调用时间
- 注意mfc下oninitdialog()和onsize()的调用顺序
- MFC中OnInitDialog与OnSize函数谁先调用
- mfc onsize() 乱序
- MFC OnShowWindow和OnSize
- MFC Onsize()函数的作用
- OnSize
- OnSize
- MFC 窗口自动填充 消息Onsize()
- MFC自绘窗口的时候,OnSize
- MFC窗口变化消息( OnSize、OnSizing和OnGetMinMaxInfo)
- [MFC]Dialog窗口大小调整控制OnSize/OnSizing
- MFC的OnCreate/OnSize/OnInitDialog哪个先执行?
- MFC窗口变化消息( OnSize、OnSizing和OnGetMinMaxInfo)
- MFC窗口变化消息( OnSize、OnSizing和OnGetMinMaxInfo)
- MFC窗口变化消息( OnSize、OnSizing和OnGetMinMaxInfo)
- MFC窗体消息之尺寸被改变 OnSize()
- 什么时间调用 UpdateData() --MFC函数
- mysql 5.7.17解压缩版本安装过程
- 查找
- 17.06.07数据库与算法学习感悟
- C笔记 文件IO
- LoadRunner基础知识
- MFC OnSize事件调用时间
- [bzoj1070][SCOI2007]修车 费用流
- Soapui安装
- wireshark的使用笔记
- Scrapy爬虫实战
- 【IE hack与浏览器内核】
- 十年寒窗,从高考,到程序员
- 【C++】【LeetCode】26. Remove Duplicates from Sorted Array
- iOS CoreAnimation (六) layer属性:阴影相关,边框、圆角,masksToBounds