设计开发

vcl线程内Synchronize更新主线程ui的问题

问题是这样的:我的Form会触发一个相当耗时的work,而同时我又不希望这个Form在做这个work的时候UI停止响应,所以,我把这个work放到了线程里执行(起了个继承自TThread的TWorker类),现在的问题时我想让这个工作的当前完成度在Form上以进度条的形式反馈给用户,也就是在线程中更新vcl组件的问题,

Continue reading…

[ExpressBars]How to Force a Main Menu to Always Be on Top of a Form

This can be accomplished if the main menu is placed onto a dock control, whose AllowDocking is set to False. Here are the step-by-step instructions of how to implement this feature in your application:
1. Drop the TdxBarDockControl component onto a form. The dock control is aligned to the top by default. Set the BarManager property to the BarManager of the form;
2. Dock the main menu to the dock control;
3. Set the AllowDocking to False of the dock control;
4. Set the NotDocking property of the main menu to [dsNone, dsLeft, dsTop, dsRight, dsBottom] (i.e. activate all options of the NotDocking).
The attached samples demonstrate the results of these steps.

用图片给VCL Form做背景的方法…

开始我在Form的Paint里直接Canvas画图,发现只要一repaint就会闪烁,很明显是先画了背景再画图片造成的,但我发现就算我截下WM_ERASEBKGND直接返回true也不能阻止其重画背景颜色,后来搜到csdn上也有人问到,最后给出的可用解决方法让我觉得很奇怪:首先截下WM_ERASEBKGND返回false,然后子类化整个form的window,处理窗口消息处理函数中的WM_ERASEBKGND和WM_HSCROLL,WM_VSCROLL…

Continue reading…

关于TListBox自绘状态下的repaint闪烁问题

又是一个flicker prob.但这个控件的闪烁问题和以往遇到的有些不同,一般情况下只要禁止控件重绘背景(WM_ERASEBKGND这个消息)就可以解决。我先用了简单的设置方式(那个直接设置vcl控件属性禁止重绘背景),但发现没有效果,后来又用了窗口子类化,重写了窗口过程拦下了重绘背景的消息,但是实际运行发现也没有效果,最后我用SPY++查看这个控件时发现,一个TListBox实际上是由2部分组成,一个TScrollBox负责控制2边滚动条的显示,还有一个InnerListBox是实际显示item的控件,以前的几种尝试方式都是针对错了对象的,如果将子类化的hwnd用inner的就没问题了,基本解决了重绘整个控件时的闪烁问题,但是还是有一点小bug:由于TListBox自绘时并不会卡准最后一个Item的下边一定和控件的下边位置一致,所以有可能在控件内空出一部分空间,如果禁用了背景重画,则空出的这部分空间的颜色无法控制,而另一种方式通过打开inner的双缓冲也可以解决闪烁的问题,但是还是这部分空出的空间的颜色会有时正常(拖动滚动条移动时)有时不正常(用滚轮移动时),这个问题还有待解决。

cvs server: sticky tag `xxx’ for file ‘xxx’ is not a branch…

貌似是cvs的一个经典问题,今天在修改的时候取了一个历史版本,好像就自动给加上了个版本号的tag,然后在commit的时候就出现了这个问题,提示修正后才能commit。
google一下果然是经典问题,很快找到了答案:对出这个错的文件执行update -A后清掉当前的tag就可以了。

[ZT]如何把string解析为int?

Q:如何把string解析为int?
A:简单的方法有三种:
string source = “1412”;
int result = 0;
// 使用Convert.ToInt32(string value);
result = Convert.ToInt32(source);
// 使用Int32.Parse(string value);
result = Int32.Parse(source);
// 使用Int32.TryParse(string s, out int result);
Int32.TryParse(source, out result);

Continue reading…