winfrom中from 和usercontrol不断闪烁处理方法

C#自定义控件(usercontrol)--美化单选按钮和复选按钮(测试可用) 立即下载

winfrom中from 和usercontrol不断闪烁处理方法
原因1:from自己绘制了或者用usercontrol控件,form窗体会不变的闪烁,
原因2:form中图片太多,窗口重叠也严重,每次滚动条滚动时,闪烁非常厉害,cpu使用也超高,配置很好的机器可能看不出来。
解决方法:
第一个方法:利用DoubleBuffer 设置 true,用双缓存处理Form界面内容加载,可以提高页面显示质量。有点效果,配置差的机器可能会很明显的再次闪
第二个方法:
在Form及UserControl上重新写CreateParams,代码如下

Form上的Code

protected override CreateParams CreateParams
{
  get
 {
    CreateParams cp = base.CreateParams;
    cp.ExStyle |= 0x02000000;  // Turn on WS_EX_COMPOSITED
    return cp;
  }
}
UserControl的Code

protected override CreateParams CreateParams
{
  get
 {
    var parms = base.CreateParams;
    parms.Style &= ~0x02000000;  // Turn off WS_CLIPCHILDREN
    return parms;
 }
}
详细参考
http://stackoverflow.com/questions/2612487/how-to-fix-the-flickering-in-user-controls


WS_CLIPCHILDREN-不包括子窗口的父窗口中绘制时所占用的区域。创建父窗口时使用。

WS_CLIPSIBLING,必须用于子窗体,使得该子窗体在收到WM_PAINT时同时令其共父的诸多子窗体(MSDN讲必须不在该区域,即不与之重叠)也会被PAINT。
详细参考
http://blog.163.com/sandylin_wind/blog/static/935500552008105104617806/

 

The following are the extended window styles.

Constant/value Description
WS_EX_ACCEPTFILES 0x00000010L

The window accepts drag-drop files.

WS_EX_APPWINDOW 0x00040000L

Forces a top-level window onto the taskbar when the window is visible.

WS_EX_CLIENTEDGE 0x00000200L

The window has a border with a sunken edge.

WS_EX_COMPOSITED 0x02000000L

Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has aclass style of either CS_OWNDC or CS_CLASSDC.

Windows 2000:  This style is not supported.
WS_EX_CONTEXTHELP 0x00000400L

The title bar of the window includes a question mark. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives aWM_HELP message. The child window should pass the message to the parent window procedure, which should call theWinHelp function using theHELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window.

WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX orWS_MINIMIZEBOX styles.

WS_EX_CONTROLPARENT 0x00010000L

The window itself contains child windows that should take part in dialog box navigation. If this style is specified, the dialog manager recurses into children of this window when performing navigation operations such as handling the TAB key, an arrow key, or a keyboard mnemonic.

WS_EX_DLGMODALFRAME 0x00000001L

The window has a double border; the window can, optionally, be created with a title bar by specifying theWS_CAPTION style in thedwStyle parameter.

WS_EX_LAYERED 0x00080000

The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.

Windows 8:  The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.
WS_EX_LAYOUTRTL 0x00400000L

If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the horizontal origin of the window is on the right edge. Increasing horizontal values advance to the left.

WS_EX_LEFT 0x00000000L

The window has generic left-aligned properties. This is the default.

WS_EX_LEFTSCROLLBAR 0x00004000L

If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored.

WS_EX_LTRREADING 0x00000000L

The window text is displayed using left-to-right reading-order properties. This is the default.

WS_EX_MDICHILD 0x00000040L

The window is a MDI child window.

WS_EX_NOACTIVATE 0x08000000L

A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.

To activate the window, use the SetActiveWindow or SetForegroundWindow function.

The window does not appear on the taskbar by default. To force the window to appear on the taskbar, use theWS_EX_APPWINDOW style.

WS_EX_NOINHERITLAYOUT 0x00100000L

The window does not pass its window layout to its child windows.

WS_EX_NOPARENTNOTIFY 0x00000004L

The child window created with this style does not send the WM_PARENTNOTIFY message to its parent window when it is created or destroyed.

