delphi – 我应该如何提供一个非可视VCL组件的内部私有非可视窗
发布时间:2020-12-15 09:41:38 所属栏目:大数据 来源:网络整理
导读:这是一个后续问题. 我之前的问题: How to paste a custom format clipboard data into a TMemo? Joining the Clipboard Chain Best practices? 我的问题: TComponent没有像TWinControl这样的窗口句柄.我不想依赖外部的. 这是我的自定义组件的片段 type TMy
这是一个后续问题.
我之前的问题: > How to paste a custom format clipboard data into a TMemo? 我的问题: TComponent没有像TWinControl这样的窗口句柄.我不想依赖外部的. 这是我的自定义组件的片段 type TMyClipBoardListener = class(TComponent) private FInnerWindowHandle: HWnd; FNextHWnd: HWnd; //... protected procedure Loaded; override; procedure WndProc(var Msg: TMessage); // <<< This is my wouldbe Window to handle messages public constructor Create(AOwner: TComponent); override; destructor Destroy; override; // ... published // ... end; 我的自定义组件的实现摘录 constructor TMyClipBoardListener .Create(AOwner: TComponent); begin inherited; // FInnerWindowHandle := ...; // <<< What to do here ? Should I pass it to a function/procedure I missed? end; destructor TMyClipBoardListener .Destroy; begin if not(csDesigning in ComponentState) then begin ChangeClipboardChain(FInnerWindowHandle,FNextHWnd); end; // // <<< Are there some cleaning code related to FInnerWindowHandle to implement here or elsewhereCreates a window that implements a specified window procedure. ? // inherited; end; procedure TMyClipBoardListener.Loaded; begin inherited; // if not(csDesigning in ComponentState) then begin FNextHWnd:= SetClipboardViewer(FInnerWindowHandle); end; end; procedure TMyClipBoardListener.WndProc(var Msg: TMessage); begin with Msg do begin // Message to handle : WM_CHANGECBCHAIN and WM_DRAWCLIPBOARD // ... else Result := DefWindowProc(FInnerWindowHandle,Msg,WParam,LParam); // <<< Is this the right way to do default handling properly? end; end; 我的问题: 如何让我的自定义组件实现嵌入式窗口过程的内部窗口? 解决方法
从类单元(而不是表单)调用
AllocateHwnd .
FInnerWindowHandle := AllocateHwnd(WndProc); 完成后,拨打 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |