Jump to content

Baxing

Members
  • Content Count

    12
  • Joined

  • Last visited

Posts posted by Baxing


  1. On 3/11/2022 at 3:04 AM, FPiette said:

    You're welcome.

    Whenever you get the solution, please post it here.

     

    Hello FPiette,

     

    I have posted a new thread in the Intraweb forum. And there are many members who have replied to the topic. If you are interested, you can read it in this link

     

    For now, I am not able to implement ICS on IntreWeb, I am currently working on a way to implement an Indy TCP socket on IntraWeb for WebSocket Client(I have a sample code from this link) but still use ICS for a WebSecket Server.

     

    And if you have any suggestions to be able to using ICS on IntraWeb please tell me.

     

    Thank you


  2. 1 hour ago, FPiette said:

    So the handle is correct and yet the error 1400 (Invalid handle) is triggered.

    Maybe PostMessage is not the one we think it is. Try with a fully qualified name:

    
    procedure TForm1.PostMessageButtonClick(Sender: TObject);
    begin
        if FWinHandle = INVALID_HANDLE_VALUE then
            Memo1.Lines.Add('Window handle not created')
        else if not WinApi.Windows.PostMessage(FWinHandle, WM_USER, 1234, 5678) then
            Memo1.Lines.Add(Format('PostMessage failed with error %d (HWND=%d)',
                                   [GetLastError, FWinHandle]));
    end;
    
    

     

    Hello

     

    It give same result

    image.thumb.png.80b00e08bb4aadaf1468fbccd48da562.png

     


  3. I show you for coding from your sample in my IntraWeb application

     

    unit Unit1;
    
    interface
    
    uses
      Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWCompMemo,
      Vcl.Controls, IWVCLBaseControl, IWBaseControl, IWBaseHTMLControl, IWControl,
      IWCompButton,
      Winapi.Windows, Winapi.Messages;
    
    type
      TIWForm1 = class(TIWAppForm)
        BTNCreateHwnd: TIWButton;
        BTNPostMessage: TIWButton;
        BTNDestroyHwnd: TIWButton;
        MMO1: TIWMemo;
        procedure BTNCreateHwndAsyncClick(Sender: TObject;
          EventParams: TStringList);
        procedure BTNDestroyHwndAsyncClick(Sender: TObject;
          EventParams: TStringList);
        procedure BTNPostMessageAsyncClick(Sender: TObject;
          EventParams: TStringList);
      private
        FWinHandle : HWND;
    
        procedure WndProc(var Msg: TMessage);
      public
        constructor Create(AOwner : TComponent); override;
      end;
    
    implementation
    
    {$R *.dfm}
    
    
    { TIWForm1 }
    
    procedure TIWForm1.BTNCreateHwndAsyncClick(Sender: TObject;
      EventParams: TStringList);
    begin
      if FWinHandle <> INVALID_HANDLE_VALUE then
      begin
        System.Classes.DeallocateHWnd(FWinHandle);
        FWinHandle := INVALID_HANDLE_VALUE;
        mmo1.Lines.Add('Window handle destroyed')
      end;
      FWinHandle := System.Classes.AllocateHwnd(WndProc);
      if FWinHandle = INVALID_HANDLE_VALUE then
        mmo1.Lines.Add('Error creating window handle')
      else
        mmo1.Lines.Add(Format('Window handle create %d', [FWinHandle]));
    end;
    
    procedure TIWForm1.BTNDestroyHwndAsyncClick(Sender: TObject;
      EventParams: TStringList);
    begin
      if FWinHandle = INVALID_HANDLE_VALUE then
        mmo1.Lines.Add('Window handle not created yet')
      else
      begin
        System.Classes.DeallocateHWnd(FWinHandle);
        FWinHandle := INVALID_HANDLE_VALUE;
        mmo1.Lines.Add('Window handle destroyed')
      end;
    end;
    
    procedure TIWForm1.BTNPostMessageAsyncClick(Sender: TObject;
      EventParams: TStringList);
    begin
      if FWinHandle = INVALID_HANDLE_VALUE then
        mmo1.Lines.Add('Window handle not created')
      else if not PostMessage(FWinHandle, WM_USER, 1234, 5678) then
    //    mmo1.Lines.Add('PostMessage failed');
    //    mmo1.Lines.Add(Format('PostMessage failed with error %d', [GetLastError]));
        mmo1.Lines.Add(Format('PostMessage failed with error %d (HWND=%d)', [GetLastError, FWinHandle]));
    end;
    
    constructor TIWForm1.Create(AOwner: TComponent);
    begin
      inherited;
    
      FWinHandle := INVALID_HANDLE_VALUE;
    end;
    
    procedure TIWForm1.WndProc(var Msg: TMessage);
    begin
      mmo1.Lines.Add(Format('MSG=%d', [Msg.Msg]));
    end;
    
    initialization
      TIWForm1.SetAsMainForm;
    
    end.

     

    And this is result to show GetLastError, FWinHandle (click CreateHwnd and then click PostMessage buttons)

     

    image.thumb.png.a6eae7f9c555c77e5b737a7290255ea7.png

     

     

    Thank you


  4. 1 hour ago, FPiette said:

    Probably no message pump. Let's add the error number to know more.

    Replace

    
            Memo1.Lines.Add('PostMessage failed');

    by

    
            Memo1.Lines.Add(Format('PostMessage failed with error %d', [GetLastError]));

    then try again and tell us the error code PostMessage returns.

    This Error code :

     

    PostMessage failed with error 1400


  5. I want to send data between multi client and server privately with TCP for some specific work. In the beginning I tested via localhost as the first step. Before putting the server part on the real server and in production I will use SSL as well.

     

    I think using TWSocket(TSslWSocket) for Client (on Delphi Intrraweb App.) and TWSocketServer(TSslWSocketServer) for Server (on VCL) is the answer.

     

    How to use message pump?  Is there a usage example to suggest me?
    or

    Using TICsIpStrmLog can do as I want please tell me.

     

    I've just used the ICS for the first time and tested it on VCL from the available samples and enough to be quite as I want. But encountered a problem when using it with IntraWeb.


    Please help guide me again.


  6. Hello,

     

    I have tested connecting to Web Socker Server with Component TWSocket on Delphi IntraWeb Application.

    But an error occurred as attached picture. The command for connecting to Socket server is used within the TIWButton's OnAsyncClick event with the following commands:

     

      with sktClient do
      begin
        Proto := 'tcp';
        Port := 'localhost';
        Addr := 'telnet';
        LineMode := True;
        LineEnd := #13#10;
        Connect;
      end

     

    which this command can be used normally on VCL..

     

    Please guide me for use ICS Sockets components normally on Delphi IntraWeb. Because now I can't connect and send/receive any data if using ICS Sockets components on Delphi IntraWeb application.

     

     

    Thanks

    ics intraweb error.jpg

×