Jump to content

programmerdelphi2k

Members
  • Content Count

    1406
  • Joined

  • Last visited

  • Days Won

    22

Posts posted by programmerdelphi2k


  1. in "forms", you can try use "AfterContruction" event to init some value! Same that the "form" is not "ready" for use, but you can access the fields or others if the instance is ready!

    in "inheriting" case, it's necessary look with more attention of calls order :<

    --> a lazy debug help... create a new form with all events called and see how it happens (who is called at first...)?  OnCreate or AfterConstruction?  (try with this events "overrided")

     


  2. GISEngine doest not have "TFORM1" class/instance object, then, you can not reference it like this!

     

    you can create a generic "procedure ... of object" and use it for two, or, for example:

     

    ------ form1

      TForm1 = class(TForm)
        Viewport3D1: TViewport3D;
        procedure Viewport3D1Click(Sender: TObject);

     

    --------- form2

    type
      TForm2 = class(TForm)
        Viewport3D1: TViewport3D;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form2: TForm2;

    implementation

    {$R *.fmx}

    uses
      Unit1;

     

    procedure TForm2.FormCreate(Sender: TObject);
    begin
      Viewport3D1.OnClick := Form1.Viewport3D1Click;
    end;
     


  3. 3 hours ago, Remy Lebeau said:

    You need to remove the double-quotes on the 'del' value, like I showed you eariler.

    same that exists a "blank space" between text on "button" value? like ... 'del=my delete';    <--- this way

     

    3 hours ago, Remy Lebeau said:

    In what way, exactly, does it not work?  Please be more specific.

    Basically, the "GET" works = it get the page of the topic, but "POST" (delete) dont delete the message! of course, the commands can not be accept or is wronged in my code... but basically I send the "POST" with url+topicID and param-list to "DEL" button 

     

    I'll upload a TXT with all returns to "GET" and "POST" texts after send two commands: 

    • Http.GET(...) and following it Http.POST(...) in sequece in the same button-click (procedure)
    3 hours ago, Remy Lebeau said:

    It should be sending back the existing cookie, thus being a single session.

    I see on returns (Get and Post) that the cookie-values is diferent each other! not the same! (same using the same Http object to send two commands in sequence)

     

    3 hours ago, Remy Lebeau said:

    TIdHTTP and TIdCookieManager handle that automatically for you, if you are reusing the same objects for multiple requests.

    YES! I'm using the same instance Object to send "GET" and following "POST" commands.

    1. in my button procedure, I create the Http:= TIdHttp.Create(...)
    2. I send the Http.GET(...) and put the text-results  in my memosLOG
    3. after "GET", I send the "POST" Http.POST(...)  in sequence, and put the text-results  in my memosLOG
    4. I destroy the Http object "Http.Free"

    for better analise, I'm send a TXT with "GET" and "POST" resulted.... I think that is better for you (and me 🙂 

     

    very thanks for you support

     

    IdHTTP_txt_infos.7z


  4. hi @Jeff Steinkamp

     

    As "CreateAnonimous" return a "Thread" you can do it:

    1. create a Array (global or a list protected to multi-access) to store (reference, id, etc...) all thread (anonimous or not) created
      1. if using "protected list" (using TMonitor, TCriticalSection, TSemaphore,  etc...) you can control it better, but I think that it's not necessary at all (see each situation in usage)
      2. if necessary, you can "remove" the thread reference in these list using "OnTerminate or other" when this thread is ended... if possible!
    2. when your form needs to be closed, you can scan this array and see if exists any thread on list and try terminate it, free it etc... this task can be done in "OnCloseQuery()", then, "OnClose()" is free to anothers tasks, you decide!
    3. I have done some like:

    function TerminateMyTasksFirstToLast(AStartFromFirst: boolean = false): integer;

    ... scan all array with thread reference stored and try end it...

     

    OnCloseQuery event:

      CanClose := (TerminateMyTasksFirstToLast() = 0); // if have any thread running... wait end it

     


  5. 42 minutes ago, Davide Angeli said:

    You can't destroy the thread object until it's finished... It doesn't even have time to start.

    hi @Davide Angeli

     

    very thanks for your "EYEsssssssss"  .... WOW MY GOD..... HELP MY GLASSES.....

     

    look, I had tryed many open, close, open, close... IDE, project and "And I couldn't see this very basic and dominant line in the code..."

     

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHH, ... I'm going back to sanity now!

     

    now, all is going to normality.

     

    thansk again


  6. other info:

    1. I have opened the old project create in RAD 11.1 Alexandia
    2. I have "duplicated" the same thread with a new name (TMyNewThread (new) = TMyThread (old) in another unit (unit2) on same project (nothing changed on config etc...)
    3. resulted:  EXECUTE IS NOT CALLED ANYMORE FOR NEW THREAD (TMyNewThread)

    Sem título.png


  7. @Der schöne Günther thanks for your quick reply

     

    this thread have a long code ok but the constructions base is the same than new thread...

     

    unit Unit1;

    interface

    uses
      System.SysUtils,
      System.Classes;

    type
      TMyThread = class(TThread)
      private
        FStatusText: String;
        FThreadID  : cardinal;
      protected
        procedure Execute; override;
      public
        constructor Create(CreateSuspended: boolean = true);
        destructor Destroy; override;
      end;

    implementation

    { TMyThread }

    constructor TMyThread.Create(CreateSuspended: boolean);
    begin
      inherited Create(CreateSuspended);
      //
      FThreadID := ThreadID;
    end;

    destructor TMyThread.Destroy;
    begin
      inherited;
    end;

    procedure TMyThread.Execute;  // is called on runtime and showed on Debug mode
    begin
      // inherited;
      FStatusText := 'OnExecute: Thread in execution...' + FThreadID.ToString;
    end;

    end.


  8. people,

    My "Execute" on Thread is not called anymore... I'm staying crazy and dont see the my error

    1. the thread is created and released with no-errors, etc..
    2. I "breakpoint it" and dont see nothing to happens... 
    3. I have the same constructions in anothers project and "Execute" is execute"D" and breakpoint is breakpoint"ED" >:)
    4. but new projects (units), does not works anymore
    5. I'm staying crazy and dont see my error on code.... help me!

     

     

     

    type
      TMyThread = class(TThread)
      private

      protected
        procedure Execute; override;
      public
        constructor Create;
        destructor Destroy; override;

      end;

      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
      public
      end;

    var
      Form1: TForm1;

     

    implementation

     

    {$R *.dfm}


    { TMyThread }

    constructor TMyThread.Create;
    begin
      inherited Create; // created (be suspended or not) OK! debug
    end;

    destructor TMyThread.Destroy;
    begin
      inherited;  // destroyed OK! debug
    end;

    procedure TMyThread.Execute;
    begin  
      // the "Execute" is not called anymore...   it's jumped, same in Debug mode
      inherited; // or not...
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    var
      x: TMyThread;
    begin
      x := TMyThread.Create;
      try
        // x.Start; // if suspended...
      finally
        x.Free;
      end;
    end;
     


  9. @Remy Lebeau

     

    if I want "delete the topic", I need to do in "Browser" (not in my Indy coding)
    1) find and click "edit" message.
    2) into message, click "delete" button
    ------------------------------------------

    in Indy-app in my test:

    // get the topic = ok! no needs nothing more for see the "message" -> it's work, I have a text-html with full-page with the message!
    Http.Get('https://<<server-address>/topic.asp' + '?topicid=' + LTopicID, LResponseContent);
    --------------

    ResponseCode: 200
    ResponseText: HTTP/1.1 200 OK
    BoundIP: 
    BoundPort: 0
    BoudnPortMin: 0
    BoundPortMax: 0
    ConnectTimeout: 0
    ReadTimeout: 10000
    AuthRetries: 0
    RedirectCount: 0
    MaxHeaderLines: 255
    UseNagle: true

    Response.RawHeaders:Cache-Control: private
    Content-Length: 15116
    Content-Type: text/html; charset=utf-8
    Server: Microsoft-IIS/7.5
    Set-Cookie: ASPSESSIONIDSWTRBRCT=EJ.............JA; secure; path=/      <-------- cookie
    X-Powered-By: ASP.NET
    Date: Thu, 24 Nov 2022 13:47:58 GMT
     

    ----------------
    in Indy-app, I have simulate "edit... delete message", like:

    1) ask to edit the message:
      same<<IdHttp>>Object.Get('https://<<server-address>/topic_edit.asp' + '?topicid=' + LTopicID, LResponseContent); 

     

    2) after "GET" command above, I send a "POST" command using same object "Http.xxxx"

    // LParams = TStringList
    LParams.Add('roomid=111');
    LParams.Add('topicfatherid=0');
    LParams.Add('topicid=' + LTopicID);
    LParams.Add('del="delete"');
    //
      same<<IdHttp>>Object..Post(https://<<server-address>/topic_edit_submit.asp', LParams, LResponseContent);   // DOES NOT WORKS yet! 😞 

    --------------
    Then, if I use the same obj "Http.xxxxx" to send a "GET" command to "edit" and, after, a "POST" command to "DELETE"
    two commands will work in the same "session" (cookie,etc...) or each command will work in distinct session (cookie,etc...)?
    --- if two session, then, the second command dont will work as expected???

     

    is it possible get the "cookie" from "GET -- edit..." to use in "POST -- delete..." command? if yes, how do it?

    Do you understand ?

     

    thanks for now


  10. @Remy Lebeau

     

    you said:

      On 11/20/2022 at 9:49 AM, programmerdelphi2k said:

          AHTTP.Request.ContentType         := 'application/json';  // maybe other configurations, I dont know?

          AHTTP.Request.CharSet             := 'utf-8';

    You are not sending any data to the server, so you shouldn't be assigning values to those properties at all.

     

    ------

    in F12 on Chrome, I see "POST" command was used after "Delete" button to be clicked on "edit message".

    but I cannot see any body reference????

     

     


  11. when clicking in "edit message" I see this in URL:   https://<<addres-from-server>>/topic_edit_submit.asp

     

    in source-page I see this info:

    ...
    <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000">
    <form name="Form1" action="topic_edit_submit.asp" method="post" onSubmit="return check()">

    <input type="hidden" name="roomid" value="1"> 
    <input type="hidden" name="topicfatherid" value="648330"> 
    <input type="hidden" name="topicid" value="648379">
    ...              
    <input type="submit" name="edit" class="button" value="edit">
    <input type="submit" name="del" class="button" value="delete">
    <input type="reset" name="reset" class="button" value="reset">
    <input name="topic_title" type="hidden" value="2">

    <textarea  class="textarea" name="topic_content" rows="11" cols="73">
    </textarea>

    </form>
    </table>

    ...

     

    other thing... what would be usage of "TIdMultiPartFormDataStream" in IdHTTP.POS(...)" ?

    it would be to send some info in "buttons" on "forms" from html page?

    some sample of usage?


  12. 12 hours ago, Remy Lebeau said:

    ... Remi response....

    hi @Remy Lebeau

     

    first, thanks for your time.

     

    As you see, my knowledge of HTML is next to nothing, so I'll try some more information.

    -- I understand that: If server send (just) HTML, then, I have only HTML. OK!

    -- use Chrome Debug, I think that I dont know how intercept my requeriment, at all.

    -- to ask to see (on screen of Chrome)  "one" message, I can to do this: https://<<address-from-server>>/topic.asp?topicid=nnnnn  <-- ID message that I can see on Chrome URL

    ------ using INDY "GET" I can receive this message (in HTML text) in my MEMO, too!

     

    My big problem is (out others, like "coding" :)

    -- Currently, in the browser, to delete any message (SPAM), I need to enter the message to see the "DELETE" button. 

    And, looking at the "source" of the page, by Chrome, right mouse button, I see the above mentioned instruction (<input type="submit" name="del" ...),

    so I thought someone could you tell me how this could be sent by INDY, or another way, because in the Chrome URL I don't see anything related to this.

    That is, I don't know how this is being sent to the server.

     

    Other question about "send config in REQUEST above": you say that I dont need/can send any configuration to server if I just ask something... not send something to server? is that?


  13. Hello girls and boys,

    I'm try to do a little app to read, post and delete my message in a forum.
    In forum, i'm like a "Moderator" (but not ADMIN privilegies! then I can post, edit, delete message (mine or from others)!

     

    the forum use old tech on server:
    -- Server: Microsoft-IIS/7.5
    -- X-Powered-By: ASP.NET
    -- Content-Type: text/html; charset=utf-8 
    -- IP: v4

     

    The answer from Indy "GET" method is a text/html with all necessary to show a "HTML page", but I would just get some data in this page, not whole page!

    -- NONE API is available to help me! then, just read the page-response!!!
    -------------------------------------------------------------------

    Im using Delphi 10 and "INDY" (TIdHttp class).

    ```
      AHttp := TIdHTTP.Create(nil);
      try
        try
          AHTTP.ReadTimeout                 := 10000;
          AHTTP.Request.ContentType         := 'application/json';  // maybe other configurations, I dont know?
          AHTTP.Request.CharSet             := 'utf-8';
          AHTTP.Request.Accept              := '*/*';
          AHTTP.Request.BasicAuthentication := true;
          AHTTP.Request.Username            := 'my user name';
          AHTTP.Request.Password            := 'my password';
          ... 
          // method GET...
          Memo1.Text := Http.Get(HTTP_DEFAULTPAGE); // **GET it's OK for now!!!**

        

          ... I would like use others: POST, UPDATE and DELETE 
        except
          // showmessage...
        end;
      finally
        AHTPP.Free;
      end

    -----------------------------------

    > resulted GET:
    1) for now, I can get the "response" without problem, but the resulted is a "HTML" text.
    2) I would like that was in JSON to catch the "key:value", but unfortunatelly ... many tags HTML default ...
    3) If was possible "JSON pair", it would help me! it's possible?
    4) if not, then is there some way to better get the "message titles", at least?
    -------------------------------------

     

    NOTE: in my IdHttp, I always send my "username + password" like above!

     

    I would like edit a message: 
    ----------------------------
    1) I type the topicID
    2) I get the messsage (posted) in "edit" mode
    3) I change the message content
    4) I post the new message content

     

    I would like "add" a message:
    -----------------------------

     

    I would like delete the message: 
    ----------------------------------------
    1) I type the topicID
    2) I send a "delete" command
    3) then, the message would be deleted


    NOTE:

    -- Currently, to Delete any messages, I have that:

    1) Edit the message to see the "button DELETE" (there is not a button before "Edit message"

     

    2) on source of the page I see:

    <input type="submit" name="del" class="button" value='....'>  to delete the current message


    for now it's only this.

    thanks
     

     

×