Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 09-06-2015
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.806
Poder: 22
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
He visto esto en la web de Tory: http://www.swissdelphicenter.ch/torr...ode.php?id=418

Código Delphi [-]
{
You can perform communication between your application using Windows messages
exchange mechanism. We can use HWND_BROADCAST value for first parameter for
SendMessage function for suppressing finding of forms' in other applications HANDLE.
For using HWND_BROADCAST we should register our messages in Windows.
In example below we will inform about our form's top position)

Das Beispiel zeigt, wie zwischen zwei Applikationen eine Meldung (Message)
verschickt werden kann. Die Meldung mit wird mit SendMessage verschickt.
Der erst Parameter ist HWND_BROADCAST, beim zweite ist unsere Message.
Das untenstehende Beispiel informiert z.B über die Top-Position unserer Form}


// 1. Define type of your message structure, it could be something like this:
// 1. Definiere eine eigene Message Struktur:


type
  TWMMYMessage = record
    Msg: Cardinal;   // ( first is the message ID )
    Handle: HWND;    // ( this is the wParam, Handle of sender)
    Info: Longint;   // ( this is lParam, pointer to our data)
    Result: Longint;
  end;

  // 2. Override your form's DefaultHandler method and add
  //    method for handling your message, like this
  // 2. Die DefaultHandler Methode zu überschreiben

  TForm1 = class(TForm)
    ...public
    { Public declarations }
    ...procedure DefaultHandler(var Message); override;
    procedure WMMYMessage(var Msg: TWMMYMessage);
    ...end;


  // 3. Declare message variable:
  // 3. Die Message-Variablen deklarieren:

var
  WM_OURMESSAGE: DWORD;

  // 4. Insert realisation of DefaultHandler and our message handler methods:
  // 4. DefaultHandler Implementation:

procedure TForm1.DefaultHandler(var Message);
var
  ee: TWMMYMessage;
begin
  with TMessage(Message) do
  begin
    if (Msg = WM_OURMESSAGE) then 
    begin
      ee.Msg    := Msg;
      ee.Handle := wParam;
      ee.Info   := lParam;
      // Checking if this message is not from us
      if ee.Handle <> Handle then
        WMMYMessage(ee);
    end
    else
      inherited DefaultHandler(Message);
  end;
end;

procedure TForm1.WMMYMessage(var Msg: TWMMYMessage);
begin
  label1.Caption := Format('Our another form handle :%d', [Msg.Handle]);
  Label2.Caption := Format('Our another form top :%d', [Msg.Info]);
end;

// 5. Add registration of your message that you could
//    handle the HWND_BROADCAST messages:
// 5. Die Message registrieren.

initialization
  WM_OURMESSAGE := RegisterWindowMessage('Our broadcast message');

  // 6. Add the message sending somewhere:

procedure TForm1.Button1Click(Sender: TObject);
begin
  SendMessage(HWND_BROADCAST, WM_OURMESSAGE, Handle, Top);
end;

    // 7. Compile and run two copies of your application and test it functionality.
    // 7. Complilieren und zwei Kopien der Applikationen ausführen.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Comunicacion entre aplicaciones erickahr Varios 0 21-06-2010 18:56:48
Parametros y comunicación entre aplicaciones. NPIdea API de Windows 4 15-04-2010 20:30:30
comunicación entre dos aplicaciones? reinier Redes 1 08-05-2008 11:28:15
comunicacion entre dos aplicaciones haron Varios 6 04-09-2007 00:53:29
Comunicacion entre aplicaciones.... chileno Varios 5 06-10-2006 09:38:07


La franja horaria es GMT +2. Ahora son las 04:30:30.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi