高手请进,大量动态控件生成时的问题。有没有可能自制不需要句柄的控件???

lyvictor131 2008-02-22 03:32:02
在Form里面动态生成大量控件后。
Error creating window handle.System.Windows.FormsSystem.ComponentModel.Win32Exception: Error creating window handle.
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.CreateGraphicsInternal()
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.ThreadContext.OnThreadException(Exception t)
at System.Windows.Forms.Control.WndProcException(Exception e)
at System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()

查询很多网站说是windows默认句柄是10000个
加入动态生成了10000个左右的控件比如说10000Label,就会抛出以上exception

我想有没有可能自制不需要句柄的控件???

...全文
149 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
js1722 2008-09-25
  • 打赏
  • 举报
回复
遇到和楼主一样的问题了! 楼主现在解决了吗?
knowledge_Is_Life 2008-05-01
  • 打赏
  • 举报
回复
不明LZ在说什么
lalac 2008-02-29
  • 打赏
  • 举报
回复
我曾经开发过一个WinForm,能够容纳至少10000000数量级的UI元素(Button……),可惜是商业的,不能share,思路是自绘UI元素,自己处理UI响应。相当的复杂。

推荐使用WPF,控件没有Handle了,^_^
csharp_start 2008-02-24
  • 打赏
  • 举报
回复
不用控件,自己绘制是一个解决方法,但是,前提是你的这些绘制出来的个体要不要可以移动,删除等等的操作,如果是的话,绘制的话就要反复刷新,可能会有些闪烁
真相重于对错 2008-02-22
  • 打赏
  • 举报
回复
不要用控件,自己绘制ui

8,834

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 组件/控件开发
社区管理员
  • 组件/控件开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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