WS_EX_NOREDIRECTIONBITMAP 0x00200000L

The window does not render to a redirection surface. This is for windows that do not have visible content or that use mechanisms other than surfaces to provide their visual.

WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)

The window is an overlapped window.

WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)

The window is palette window, which is a modeless dialog box that presents an array of commands.

WS_EX_RIGHT 0x00001000L

The window has generic "right-aligned" properties. This depends on the window class. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading-order alignment; otherwise, the style is ignored.

Using the WS_EX_RIGHT style for static or edit controls has the same effect as using theSS_RIGHT orES_RIGHT style, respectively. Using this style with button controls has the same effect as usingBS_RIGHT andBS_RIGHTBUTTON styles.

WS_EX_RIGHTSCROLLBAR 0x00000000L

The vertical scroll bar (if present) is to the right of the client area. This is the default.

WS_EX_RTLREADING 0x00002000L

If the shell language is Hebrew, Arabic, or another language that supports reading-order alignment, the window text is displayed using right-to-left reading-order properties. For other languages, the style is ignored.

WS_EX_STATICEDGE 0x00020000L

The window has a three-dimensional border style intended to be used for items that do not accept user input.

WS_EX_TOOLWINDOW 0x00000080L

The window is intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE.

WS_EX_TOPMOST 0x00000008L

The window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use theSetWindowPos function.

WS_EX_TRANSPARENT 0x00000020L

The window should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted.

To achieve transparency without these restrictions, use the SetWindowRgn function.

WS_EX_WINDOWEDGE 0x00000100L

The window has a border with a raised edge.

电脑主板开机12步流程全解析:从按下电源键到BIOS启动的完整过程 本文深入解析了电脑主板从按下电源键到BIOS启动的完整12步流程,详细阐述了待机电路、主供电上电、CPU供电建立、时钟信号分发及复位链等关键硬件协同工作原理。通过剖析电脑主板的电路结构与芯片协作时序,帮助读者构建系统性的硬件故障诊断思维,精准定位开机故障。 阅读详情

相关推荐

STM32F401RET6寄存器手册阅读标记

对于时钟树配置,可参考STM32CubeMX中的时钟树配置,STM32CubeMX将基础配置图像化,较为简单。RCC_CR寄存器的HSIRDY位为只读位,当读取值为1时,表示HSI振荡器准备就绪,当HSION位被设置时,HSIRDY会自动设置为低电平。//问题标记:USART配置寄存器信息是如何与USART1/2/3建立联系的(为什么不是三个分别配置)查阅寄存器手册可知,需要配置时钟的模块有:USART1,IO port A。(2)TX配置方法(寄存器手册512页)(4)配置寄存器(寄存器手册548页)

m0_72615170的博客 1468

C# WinForms 画板实战:手把手教你打造一个交互式绘图工具(附完整源码)

本文详细介绍了如何使用C# WinForms构建一个交互式绘图工具,从项目架构设计到核心绘图逻辑实现,再到可复用控件的封装与功能扩展。通过实战案例,开发者可以学习到双缓冲绘图、撤销/重做功能等关键技术,提升桌面应用开发能力。

weixin_27215337的博客 196

从Android到鸿蒙:UI框架迁移的实战指南与最佳实践

本文为Android开发者提供了将应用UI框架迁移至鸿蒙系统的实战指南。文章深入对比了Android命令式编程与鸿蒙ArkUI声明式编程的核心差异,详细讲解了从环境配置、布局迁移(如RecyclerView转List)、逻辑处理到多设备适配与性能优化的全流程最佳实践,帮助开发者高效完成迁移工作。

weixin_29208077的博客 433

关于C#UserControl闪烁的问题

 Winform在单个UserControl中控件布局过多,在加载的时候就会出现页面闪烁的问题。网上也查了很多资料,有很多涉及到BufferedGraphics,双缓冲,重写控件,以及将构造函数中的东西都放在Form_Load中,然而都没有什么卵用。最后发现重载CreateParams可以做到,而且不是网上大部分写的只对WS_EX_COMPOSITED进行处理。  解决方法如下:  在容器Form...

