Это дополнительный вопрос.
Мои предыдущие вопросы:
- Как вставить данные буфера обмена пользовательского формата в 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;
Мой вопрос:
Как я могу получить для своего пользовательского компонента внутреннее окно, реализующее встроенную оконную процедуру?