Ver Mensaje Individual
  #2  
Antiguo 03-03-2008
Avatar de ArdiIIa
[ArdiIIa] ArdiIIa is offline
Miembro Premium
 
Registrado: nov 2003
Ubicación: Valencia city
Posts: 1.481
Reputación: 22
ArdiIIa Va por buen camino
jeje...
Me parece que el asunto tiene mas miga del que parece.

En principio a mi se me ocurrió hacer un SetWindowLong interfiriendo en proceso Wnd de la ventana del reloj, interceptar los mensajes y ya está.
Fácil verdad ?

Pues mira por donde la cosa parece algo mas compleja...

En principio parece inviable lo que proponía a pelo, a no ser que se meta un gancho o Hook a la aplicación que queremos interferir, y para esto tal como he podido ver, se necesita un DLL para enganchar al relojito.

Buscando y buscando he encontrado en Delphi-PRAXIS el código que te pongo aquí (para que no se pierda) que en realidad es el inicio de lo que necesitas. En este ejemplo se controla únicamente si se pulsa el ratón y saca un mensaje. En tu WndProc deberías controlar creo el WM_MOUSEMOVE y actuar en consecuencia..................... que creo que no va a ser poniendo y texto sin mas....


El código:

Código Delphi [-]
library ClockHook;

var
  g_hhook: THandle;
  hwndTaskbar, hwndTray, g_hwndClock: hwnd;
  idThread: dword;

  g_bInitClock: boolean = false;

  g_oldWndProc, g_hInst: THandle;


procedure RefreshRebar(myHwnd: hwnd);
var
  hhwnd: hwnd;
begin
  if myHwnd > 0 then
  begin
    InvalidateRect(myHwnd, nil, TRUE);
    hhwnd := GetWindow(myHwnd, GW_CHILD);
    while hhwnd > 0 do
    begin
      InvalidateRect(hhwnd, nil, TRUE);
      hhwnd := GetWindow(hhwnd, GW_HWNDNEXT);
    end;
  end;
end;

procedure RefreshTaskbar(myHwnd: hwnd);
var
  hwndTaskbar, hwndRebar, hwndTray, hwndStartButton: hwnd;
begin
  hwndTray := GetParent(myHwnd);
  hwndTaskbar := GetParent(hwndTray);
  hwndRebar := FindWindowEx(hwndTaskbar, 0, 'ReBarWindow32', nil);
  hwndStartButton := FindWindowEx(hwndTaskbar, 0, 'Button', nil);

  InvalidateRect(hwndStartButton, nil, TRUE);
  InvalidateRect(hwndTray, nil, TRUE);
  PostMessage(hwndTray, WM_SIZE, SIZE_RESTORED, 0);

  RefreshRebar(hwndRebar);
  PostMessage(hwndRebar, WM_SIZE, SIZE_RESTORED, 0);
  InvalidateRect(hwndTaskbar, nil, TRUE);
  PostMessage(hwndTaskbar, WM_SIZE, SIZE_RESTORED, 0);
end;

function WndProc(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam): lresult; stdcall;
begin
  case uMsg of
    WM_LBUTTONDOWN: MessageBoxA(0, 'Left mouse button', 'Test', 0);
  end;

  result := CallWindowProc(@g_oldWndProc, hWnd, uMsg, wParam, lParam);
end;

procedure InitClock(myHwnd: hwnd);
begin
  if g_bInitClock then exit;
  g_bInitClock := true;

  g_oldWndProc := GetWindowLong(myHwnd, GWL_WNDPROC);
  SetWindowLong(myHwnd, GWL_WNDPROC, LongInt(@WndProc));
  RefreshTaskbar(myHwnd);
end;

function CallWndProc(ncode: integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
  pcwps: PCWPSTRUCT;
begin
  pcwps := PCWPSTRUCT(lParam);

  if (ncode = HC_ACTION) then
  begin
    if (not g_bInitClock) and (pcwps.hwnd = g_hwndClock) then
      InitClock(pcwps.hwnd);
  end;

  result := CallNextHookEx(g_hhook, ncode, wParam, lParam);
end;

function StartHook(): boolean; stdcall;
begin
  g_hInst := GetModuleHandle('ClockHook.dll');

  hwndTaskbar := FindWindow('Shell_TrayWnd', nil);
  hwndTray := FindWindowEx(hwndTaskbar, 0, 'TrayNotifyWnd', nil);
  g_hwndClock := FindWindowEx(hwndTray, 0, 'TrayClockWClass', nil);
  idThread := GetWindowThreadProcessId(hwndTaskbar, nil);
 
  g_hhook := SetWindowsHookEx(WH_CALLWNDPROC, @CallWndProc, g_hInst, idThread);
 
  PostMessage(hwndTaskbar, WM_SIZE, SIZE_RESTORED, 0);
 
  result := true;
end;

function StopHook(): boolean; stdcall;
begin
  SetWindowLong(killhwnd, GWL_WNDPROC, g_oldWndProc);
  g_oldWndProc := 0;
  RefreshTaskbar(killhwnd);

  result := UnhookWindowsHookEx(g_hhook);
  g_hhook := 0;
end;

exports
  StartHook,
  StopHook;
         
begin
end.

Llama la atención que la captura del Wndproc de la ventanita en cuestión lo hace en el procedimiento InitClock.

A partir de ahí, creo tal como digo que no va a bastar con cambiar simplemente un texto del hint, sino que además vas a tener que crear una ventanita tipo Thint con el texto a exhibir.
No se me ocurre como enviarle un CM_HINTSHOW de la VCL.

Seguro que muchos de los ASES que tenemos aquí cuando lean esto, encuentran una solución al asunto, pero creo que lo te pongo es el inicio.

Un saludo estruendoso con petardos...
__________________
Un poco de tu generosidad puede salvar la vida a un niño. ASÍ DE SENCILLO
Responder Con Cita