| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2402 人关注过本帖
标题:请高手指点一下下面绘制ActiveX控件外观的代码
只看楼主 加入收藏
lansemengxiang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-5-8
收藏
 问题点数:0 回复次数:0 
请高手指点一下下面绘制ActiveX控件外观的代码
绘制控件外观的代码如下:
void CPid4Ctrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
    // TODO: Replace the following code with your own drawing code.
    //pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
    //pdc->Ellipse(rcBounds);
 CRect rectBouds;
GetClientRect(&rectBouds);
int x1, y1,dx,dy;
x1=rectBouds.TopLeft().x;
y1=rectBouds.TopLeft().y;
dx=rectBouds.BottomRight().x-rectBouds.TopLeft().x;
dx=rectBouds.BottomRight().y-rectBouds.TopLeft().y;
pdc->Draw3dRect(x1,y1,dx,dy,RGB(255,255,0),RGB(0,255,255));
CBrush bkBrush(TranslateColor(GetBackColor()));
pdc->SetBkMode(TRANSPARENT);
pdc->FillRect(rectBouds,&bkBrush);
CFont *Poldfont;
poldfont=SelectStockFont(pdc);
pdc->SetTextColor(TranslateColor(GetForeColor()));
//pdc->DrawText("标准位置型PID"/*GetText()*/,CRect(rectBouds),DT_CENTER);
pdc->Textout((rectBouds.right-rectBouds.left )/2-63,rectBouds.top+10,"自适应控制器");
pdc->SelectObject(poldfont);
CRect rect;
CBrush brush(RGB(0,0,0)),brush12(RGB(0,0,255));
rect.left=rectBouds.left+10;
rect.right=rectBouds.right-10;
rect.top=rectBouds.top+100;//1.5*(rectBouds.bottom-rectBouds.top)/6;
rect.bottom =rectBouds.bottom-65;//(rectBouds.bottom -rectBouds.top )/6;
pdc->FillRect(rect,&brush);
pdc->FrameRect(rect,&brush12);
CRect rect0;
CBrush brush0(RGB(0,0,0)),brush120(RGB(0,0,255));
rect0.left=rectBouds.left+10;
rect0.right=rectBouds.right-10;
rect0.top=rectBouds.top+50;//1.5*(rectBouds.bottom-rectBouds.top)/6;
rect0.bottom=rectBouds.top+90;//(rectBouds.bottom-rectBouds.top)/6;
pdc->FillRect(rect0,&brush0);
pdc->FrameRect(rect0,&brushl20);
CString ss;
ss.Format("%.2f",m_output);
pdc->DrawText(ss,CRect(rect0),DT_CENTER|DT_SINGLELINE|DT_VCENTER);
CRect rect33;
CBrush brush33(RGB(255,0,0));
rect33.left=rect.left+8*(rect.right-rect.left)/12;
rect33.right=rect3.right;//9*(rect.right-rect.left)/12;
rect33.top=rect3.bottom -(rect3.bottom -rect3.top)*m_output/100;
rect33.bottom=rect.bottom-1*(rect.bottom-rect.top)/10;
pdc->FillRect(rect33,&brush33);
pdc->FrameRect(rect3,&brush12);
pdc->TextOut(rect3.left,rect3.top-20,"ov");
rectB.left=rectBouds.left+100;
rectB.right=rectBouds.left+150;
rectB.bottom =rectBouds.bottom-20;
rectB.toP=rectBouds.bottom-60;
m_Button.MoveWindow(rectB,true);
if(m_Button.GetState()==0x0008)
{
  m_MyDialog.DoModal();
}
if(m_szbutton.GetState()==0x008)
{
if(!zsflg)
{
m_zbutton.EnableWindow(true);
m_fbUtton.EnableWindow(true);
m_szbUtton.SetWindowText("手动");
zsflg=!zsflg;
}
else
{
zsflg=!zsflg;
m_zbutton.Enab1eWindow(false);
m_fbutton.Enab1eWindow(false);
m_szbutton.SetWindowText("自动");
}
m_szbutton.SetState(0x004);
}
}
错误如下:
--------------------Configuration: pid4 - Win32 Debug--------------------
Compiling...
Pid4Ctl.cpp
f:\pid4\pid4ctl.cpp(3) : warning C4652: compiler option 'Generate Browser Info' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
F:\pid4\Pid4Ctl.cpp(176) : error C2065: 'poldfont' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(176) : error C2440: '=' : cannot convert from 'class CFont *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
F:\pid4\Pid4Ctl.cpp(179) : error C2039: 'Textout' : is not a member of 'CDC'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(636) : see declaration of 'CDC'
F:\pid4\Pid4Ctl.cpp(196) : error C2065: 'brushl20' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(198) : error C2065: 'm_output' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(203) : error C2065: 'rect3' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(203) : error C2228: left of '.right' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(204) : error C2228: left of '.bottom' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(204) : error C2228: left of '.bottom' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(204) : error C2228: left of '.top' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(208) : error C2228: left of '.left' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(208) : error C2228: left of '.top' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(209) : error C2065: 'rectB' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(209) : error C2228: left of '.left' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(210) : error C2228: left of '.right' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(211) : error C2228: left of '.bottom' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(212) : error C2228: left of '.toP' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(213) : error C2065: 'm_Button' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(213) : error C2228: left of '.MoveWindow' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(214) : error C2228: left of '.GetState' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(216) : error C2065: 'm_MyDialog' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(216) : error C2228: left of '.DoModal' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(218) : error C2065: 'm_szbutton' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(218) : error C2228: left of '.GetState' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(220) : error C2065: 'zsflg' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(222) : error C2065: 'm_zbutton' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(222) : error C2228: left of '.EnableWindow' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(223) : error C2065: 'm_fbUtton' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(223) : error C2228: left of '.EnableWindow' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(224) : error C2065: 'm_szbUtton' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(224) : error C2228: left of '.SetWindowTextA' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(230) : error C2228: left of '.Enab1eWindow' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(231) : error C2065: 'm_fbutton' : undeclared identifier
F:\pid4\Pid4Ctl.cpp(231) : error C2228: left of '.Enab1eWindow' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(232) : error C2228: left of '.SetWindowTextA' must have class/struct/union type
F:\pid4\Pid4Ctl.cpp(234) : error C2228: left of '.SetState' must have class/struct/union type
Pid4Ppg.cpp
f:\pid4\pid4ppg.cpp(3) : warning C4652: compiler option 'Generate Browser Info' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
F:\pid4\Pid4Ppg.cpp(24) : error C2065: 'IDC_EDIT1' : undeclared identifier
F:\pid4\Pid4Ppg.cpp(25) : error C2065: 'IDC_EDIT4' : undeclared identifier
Generating Code...
Error executing cl.exe.

pid4.ocx - 38 error(s), 2 warning(s)
请高手帮看一下,感激不尽!
搜索更多相关主题的帖子: 控件外观 ActiveX rectBouds pdc 
2008-05-08 10:15
快速回复:请高手指点一下下面绘制ActiveX控件外观的代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041655 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved