当前位置:编程学习 > C#/ASP.NET >>

大伙帮我看看这是什么问题,有关于CWND继承类的问题。

我定义了一个控件从CWND继承下来,
CMyCtrl:public cwnd
{
BOOL RegisterWindowClass()
{
    WNDCLASS wndcls;
    HINSTANCE hInst = AfxGetInstanceHandle(); 

    if (!(::GetClassInfo(hInst, DRAWWND_CLASS, &wndcls)))
    {
        // otherwise we need to register a new class
        wndcls.style            = CS_DBLCLKS | CS_HREDRAW |CS_VREDRAW;
        wndcls.lpfnWndProc      = ::DefWindowProc;
        wndcls.cbClsExtra       = wndcls.cbWndExtra = 0;
        wndcls.hInstance        = hInst;
        wndcls.hIcon            = NULL;
        wndcls.hCursor          = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
        wndcls.hbrBackground    = (HBRUSH) (COLOR_3DFACE + 1);
        wndcls.lpszMenuName     = NULL;
        wndcls.lpszClassName    = DRAWWND_CLASS;

        if (!AfxRegisterClass(&wndcls)) {
            AfxThrowResourceException();
            return FALSE;
        }
    }

    return TRUE;
}

BOOL Create(const RECT& rect, CWnd* parent, UINT nID,
                DWORD dwStyle = WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VISIBLE)
{
    RegisterWindowClass()
    ASSERT(pParentWnd->GetSafeHwnd());
    
    if (!CWnd::Create(DRAWWND_CLASS, NULL, dwStyle, rect, pParentWnd, nID)) 
        return FALSE;

m_nID = nID;
}
}

我在DIALOG上这样用这个控件
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO:  Add extra initialization here

m_pMyCtrl= new CMyCtrl;
if (m_pMyCtrl== NULL)
return FALSE;

CRect rc(40,60 , 800,600);
m_pMyCtrl->Create(rc , this , IDC_STATIC_DRAW1 );

return TRUE;  // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

控件可以正常在窗口显示出来,但是窗口上无法在显示模式对话框了,比如AfxMessageBox()显示不出来,调用后窗口无响应了。
请问这是什么问题? --------------------编程问答-------------------- 你在那里 怎么调用的模态对话框? 应该跟你自己写的这个窗体没有多大关系吧 --------------------编程问答-------------------- 模式对话框怎么调用的,消息阻塞了.. --------------------编程问答-------------------- 支持下啊我来也 --------------------编程问答--------------------  RegisterWindowClass貌似写得不对啊,而且你没用doModal,怎么会显示个对话框出来呢?
补充:.NET技术 ,  VC.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,