Модераторы: Snowy, bartram, MetalFan, bems, Poseidon, Riply
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Как получить событие о смене реестра? 
:(
    Опции темы
Poseidon
Дата 9.6.2005, 21:34 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Delphi developer
****


Профиль
Группа: Комодератор
Сообщений: 5273
Регистрация: 4.2.2005
Где: Гомель, Беларусь

Репутация: 10
Всего: 133



Код

  An application can be notified of changes in the data stored in the 
  Windows clipboard by registering itself as a Clipboard Viewer. 

  Clipboard viewers use two API calls and several messages to communicate 
  with the Clipboard viewer chain. SetClipboardViewer adds a window to the 
  beginning of the chain and returns a handle to the next viewer in the chain. 
  ChangeClipboardChain removes a window from the chain. When a clipboard change occurs, 
  the first window in the clipboard viewer chain is notified via the WM_DrawClipboard 
  message and must pass the message on to the next window. To do this, our application 
  must store the next window along in the chain to forward messages to and also respond 
  to the WM_ChangeCBChain message which is sent whenever any other clipboard viewer on 
  the system is added or removed to ensure the next window along is valid. 



unit Unit1; 

interface 

uses 
  Windows, Messages, Forms, Classes, Controls, StdCtrls; 

type 
  TForm1 = class(TForm) 
    Button1: TButton; 
    Button2: TButton; 
    procedure Button1Click(Sender : TObject); 
    procedure Button2Click(Sender : TObject); 
    procedure FormCreate(Sender : TObject); 
    procedure FormDestroy(Sender : TObject); 
  private 
    FNextClipboardViewer: HWND; 
    procedure WMChangeCBChain(var Msg : TWMChangeCBChain); message WM_CHANGECBCHAIN; 
    procedure WMDrawClipboard(var Msg : TWMDrawClipboard); message WM_DRAWCLIPBOARD; 
  end; 

var 
  Form1 : TForm1; 

implementation 

{$R *.DFM} 

procedure TForm1.FormCreate(Sender : TObject); 
begin 
  { Initialize variable } 
  FNextClipboardViewer := 0; 
end; 


procedure TForm1.Button1Click(Sender : TObject); 
begin 
  if FNextClipboardViewer <> 0 then 
    MessageBox(0, 'This window is already registered!', nil, 0) 
  else 
    { Add to clipboard chain } 
    FNextClipboardViewer := SetClipboardViewer(Handle); 
end; 


procedure TForm1.Button2Click(Sender : TObject); 
begin 
  { Remove from clipboard chain } 
  ChangeClipboardChain(Handle, FNextClipboardViewer); 
  FNextClipboardViewer := 0; 
end; 


procedure TForm1.WMChangeCBChain(var Msg : TWMChangeCBChain); 
begin 
  inherited; 
  { mark message as done } 
  Msg.Result := 0; 
  { the chain has changed } 
  if Msg.Remove = FNextClipboardViewer then 
    { The next window in the clipboard viewer chain had been removed. We recreate it. } 
    FNextClipboardViewer := Msg.Next 
  else 
    { Inform the next window in the clipboard viewer chain } 
    SendMessage(FNextClipboardViewer, WM_CHANGECBCHAIN, Msg.Remove, Msg.Next); 
end; 


procedure TForm1.WMDrawClipboard(var Msg : TWMDrawClipboard); 
begin 
  inherited; 
  { Clipboard content has changed } 
  try 
    MessageBox(0, 'Clipboard content has changed!', 'Clipboard Viewer', MB_ICONINFORMATION); 
  finally 
    { Inform the next window in the clipboard viewer chain } 
    SendMessage(FNextClipboardViewer, WM_DRAWCLIPBOARD, 0, 0); 
  end; 
end; 


procedure TForm1.FormDestroy(Sender : TObject); 
begin 
  if FNextClipboardViewer <> 0 then 
  begin 
    { Remove from clipboard chain } 
    ChangeClipboardChain(Handle, FNextClipboardViewer); 
    FNextClipboardViewer := 0; 
  end; 
end; 

end. 



--------------------
Если хочешь, что бы что-то работало - используй написанное, 
если хочешь что-то понять - пиши сам...
PM MAIL ICQ   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Delphi: WinAPI и системное программирование"
Snowybartram
MetalFanbems
PoseidonRrader
Riply

Запрещено:

1. Публиковать ссылки на вскрытые компоненты

2. Обсуждать взлом компонентов и делиться вскрытыми компонентами

  • Литературу по Delphi обсуждаем здесь
  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь
  • 90% ответов на свои вопросы можно найти в DRKB (Delphi Russian Knowledge Base) - крупнейшем в рунете сборнике материалов по Дельфи
  • 99% ответов по WinAPI можно найти в MSDN Library, оставшиеся 1% здесь

Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Snowy, bartram, MetalFan, bems, Poseidon, Rrader, Riply.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Delphi: WinAPI и системное программирование | Следующая тема »


 




[ Время генерации скрипта: 0.0512 ]   [ Использовано запросов: 23 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.