我要做一个在非客户区的按扭控件。注:是控件,不单是绘制一个按扭并响应消息。
现在是继承自TComponent的类,但是要如何响应消息?
现在是继承自TComponent的类,但是要如何响应消息?
解决方案 »
- dbgrideh多选后,如何SHOW字段出来
- 不知谁用过,请教一下Camtasia Studio使用问题??
- delphi7开发ocx控件供vb.net调用的字符串作参数传递问题。(高分求助,不够再加)
- IWDBGrid的问题??
- 关于内存拷贝的问题,高手帮忙
- 怎样提取资源
- 请问如何将一个integer类型的数据转换为一个byte数组
- 数据库菜鸟的小问题,高分相送!!
- 如何用Java编写检测是否和PLC连接 断连则发送邮件 有没有大神会的 急!!!
- 动态创建Query
- 关于多线程里TidHTTP的 一个问题,搞很久了,请大家帮忙看看
- 很多年没用Delphi了,又要重新捡起。现在大家都用什么版本,推荐一下,谢谢
明明说的非客户区,不好意思.
楼主的意思是不是一个控件,然后在具有客户区的Parent(如Form)上绘制东西并响应?如何是的话,从TGraphicControl开始继承
第二种:处理应用程序接收到的WM_NCCALCSIZE消息,改变客户区在窗口中的位置,从而得到合适标题栏高度。
---------------------------
我现在选择的是第二种
TFormMessage = class(TComponent)
private
fParentForm : TForm;
fOldProc : TWndMethod;
procedure MessageProc(var Message: TMessage);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override; procedure SetForm(const Value: TForm);
end;{ TFormMessage }
constructor TFormMessage.Create(AOwner: TComponent);
begin
inherited;
while AOwner<>NIL do begin
if AOwner is TForm then begin
SetForm(TForm(AOwner));
Break;
end;
AOwner := AOwner.Owner;
end;
end;destructor TFormMessage.Destroy;
begin
SetForm(NIL);
inherited;
end;procedure TFormMessage.SetForm(const Value: TForm);
begin
if Value = fParentForm then exit;
if fParentForm <> NIL then begin
fParentForm.WindowProc := fOldProc;
fParentForm := NIL;
fOldProc := NIL;
end;
if Value <> NIL then begin
fParentForm := Value;
fOldProc := Value.WindowProc;
Value.WindowProc := MessageProc;
end;
end;procedure TFormMessage.MessageProc(var Message: TMessage);
var
bCallDefault : Boolean;
begin
bCallDefault := True;
if Message.Msg = WM_NCCALCSIZE then begin
//该消息的处理代码
//bCallDefault := False; //覆盖选项
fParentForm.Caption := fParentForm.Caption + 'a';
end;
if bCallDefault and Assigned(fOldProc) then fOldProc(Message);
end;
都是通过截获父窗口的WindowProc来响应的话,那最终执行的消息响应代码是类B的,就是后面窗口的类。而类A的应该不会响应到。
如果B中设置了这个,A就得不到消息,类推