各位大侠:
小弟初学VC++,这几天在试编一个程序时,碰到了困难,请大侠们指点.
我想编的程序是一个控件,能跟据父窗口大小自动改变大小,这里我用一按钮做实验.
在主窗口的On_Size中加入代码.
void CTryDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
m_Button.SetWindowPos(NULL,0,0,cx,cy,SWP_NOZORDER );
// m_Button.MoveWindow(0,0,cx,cy); 这种方式我也试了.
//以下方式我也试了:
//CButton *myButton=(CButton*)GetDlgItem(IDC_BUTTON1);
//myButton->SetWindowRgn(
}
编译后没有仍何的错误和警告,但一到运行时就会出如下错误:
+++++++++++++++++++++++++++++++++++++++++++++++++++++
Debug Assertion Failed!Program: D:\VC++\Learn\try\Debug\try.exe
File:winocc.cpp
Line:279For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
如果点"忽略"程序也可以正常运行,但是始终不好.请问各位大侠,为什么会出现这种情况,该怎样改?
小弟初学VC++,这几天在试编一个程序时,碰到了困难,请大侠们指点.
我想编的程序是一个控件,能跟据父窗口大小自动改变大小,这里我用一按钮做实验.
在主窗口的On_Size中加入代码.
void CTryDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
m_Button.SetWindowPos(NULL,0,0,cx,cy,SWP_NOZORDER );
// m_Button.MoveWindow(0,0,cx,cy); 这种方式我也试了.
//以下方式我也试了:
//CButton *myButton=(CButton*)GetDlgItem(IDC_BUTTON1);
//myButton->SetWindowRgn(
}
编译后没有仍何的错误和警告,但一到运行时就会出如下错误:
+++++++++++++++++++++++++++++++++++++++++++++++++++++
Debug Assertion Failed!Program: D:\VC++\Learn\try\Debug\try.exe
File:winocc.cpp
Line:279For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
如果点"忽略"程序也可以正常运行,但是始终不好.请问各位大侠,为什么会出现这种情况,该怎样改?
{
m_Button.SetWindowPos(NULL,0,0,cx,cy,SWP_NOZORDER );
}
{
CRect rect;
m_cTip.GetWindowRect(&rect);
this->ScreenToClient( &rect );
m_cTip.MoveWindow( rect.left, cy - 30, rect.Width(), rect.Height());
}在按钮生成以后再放大。
关于(::IsWindow(m_Button.hWnd))中的m_Button的hWnd如果我是用.Detach()来获得的话,编译不会报错,但运行时一拉动父窗体,程序就出错,必须用m_hWnd才行,为什么?
谢谢谢!!!!!答案出来后我会新发贴给分的,再次谢谢!