Jump to content

egnew

Members
  • Content Count

    21
  • Joined

  • Last visited

Everything posted by egnew

  1. I am using a TNetHttpRequest component to retrieve text from a secure website. I use the associated TNetHttpClient's OnAuthEvent to set the username and password. This allows me to retrieve text into a string using IHTTPResponse.ContentasString. I need to retrieve files from the same secured website. When I request the file using the same code, the IHTTPResponse.ContentStream seems to contain the requested file content since the IHTTPResponse.ContentLength appears to be correct. How can I save the content of IHTTPResponse.ContentStream to a file? Thanks
  2. I typecast the ContentStream as a TMemoryStream and SaveToFile worked perfectly. Thanks for your help.
  3. I can set the property of a component on a form by value: SetPropValue(TopPanel,'align',alBottom); I want to be able to set the property using the name of the value as a string: SetPropValue(TopPanel,'align','alBottom'); How can this be accomplished? Thanks
  4. egnew

    SetPropValue by Name

    KodeZwerg. I had a solution using just System.TypInfo, which works for all simple types. try SetPropValue(p_Component,p_PropertyName,p_PropertyValue); except ... But your version is better as it allows me to set all properties. Example: SetPropertyValue(TControl(MyFDConnection.Params),'UserName','MyUserName'); Thank you very much.
  5. I receive this warning when compiling a package: [dcc32 Warning] Indigo.EventHandlers.pas(11): W1055 PUBLISHED caused RTTI ($M+) to be added to type 'TisEventHandler' Documentation at https://docwiki.embarcadero.com/RADStudio/Sydney/en/W1055_Published_caused_RTTI_($M%2B)_to_be_added_to_type_'%s'_(Delphi)s says: The above description means nothing to me. How do I eliminate the warning from my package? Here is the code associated with the warning: type TisEventHandler = class published procedure isPrintScreenClick(Sender: TObject); end; Thanks
  6. I dynamically generate applications from text. This requires me to locate events by name. I am currently allowing either an event handler on a form or a built-in handler. The code I am using is this: function GetNotifyEvent (const p_MethodName: String; p_Form: TForm): TNotifyEvent; var v_Method: TMethod; begin v_Method.Data := Pointer(p_Form); v_Method.Code := p_Form.MethodAddress(p_MethodName); if v_Method.Code = nil then Result := BuiltInEvent(p_MethodName) else Result := TNotifyEvent(v_Method); end; Since I am using MethodAddress, I must publish methods I want to find by name. This is easy and is the approach I am using. I am open to other solutions. But my question is how to get rid of the warning from the compiler.
  7. I have a component in a Delphi package. The component contains a TTimer. When I manually create an instance of the Component, everything works fine. But when I drop the component on my form, everything works until the component tries to activate the timer. When the component attempts to start the timer with "FTimer.Enabled := True;", the access violation occurs. The following code from Vcl.ExtCtrls is called with Value=True but as soon as "if Value <> FEnabled" executes, the access violation occurs. procedure TTimer.SetEnabled(Value: Boolean); begin if Value <> FEnabled then begin FEnabled := Value; UpdateTimer; end; end Is this a bug or am I overlooking something? Thanks
  8. Dalija Prasnikar: You are the best. I have not built any components in years and forgot to add the override. That was the issue. Thanks so much.
  9. I populate forms dynamically from units. Attempts to create a TForm component on the Application.MainForm but has failed. My current workaround is to drop a "Host" panel on the MainForm and use it as the parent. procedure MakeSurface; MyComponent[0] := TPanel.Create; TPanel(MyComponent[0]).Parent := Application.MainForm; MyParent := MyComponent[0]; procedure MakeTopPanel MyComponent[1] := TPanfel.Create; TPanel(MyComponent[1]).Align := alTop; TPanel(MyComponent[1].Parent := MyParent; TPanel(MyComponent[1].Name := 'TopPanel'; Application.MainForm.FormCreate inherited; MakeSurface; MakeTopPanel; This fails with the message "Control 'TopPanel' has no parent window. Path: TopPanel." Application.MainForm.FormCreate inherited; MakeSurface; MyComponent[0].Parent := Self; MakeTopPanel; This works without a problem.
  10. This is not an issue because the first statement in the OnShow event is "OnShow := nil;" which keeps it from being called again. I would never call the OnShow event explicitly.
  11. Lajos Juhász - Thanks. I called inherited in the OnCreate event and never thought Delphi would set the MainForm property later. I moved the code to OnShow, and it works fine now. Thanks
  12. egnew

    SetPropValue by Name

    3) Not a problem. I realized I didn't need the list of values. I can try the provided value. An "invalid property element: <value>" exception is returned. However, if you have a solution, that would be useful. Thanks again.
  13. egnew

    SetPropValue by Name

    Thanks very much. 1 - Works Perfectly 2 - Works Perfectly 3 - Any idea how to the names of the type values? I can do it as shown in my previous email by specifying the type. I need to do it from the type name instead. 4 - I used this code to get the property type. Is there a better way? function GetPropertyType(p_Component: TComponent; const p_PropertyName: String): String; var v_Context: TRttiContext; v_Property: TRttiProperty; begin v_Property := v_Context.GetType(p_Component.ClassType).GetProperty(p_PropertyName); Result := v_Property.PropertyType.ToString; end; Thanks
  14. egnew

    SetPropValue by Name

    I checked the links you provided and do not yet see a solution. I can just use SetPropValue when the property is a simple type of sting, integer, float, etc. But here the property is a type. I am using Align as an example type, as it is a property of all TControl components: property Align: TAlign read FAlign write SetAlign default alNone; I dynamically create components at runtime using text commands and set the values of the components from the text. The command to create a panel aligned to TOP is "PANEL /ALIGN=TOP" which will be changed to "PANEL /ALIGN=alTOP" in the new version. Once I have this working, I can set any property in a component without knowledge of the component. In the current implementation, I have to deal with each property with a type using functions similar to this: function SetAlign(p_Control: TControl; p_Value: String); begin if SameText(p_Setting,'TOP') then p_Control.Align := alTop else if SameText(p_Setting,'BOTTOM') then p_Control.Align := alBottom etc... end; I validate a property name using this: function GetPropertyType(p_Component: TComponent; const p_PropertyName: String): String; var v_Context: TRttiContext; v_Property: TRttiProperty; begin v_Property := v_Context.GetType(p_Component.ClassType).GetProperty(p_PropertyName); Result := v_Property.PropertyType.ToString; end; I am attempting to resolve these problems: 1) How do I get the current value of the property? 2) How do I change the value of a property when the property is a type? That is the question posted here. 3) How do I validate the string that identifies the new property value? I can obtain valid strings for TAlign using the following: for I := Ord(Low(TAlign)) to Ord(High(TAlign)) do p_Memo.Lines.Add(GetEnumName(TypeInfo(TAlign),I)) However, I have not been able to determine how to do this for a type I don't know ahead of time using a parameter like: for I := Ord(Low(p_Type)) to Ord(High(p_Type)) do p_Memo.Lines.Add(GetEnumName(TypeInfo(p_Type),I)) Thanks
  15. I have a TEdgeBrowser log into a website that has PDF records we need to download to our system. When I enter the URL for the PDF, the PDF is loaded into the browser. How can I download the PDF instead of displaying it? Thanks, Sidney
  16. I am emailed html files that link to a Cisco "Secure Email Encryption Service". I can load the downloaded html into a TEdgeBrowser, manually enter the password, click the button, and access the content using document.innerHTML. I need to be able to get the program to fill in the password and click the submit button. Nothing happens when I execute the code I expect to work. I created the following a test form which uses the same input and button: <form action="https://www.google.com" method="post"> Password: <input name="key1" id="passwordInput1" autocomplete="off" type="password"><br> <input type="submit" "id="text_i18n.authframe.safr.button.openonline" value="Open Online" name="openButton"> </form> I set the password using: document.getElementById("passwordInput1").value = 'mypass' I click the button using: document.querySelector("input[type=submit]").click(); Everything works as expected with my test form but I am unable to accomplish this with the "Secure" form. This is likely because the values are embedded in other elements. The structure is very complex and I am leaving out many table rows and other details. I think I have identified the important elements as shown below: <table id="outerTable" <tbody> <tr> <td id="iframelocation"> <iframe id="authFrame" #document >html> <body> <form> <table class="mainWIndow"> <tbody> <tr> <td id="heightControl" <table> <tbody> <tr> <td> <table id=borderTable"> <tbody> <tr> <td id=passwordEntry1"> <p> <input size="20" maxlength="127" name="key1" id="passwordInput1" placeholder="Secure Email Encryption Service Password" title="Enter your password here" autocomplete="off" type="password" style="width: 100%;"> </input> The button is in <td id="openButtonLocation"> in <td id="buttonContainer" eventually going batck to <tr id=buttonRow", etc. and is defined as: <input type="submit" id="text_i18n.authframe.safr.button.openonline" value="Open Online" name="openButton" onclick="openOnline()" class="btn"> The ExecuteScript seems to only execute one line of javascript so I am not sure how to access the field and the button. What do I need to do differently? I would also like to be able to accomplish this using the types (password and submit) instead of the Id once I get this working. Thanks
  17. I deleted invalid paths in "tools options language Delphi library" for "library path", "browsing path", and "Debug DCU path" in both Win-32 and Win-64. Compiling units with "Window" in the use clause fails with the message "[dcc32 Fatal Error] Form.pas(10): F2613 Unit 'Windows' not found." Any unit from WinAPI such as Messages results in similar fatal errors. I can bypass the error by using "WinAPI.WIndows, WinAPI.Messages," instead of "WIndows, Messages". System units such as "SysUtils" can still be used without the need to qualify as "System.SysUtils". I am using RadStudio 11 Alexandria.. Is there a way to resolve this issue without reinstalling? Thanks
  18. I am using a TFDMemTable to import text data. When processing comma delimited files with double-quoted values an error occurs when the last line in the file does not have a line feed. To reproduce this problem create a text file with the following values in notepad: "name","date","amount" "Alpha","1/1/2021","100" "Bravo","1/2/2021","200" "Charlie","1/3/2021","300" Make sure you save the file with the final cursor at the end of the "Charlie" line. The following error will occur on BatchMove.Execute; The error does not occur if double-quote characters are not used. The error does not occur if you add a line feed so the cursor is on the line after "Charlie" when the file is saved. myTable := TFDMemTable; myReader := TFDBatchMoveTextReader; myWriter := TFDBatchMoveDataSetWriter; myMover := TFDBatchMove; procedure Test (const p_FileName: String); var // --- Added in attemp to bypass the issue I: Integer; // --- Added in attemp to bypass the issue begin myReader.FileName := p_FileName; for i := 0 to myReader.Datadef.Fields.Count-1 do // --- Added in attemp to bypass the issue myReader.Datadef.Fields.DataType := atString; // --- Added in attemp to bypass the issue myReader.DataDef.WithFieldNames := True; myWriter.DataSet := myTable; myWriter.Optimise := False; myMover.Reader := myReader; myMover.Writer := myWriter; myMover.GuessFormat; myMover.Analyze := [taDelimSep, taHeader, taFields]; myMover.AnalyzeSample := 50; myMover.Execute; end; The files being processed are automatically obtained from other systems. We cannot control the presence of the linefeed without modifying the received file. Can you please advise on how to handle this issue?
  19. Thanks for your help. The issue is resolved. I reported the bug and your solution: https://quality.embarcadero.com/browse/RSP-32465
  20. Thanks for your solutions but I am asking how to get the FDBatchMove to properly handle the situation.
  21. Our web applications have been moved to IIS on a server running Microsoft Windows Server 2019 Standard. I have two SOAP applications (Delphi 10.3.3) running on the server. One of the SOAP applications is accessed by external third-party clients and works fine. The second SOAP application handles geocoding tasks for internal users and is accessed using our main client application (Delphi XE2). When users access the geocoding SOAP over https, they get the message: "A certificate is required to complete client authentication - URL:https:.../indigoservice.exe/soap/IIsservices - SOAPAction:urn:IsServicesIntf-IIServices#GeocodeArea" I can't install certificates on users computers and so I don't know how to resolve this issue. I made changes to the SOAP source to run over http and opened the http port on the server. That didn't work either as users get the message: Class not registered, ClassID: {C0EAC9EB-1D02-4BD9-8DAB-4BF922C8CD13}. I can rewrite the routine without using SOAP but would like to get this online ASAP. What can be done to get this working? Thanks
×