kun_wang的博客 1039

abaqus 6.13安装(ubuntu 16.04LTS)

1。从iso将文件拷贝出来 2。chmod 777 -R ./* 给文件权限 3。sudo /home/xx/A/setup 4。安装licenseserver 5。拷贝lic,log文件 6。打开license sudo ./lmgrd -c path 7. 27011@xx or 27011@localhost ...

a1099313374的博客 1950

在MacBook M1/M2上,手把手教你打包包含嵌入模型的RagFlow Docker镜像(避坑指南)

本文详细指导如何在MacBook M1/M2上构建ARM64架构的RagFlow Docker镜像,涵盖环境准备、依赖处理、镜像构建及性能优化全流程。特别针对Apple Silicon芯片的兼容性问题提供解决方案,帮助开发者高效完成本地开发环境搭建。

weixin_26908317的博客 242

【WinForm+DevExpress】用EditFormUserControl来编辑GridControl的行数据

1.添加一个gridControl,将它转成我们常用的GridView(GridView是我们常用的Layout) 2.Run Designer ,先将Editable 设置为false,EditMode = EditForm 3.新建一个EditFormUserControl的实例 4.设置gridView的OptionsEditForm.CustomEditFormLayout 5...

早起吃虫的博客 3531

【Docker】如何让docker容器正常使用nvidia显卡

描述了如何在docker容器中使用英伟达显卡的过程和问题解决方法。

NameLoadingFailed的博客 8372

C# WinForm 用户自定义控件UserControl闪烁的问题

转载地址:https://blog.youkuaiyun.com/aoshilang2249/article/details/45251711 使用WinForm开发,当使用了大量的用户自定义控件UserControl时,界面拖动或切换时就会出现闪烁的问题。解决方法主要就是重写UserControl和Form的CreateParams方法。 前端调用UserControl的窗体Form(我的代码是UserControl也可以)这样写:(通俗的讲,就是在Form里new了UserControl,Form这个代码里实现下面

波波诸葛伟 963

芒果YOLOv8改进16:检测头Head篇:即插即用|新颖轻量化非对称多级压缩LADH检测头,原创改进适配YOLOv8高效检测头,检测头新颖性改进,全网首发独一份

YOLOv8代码改进教程:即插即用|新颖轻量化非对称多级压缩LADH检测头🎈

包括YOLOv5、YOLOv7、YOLOv8等模型改进 5611

多图详解VSCode搭建Python开发环境

本文通过多图的方式详细介绍了VSCode搭建Python开发环境,希望能对学习Python的同学们有所帮助。 文章目录 1. VSCode的介绍和安装 2. 安装插件 2.1 安装中文插件 2.2 安装Python插件 2.3 安装远程插件 3. 远程连接服务器 3.1 配置ssh 3.2 运行代码 3.3 调试代码

weixin_43178406的博客 8万+

WinForm解决UserControl自定义控件闪烁的问题

今天无意中看到了这个的解决方法,我的项目是10年做的一个监控类的东西,使用的WinForm开发。其中使用到了自定义控件UserControl;界面上有自己做的地图,地图上使用了自定义控件用来显示状态,但是当拖动地图的时候就会出现闪烁的问题。这个一直困扰我,直到项目结束的时候都没能处理好,只能按照平常的双缓冲方式解决。 今天无意中看到了一个解决方法,于是就把原来的项目拿出来实验了一下,确实有改

狐狸,狐狸~~~~ 3458

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

使用UserControls自定义sharepoint表单页面

表单页面(new,edit,display)进入表单页面的设计模式状态(在url地址后添加&displaymode=design)将原来的webpart关闭掉(注意是关闭不是删除)使用QuickPart添加UserControl缺点:无法使用sharepoint自带的控件及功能优点:可控性高,想怎么搞就怎么搞,所有的功能都需要自己开发。 转载于:https://www.c...

dianlicheng1827的博客 171

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

C# WinForm 用户自定义控件闪烁的问题

使用WinForm开发,当使用了大量的用户自定义控件UserControl时,界面拖动或切换时就会出现闪烁的问题。解决方法主要就是重写UserControl和Form的CreateParams方法。 前端调用UserControl的窗体Form这样写: protected override CreateParams CreateParams { get {

郎涯技术 5378

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

(六十二)c#Winform自定义控件-警灯(工业)

前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。 GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git 如果觉得写的还行,请点个 star 支持一下吧 欢迎前来交流探讨: 企鹅群5...

冰封一夏 2238

【编程随笔】C# 自定义控件防闪烁

必备类库 using System; using System.Drawing; using System.Windows.Forms; using System.Drawing.Imaging;//用来使用PixelFormat,初始化bitmap 代码示例 public partial class BoardComboBox : UserControl { Bitmap _background; public BoardComboBox() ..

qq_36602234的博客 555

C#控件的闪烁问题解决方法

protected override void WndProc(ref Message m) { if (m.Msg == 0x0014) // 禁掉清除背景消息 return; base.WndProc(ref m); }

Joe的专栏 1295

VS中让DOS窗口等待不闪退

四种方法: 方法1:运行程序的时候,不要用F5键执行,用Ctrl+F5执行,它的意思是“启动执行(不调试)”,这样就不会一闪而过了。 方法2:在你的代码的最后加上这句 Console.ReadLine(); 也就是“等待用户输入”,这样DOS窗口直到你敲击回车键才会关闭 方法3:在程序最后加上一句Console.ReadKey();这样DOS窗口接收一个字符才会退出. 方法

妙手书生的博客 2295

使用者控制项- Winforms UserControl

最近练习写专案的时候,用到了UserControl类别 其中摸索了很久,如何设定此控制项的属性以供外部,Form类别来取值与设值。 自定义UserControl如下图: 1、想像一下,要如何设定属性,使得此userControl能够像 dataGridView一样,有dataSource得以绑定资料来源? 2、以及如何设定userControl里的dataGridView储存格的值呢? 首先,自定义属性时,我都会先思考,属性的"封闭性"。 到底此属性是只供外部设值,还是只供外部取值,或是两者皆需要。 以我

blender模型设计者www.blender-3d.cn 410

如何将表单和UserControl转换成DevExpress XtraForm和XtraUserControl

如何将表单转换成DevExpress XtraForm(RibbonForm)、将UserControl转换成DevExpress XtraUserControl呢? 如果你需要转换现有的表单或UserControl到DevExpress XtraForm、RibbonForm或XtraUserControl,只需修改您的表单/UserControl的代码声明。以及更换表单/UserContro

xieyufei的专栏 5062

【C#】新建窗体文件,Form、UserControl

新建窗体文件,Form、UserControl 从**用途**、**功能性**和**架构**方面进行讲解。

weixin_44939430的博客 1562

关闭Usermanager服务导致windows10屏幕不断显烁的故障

为了建立一个极小服务系统,试着把windows10 的绝大多数的服务关闭,并禁止启动。重新启动windows后并无异常,但登录后屏幕不断显烁。经过几个小时排查,发现与Usermanager服务相关。把Usermanagere服务恢复成demang(手动启动)后正常。 这个服务被关闭后,很难做系统操作。只有利用ctrl+atl+del键调出任务管理器,然后利用任务管理器运行cmd,再在命令行...

eliuxiaoming1的博客 1364

winform Control与UserControl的区别

作为创建控件的起点,有两个类分别用于不同的情况。理解这两个类的结构,有助于确定什么场合应使用哪个类。   1、Control类 Control类包含在System.Windows.Forms名称空间中,其基本功能包括:在屏幕上定义一个矩形区域,给它提供一个句柄,处理常规的系统消息。这样,Control类就可以处理用户通过键盘和鼠标输入的信息。Control类可以用作组件的基类,这

shineych的专栏 3730

c#中动态加载及显示UserControl和Form在父控件中

c#

u011555996的博客 4064
上一篇: 批处理发布web项目及应用程序,cs,vc编译的DLL,exe
下一篇: 定义数据库表的字段创建结构体
蝶恋花雨
博客等级 码龄21年 1290粉丝 147原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值