Jump to content

egnew

Members
  • Content Count

    21
  • Joined

  • Last visited

Community Reputation

3 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I typecast the ContentStream as a TMemoryStream and SaveToFile worked perfectly. Thanks for your help.
  2. 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
  3. 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.
  4. 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.
  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. 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.
  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. 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.
  9. 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
  10. 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.
  11. 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.
  12. 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
  13. 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
  14. 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
  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
×