Jump to content

KodeZwerg

Members
  • Content Count

    201
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by KodeZwerg

  1. KodeZwerg

    TJsonTextWriter out of memory

    Since you did not told for what purpose you need to have everything stored to memory, another approach can be to use a database and only get/put data that you actual need for current task.
  2. Good day everone! I did opened this https://quality.embarcadero.com/browse/RSP-33937 to have Segoe UI (Windows Vista+) as Default Font instead of Tahoma (Windows XP) Stay healthy!
  3. Hopefully that should give the doubters enough courage to vote 👍
  4. Thank you for voting, here is my workaround way to have it scaled properly: procedure ApplyFontAndScale(aForm: TForm); var OldSize : Integer; Font : TFont; begin OldSize := aForm.Font.Size; if Screen.MessageFont.Size <> OldSize then begin Font := TFont.Create; try Font.Assign(Screen.MessageFont); Font.Size := OldSize; aForm.Font := Font; finally Font.Free; end; aForm.ScaleBy(Abs(Screen.MessageFont.Size), Abs(OldSize)); end else aForm.Font := Screen.MessageFont; if aForm.BorderStyle <> bsSizeable then begin if aForm.Height > Screen.WorkAreaHeight then aForm.ScaleBy(Screen.WorkAreaHeight, aForm.Height); if aForm.Width > Screen.WorkAreaWidth then aForm.ScaleBy(Screen.WorkAreaWidth, aForm.Width); end; end; calling within OnCreate event.
  5. You can read what Microsoft write in this link. Using "MS Shell Dlg 2" pseudo font is to be backward compatible i guess. (Would be fatal if from now on that HKEY would lead to Segoe UI, font size would not match on old applications....) Feel free to use the classic Windows XP way, my wish is to be more modern and not support Windows XP.
  6. KodeZwerg

    did Sherlock left DP?

    Good day! I wonder why he does not log in anymore?! Since english DP started he aint active on german DP anymore and now inactive since start of 2021. Is he okay? @Sherlock
  7. KodeZwerg

    Prevent Alt or Ctrl + Print Screen

    Thank you Mr. Heffernan, that work! type TfrmMain = class(TForm) protected procedure CreateWnd; override; end; implementation procedure TfrmMain.CreateWnd; begin inherited CreateWnd; SetWindowDisplayAffinity(Handle, WDA_MONITOR); end;
  8. KodeZwerg

    Prevent Alt or Ctrl + Print Screen

    SetWindowDisplayAffinity(Application.MainFormHandle, WDA_MONITOR); Does do nothing, did I called it wrong? //edit SetWindowDisplayAffinity(Application.MainFormHandle, WDA_MONITOR or WDA_EXCLUDEFROMCAPTURE); Also not working. (I called it in FormCreate event) Used Capture Software: Screenshot Captor from DonationCoder.com Tested on latest Windows 10 pro.
  9. KodeZwerg

    did Sherlock left DP?

    My worry = corona virus 😞
  10. KodeZwerg

    Prevent Alt or Ctrl + Print Screen

    Beside analog copy (smartphone) what cant be stopped (but can be a bit mangled if playing with display Hertz) and hooks to eat keyboard you can prevent digital copies (simple screencapture tools) by using overlay to draw screen or write direct to graphic card buffers. Simple Screencapture or Print would end with a black screen.
  11. Equal how you try, it end in a workaround since you publish it with a "write" property.
  12. that i mean, and within your class-code just adjust "_status" to whatever you like. or implement and publish a private setter to adjust only by code not by property if you know what i mean. TMyObject = Class(TObject) strict private _status: String; private procedure mysetter(const AValue: string); public Property Status: String Read _status; End;
  13. Why not dont publish "Read" "Write" at all and access internal the used Variable?
  14. How about BCryptGenRandom from Windows Api? Is that random/quality enough for your needs @Tommi Prami ?
  15. KodeZwerg

    Delphi 5 Printing

    @Geoff88: ShellExecute(Application.Handle, PChar('print'), PChar('A:\Path\to\a\file\to\print.pdf'), PChar(''), nil, SW_HIDE); you can let windows handle everything with that. this would open whatever programm is associated to print that file. //edit if you want full control, customized-printing-in-delphi, here you find everything you need.
  16. good day, is someone willing to help me port those two c# snippets into working delphi (winapi/wininet) snippets please? the first one: var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri("https://yandextranslatezakutynskyv1.p.rapidapi.com/translate"), Headers = { { "x-rapidapi-key", "1234567890" }, { "x-rapidapi-host", "YandexTranslatezakutynskyV1.p.rapidapi.com" }, }, Content = new FormUrlEncodedContent(new Dictionary<string, string> { { "apiKey", "1234567890" }, { "lang", "de-en" }, { "text", "dieser text soll übersetzt werden" }, }), }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } and the second one: var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://systran-systran-platform-for-language-processing-v1.p.rapidapi.com/translation/text/translate?source=auto&target=en&input=dieser%20text%20soll%20%C3%BCbersetzt%20werden"), Headers = { { "x-rapidapi-key", "1234567890" }, { "x-rapidapi-host", "systran-systran-platform-for-language-processing-v1.p.rapidapi.com" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } thank you in advance!
  17. KodeZwerg

    can you help me port c# code to winapi/wininet please?

    function Http_Get: string; const headerkey = 'x-rapidapi-key: 1234567890'; headerhost = 'x-rapidapi-host: systran-systran-platform-for-language-processing-v1.p.rapidapi.com'; var hInet: HINTERNET; hURL: HINTERNET; Buffer: array[0..1023] of AnsiChar; i, BufferLen: cardinal; begin result := ''; hInet := InternetOpen('', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try hURL := InternetOpenUrl(hInet, PChar('https://systran-systran-platform-for-language-processing-v1.p.rapidapi.com/translation/text/translate?source=auto&target=en&input=dieser%20text%20soll%20%C3%BCbersetzt%20werden'), PChar(headerkey + headerhost), 0, INTERNET_FLAG_SECURE, 0); try repeat InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen); if BufferLen = SizeOf(Buffer) then result := result + AnsiString(Buffer) else if BufferLen > 0 then for i := 0 to BufferLen - 1 do result := result + Buffer[i]; until BufferLen = 0; finally InternetCloseHandle(hURL); end; finally InternetCloseHandle(hInet); end; end; this works, i get result = {"message":"You are not subscribed to this API."} now the code for post... thank you @mvanrijnen but i like to try with wininet.
  18. KodeZwerg

    can you help me port c# code to winapi/wininet please?

    function Http_Get(const Server: string; const Resource: string; const key: string): string; const headerkey = 'x-rapidapi-key: '; headerhost = 'x-rapidapi-host: systran-systran-platform-for-language-processing-v1.p.rapidapi.com'; var hInet: HINTERNET; hURL: HINTERNET; Buffer: array[0..1023] of AnsiChar; i, BufferLen: cardinal; begin result := ''; hInet := InternetOpen('', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try hURL := InternetOpenUrl(hInet, PChar('https://' + Server + Resource), {how to put header in here?}nil, 0, INTERNET_FLAG_SECURE , 0); try repeat InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen); if BufferLen = SizeOf(Buffer) then result := result + AnsiString(Buffer) else if BufferLen > 0 then for i := 0 to BufferLen - 1 do result := result + Buffer[i]; until BufferLen = 0; finally InternetCloseHandle(hURL); end; finally InternetCloseHandle(hInet); end; end; i am somehow stuck... please need help
  19. KodeZwerg

    Install .apk via google drive

    Why not create one mail template and spread it out to those 10?
  20. KodeZwerg

    Omnithread examples Target Delphi Version

    {$IF CompilerVersion >= 23} {$DEFINE NameSpace} {$ELSE CompilerVersion} {$UNDEF NameSpace} {$IFEND CompilerVersion} unit ppb1; interface uses {$IFDEF NameSpace} Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls, Vcl.ExtCtrls, System.Threading, {$ELSE NameSpace} Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, ExtCtrls, {$ENDIF NameSpace} Thats a more generic approach for namespace handling.
  21. KodeZwerg

    Download Images from a URL

    {$IFDEF MSWindows} // code that run when windows is used {$ENDIF MSWindows} i really thought that was your question, find out other methods.
  22. KodeZwerg

    Download Images from a URL

    for windows i would use winapi, like that oneliner: Result := URLMon.URLDownloadToFile(nil, PChar('http://www.somewhere.com/something.gif'), PChar('a:\local\file.ext'), 0, nil) = 0;
  23. Very possible that you run into a version conflict. Check used Delphi Indy version and use for that proper libraries. //tip To find out the location of the "good" library (on your development pc), download a tool like ProcessHacker, run your application, let it load libraries, open ProcessHacker, doubleclick on your process, switch to "Modules" tab, either move mouse over library or doubleclick library, both result in telling you location.
  24. KodeZwerg

    Learning Delphi

    1. Hire a freelancer that teach 2. udemy has good learning courses, not free but worth the invest. (a free solution can be youtube, with proper search input you get okay output) Mix of both should be best practice.
×