Jump to content

Luciano França

uniGUI Subscriber
  • Posts

    273
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Luciano França

  1. I have several settings that I save in my database such as font sizes, colors, etc. How could I give an update on "CustomCSS" because I realize that it is only loaded when creating the "TUniServerModule" Unit ServerModule; public { Public declarations } Procedure UpdateCSS; End; Procedure TUniServerModule.UpdateCSS; Begin With Self.customCSS Do Begin Add('.x-myfield-focus { '); Add(' border-color: #7eadd9; '); Add(' background-color: #FFFFE1; '); Add(' color: #FF0000; '); Add(' background-image: none; '); Add(' } '); End; End; //============================================================================================================ Unit Main; procedure TMainForm.UniFormCreate(Sender: TObject); begin UniServerModule.UpdateCSS; UniEdit2.JSInterface.JSConfig('focusCls', ['myfield-focus']); UniComboBox1.JSInterface.JSConfig('focusCls', ['myfield-focus']); end; CustomCSS.7z
  2. How do I change the color when receiving editing objects like: UniEdit UniMemo UniCombobox I found this post but it doesn't work.
  3. I made a modification in a situation where accessviolation procedure TMainForm.htmlGetFileAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var aFileName : String; aJSONData : String; aJsonObj: TJSONObject; aFileStream :TFileStream; aMemoryStream : TMemoryStream; afileType : String; aOutputFile : String; function getJsonString(wObj: TJSONObject; aItem: String): String; var aObjItem : TJSONString; begin aObjItem := wObj.Get(aItem).JsonValue as TJSONString; Result := aObjItem.Value; end; function getJsonStream(wObj: TJSONObject; aItem: String): TMemoryStream; var aObjItem : TJSONString; aBytes : TBytes; aString : String; i : Integer; begin aObjItem := wObj.Get(aItem).JsonValue as TJSONString; aString := aObjItem.Value; i := Pos('base64,', aString); if i > 0 then aString := Copy(aString, i+7, Length(aString)); aBytes := TNetEncoding.Base64.DecodeStringToBytes(aString); Result := TMemoryStream.Create; Result.WriteBuffer(aBytes, Length(aBytes)); end; begin UniImage1.Picture.Bitmap := nil; UniMemo1.Clear; if (EventName = 'selected_file') then begin aJSONData := Params.Values['file_info']; aJsonObj := TJSONObject.ParseJSONValue(aJSONData) as TJSONObject; try If (Not Assigned(aJsonObj)) Or (Not Assigned(aJsonObj.Get('filename'))) Or (Trim(aJsonObj.Get('filename').ToJSON) = Emptystr) Then Begin ShowMessage('No file was selected'); Exit; End; aFileName := getJsonString(aJsonObj, 'filename'); if aFileName > '' then begin aOutputFile := UniServerModule.StartPath+'UploadFolder\'+ aFileName; aFileType := getJsonString(aJsonObj, 'filetype'); aMemoryStream := getJsonStream(aJsonObj, 'filedata'); try aMemoryStream.SaveToFile(aOutputFile); finally aMemoryStream.free; end; if Pos('text', aFileType) > 0 then begin with TStringList.Create do try LoadFromFile(aOutputFile); UniMemo1.Text := Text; finally free; end end else if Pos('image', aFileType) > 0 then begin aFileStream := TFileStream.Create(aOutputFile, fmOpenRead); try UniImage1.LoadFromStream(aFileStream); finally aFileStream.Free; end; end else if Pos('pdf', aFileType) > 0 then ShowMessage('File is PDF') else ShowMessage('Filetype is unknown') end else ShowMessage('No file was selected'); finally aJsonObj.Free; end; end; end; Completing the Topic how to open Simulate automatic Click.
  4. Wow, I was looking for a way to invoke Frame Click and my colleague did it in a much simpler way. Much obliged.
  5. I believe the colleague is wrong and there is no solution for this I did a search just with the term "TUniHTMLFrame" and opened all the topics related to it and didn't find any solution.
  6. I'm sorry I already did that How to do this search right on the forum I tried by terms "simulate Click UniHTMLFrame" ? "Click UniHTMLFrame" ? "Simulate Click" ?
  7. I looked for it and couldn't find it on the forum, I think it's a simple thing. based on this topic: http://forums.unigui.com/index.php?/topic/24462-detect-cancel-opendialog-in-tunifileuploadbutton/ and I will use a "UniHTMLFrame" instead of "unifileuploadbutton" How do I need to simulate Click? UniHTMLFrame1.JSInterface.JSCall('fileInputEl.dom.click', []); // Error UniHTMLFrame1.JSInterface.JSCall('dom.click', []); // Error UniHTMLFrame1.JSInterface.JSCall('click', []); // Error UniHTMLFrame1.JSInterface.JSCall(UniHTMLFrame1.jsName + 'dom.click', []); // Error
  8. My friend amazing work I and the entire Unigui community are very grateful
  9. what is wrong in this code See attached. Procedure TMainForm.htmlGetFileAjaxEvent(Sender: TComponent; EventName: String; Params: TUniStrings); Var aFileName, aXMLData: String; aJSONData: String; aJsonObj: TJSONObject; aFileStream: TFileStream; Function getJsonString(wObj: TJSONObject; aItem: String): String; Var aObjItem: TJSONString; Begin aObjItem := wObj.Get(aItem).JsonValue As TJSONString; Result := aObjItem.Value; End; Begin If (EventName = 'selected_file') Then Begin aJSONData := Params.Values['file_info']; aJsonObj := TJSONObject.ParseJSONValue(aJSONData) As TJSONObject; Try aFileName := getJsonString(aJsonObj, 'filename'); If aFileName > '' Then Begin aXMLData := getJsonString(aJsonObj, 'filedata'); aFileStream := TFileStream.Create(aXMLData, fmCreate or fmOpenReadWrite or fmShareDenyWrite); Try aFileStream.Position := 0; UniImage1.Picture.LoadFromStream(aFileStream); Finally aFileStream.Free; End; ShowMessage('Selected file is: ' + aFileName); End Else ShowMessage('No file was selected') Finally aJsonObj.Free; End; End; End; FileDownloadDemo.7z
  10. I'm here banging my head to make it generic for any type of file saving in "AStream: TFileStream"
  11. So I liked your solution so much that I'm wanting to ditch "TUniFileUploadButton" and use your approach for everything, including images
  12. Fantastic I would never know how to do something like that If I also want to adapt to use this idea and save the content in a TFileStream and capture any file, not just XML, how could I do it ? htmlGetFile.Html -> el.accept = "*.*"; procedure TMainForm.htmlGetFileAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var aFileName, aXMLData : String; aJSONData : String; aJsonObj: TJSONObject; AStream: TFileStream; // How to use it function getJsonString(wObj: TJSONObject; aItem: String): String; var aObjItem : TJSONString; begin aObjItem := wObj.Get(aItem).JsonValue as TJSONString; Result := aObjItem.Value; end; begin if (EventName = 'selected_file') then begin aJSONData := Params.Values['file_info']; aJsonObj := TJSONObject.ParseJSONValue(aJSONData) as TJSONObject; aFileName := getJsonString(aJsonObj, 'filename'); UniMemo1.Clear; if aFileName > '' then begin Showmessage(aFileName); aXMLData := getJsonString(aJsonObj, 'filedata'); UniMemo1.Text := aXMLData; ShowMessage('Selected file is: ' + aFileName); end else ShowMessage('No file was selected') end; end;
  13. If you could share the source code so I can compile it I would greatly appreciate it.
  14. @Sherzod Some help, I have no idea how I could do this.
  15. Searching on the Internet doesn't help me because I don't know how to use it on unigui Colleague could try for me https://stackoverflow.com/questions/71435515/how-can-i-detect-that-the-cancel-button-has-been-clicked-on-a-input-type-file Grateful
  16. You still don't understand what I need? I don't know what else to describe for you to understand. In VCL, when I open an OpenDialog, the code flow is retained and so when I click on the cancel button I can know if the user chose a file However, in unigui the code flow is not retained and there is no way for events to know when the user has closed the OpenDialog without having chosen a file. How to retain the flow here UniFileUploadButton1.JSInterface.JSCall('fileInputEl.dom.click', []); // Retain Flow Or I there was a cancellation event OpenDialog.execute. // VCL the retained flow For reasons of event logging recorded in a database table, I need to inform the user's action in canceling opendialog and not selecting an XML file from the NFe invoice City hall public management system, everything is audited and recorded
  17. This event only works when I select a file, as I explained above, my problem is that I need to record when the user canceled the operation. See my detailed example above Where user has not selected any file and so I need to record a log if their cancel action
×
×
  • Create New...