Delphi 窗口消息

function TCmdEbookMin.Execute: string;
//  var
//  hHandle           : HWND;
begin
  //hHandle := Application.MainForm.Handle;
  //PostMessage(hHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
  Application.Minimize;
end;


case Message.msg of
    WM_COPYDATA:
      begin
        str := StrPas(PChar(PCopyDataStruct(Message.lparam)^.lpData));
        outputArgs := SplitString(str, '|');
        if outputArgs.Count > 0 then
        begin
          if outputArgs[0] = 'getres' then

            DownloadCallback(str)
          else if outputArgs[0] = 'uploadres' then
            UploadCallback(str);

          if outputArgs.Count <> 2 then
          begin
            Exit;
          end;

          if outputArgs[0] = 'videocap' then
          begin
            if (outputArgs[0] = 'videocap') and (outputArgs[1] = 'nocamera') then
            begin
              ShowMessage('没有检测到拍照设备!');
              Exit;
            end;

            data := outputArgs[1];
            VideoCapCallback(data);
          end;
        end;

        outputArgs.Free;
      end;
  end;
  inherited;

var
  SL                : TStringList;
  msg               : string;
  head              : string;
  msglen            : Integer;
  hAgent            : HWND;
  ds                : TCopyDataStruct;
begin
  if combobox_Cams.Items[0] = 'NoCamera' then
  begin
    head := 'videocap|';
    msg := head + 'nocamera';
    msglen := Length(msg);
    // IflybooFrom发送窗口消息
    hAgent := FindWindow('TiflyBookForm', nil);

    if hAgent <> 0 then
    begin
      ds.dwData := 0;
      ds.cbData := msglen * 2 + 2;
      ds.lpData := PChar(msg);
      SendMessage(hAgent, WM_COPYDATA, 0, Cardinal(@ds));
    end;

    Self.Close;
    VideoImage.VideoStop;
    Exit;
  end;


你可能感兴趣的:(Delphi 窗口消息)