我建了一个ATL项目,主窗口是一个复合控件,现在在里面用一个botton点击创建一个窗口,用CAxDialogImpl::Create(),第一个参数是个句柄,是指要创建的窗口的还是主窗口的啊?请问怎么获得这个句柄?

解决方案 »

  1.   

    Parameters
    hWndParent 
    [in] The handle to the owner window.是父窗口的handle
      

  2.   

    哦,谢谢,现在我的程序改到父窗口了,
             CPaintDC dc();
             CFont newFont;
    CPen NewPen;
    dc.MoveTo(20,20);//从这行开始出同一个错误
    dc.LineTo(20,240);
    dc.LineTo(240,240);
    dc.Rectangle(40,mem1,60,240);
    dc.Rectangle(80,mem2,100,240);
    dc.Rectangle(120,mem3,140,240);
    dc.Rectangle(160,mem4,180,240);
    dc.TextOut(19,19,"%");
    dc.TextOut(241,241,"num");
    这是我的画图程序,编译报错:left of '.MoveTo' must have class/struct/union type
    是指什么?没有初始化吗?请问应该怎样改?
      

  3.   

    CPaintDC dc(this) ; 没有出现错误啊~~~
      

  4.   

    我用this的时候就会抱错
    error C2664: 'CPaintDC::CPaintDC' : cannot convert parameter 1 from 'class Cinface *const ' to 'class CWnd *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
      

  5.   

    void CMYSoftRecordCtrl::OnDraw(
    CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)楼主就用CDC* pdc来画图试试我测试过这样没问题:void CTestCtrl::OnDraw(
    CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
    {
    // TODO: Replace the following code with your own drawing code.

            HBRUSH hBakBrush=CreateSolidBrush(RGB(0x00,0x66,0xcc));
    pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)hBakBrush));
    // pdc->Ellipse(rcBounds);
    pdc->SetBkColor(RGB(0x00,0x66,0xcc));
    pdc->SetTextColor(RGB(255,255,255));
    pdc->TextOut(20,20,"Test ActiveX");
    DeleteObject(hBakBrush);
    }
      

  6.   

    请问楼上大哥是在composite control控件上画的吗?
      

  7.   

    这个只是在创建的默认的public COleControl 控件上画 如果你要画出你自己的子控件 可以在OnCreate()中画出来这个是OnDraw()参数的意义:
    virtual void OnDraw(
       CDC* pDC,
       const CRect& rcBounds,
       const CRect& rcInvalid 
    );
    Parameters
    pDC 
    The device context in which the drawing occurs. 
    rcBounds 
    The rectangular area of the control, including the border. 
    rcInvalid 
    The rectangular area of the control that is invalid. 
      

  8.   

    use BeginPaint or do anything in OnPaint with ATL_DRAWINFO
      

  9.   

    我的ATL工程怎么没有默认的控件啊?要自己加入public COleControl
      

  10.   

    Search atlfire.sln in MSDN,
    The sample uses BeginPaint function