VC中如何自定义控件?

shancjb 2017-12-16 10:48:30
VC中如何自定义控件?
...全文
344 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
GHH120338 2017-12-19
  • 打赏
  • 举报
回复
很多都是直接拖进去的,如果是要自定义的话,直接把OnPaint函数重新写过就好了
sichuanwww 2017-12-18
  • 打赏
  • 举报
回复
望蓝天 2017-12-18
  • 打赏
  • 举报
回复
一般从已有类中派生,像窗口啊,按钮啊,在上面重绘就好了,重写DrawItem,或者在OnPaint中直接画。其他别的操作类似于鼠标按下,添加消息响应就好了
schlafenhamster 2017-12-17
  • 打赏
  • 举报
回复
注册一个 类名 如

// CMyAnimateCtrl
BOOL CMyAnimateCtrl::RegisterMyself()
{// Register the window class if it has not already been registered.
	WNDCLASS wc;
	HINSTANCE hInst = AfxGetInstanceHandle();
	if(!(::GetClassInfo(hInst, "MySysAnimate32", &wc)))
	{// otherwise we need to register a new class,must have CS_OWNDC !
		wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;// | CS_OWNDC;// | CS_GLOBALCLASS;
		wc.lpfnWndProc   = ::DefWindowProc;
		wc.cbClsExtra    = 0;
		wc.cbWndExtra    = 0;//SPINCUBE_EXTRA;//=4
		wc.hInstance     = hInst;
		wc.hIcon         = NULL;
		wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground = NULL;
		wc.lpszMenuName  = (LPSTR)NULL;
		wc.lpszClassName = (LPSTR)"MySysAnimate32";
		if (!AfxRegisterClass(&wc))
		{
			AfxMessageBox("Register a custom control failed!");
			return FALSE;
		}
	}
	return TRUE;
}

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