Jump to content

Attila Kovacs

Members
  • Content Count

    1936
  • Joined

  • Last visited

  • Days Won

    25

Everything posted by Attila Kovacs

  1. Attila Kovacs

    Prevent WM_VSCROLL on TScrollBox to be executed twice in a row

    I see. Then you could also check how Align "alCustom" works. It could save you some repainting/flickering.
  2. Attila Kovacs

    Prevent WM_VSCROLL on TScrollBox to be executed twice in a row

    No I didn't miss it, and if it works for you then fine. Just fyi, if you drag the thumb, there will be messages coming (more than 2) and if you release the mouse button SB_ENDSCROLL fires. So depending on what you need, "OnScrolling" (Message.ScrollCode <> SB_ENDSCROLL) or "OnScroll" (Message.ScrollCode = SB_ENDSCROLL) you can call your event if assigned. May I ask what do you have in those events?
  3. Attila Kovacs

    Prevent WM_VSCROLL on TScrollBox to be executed twice in a row

    If you were looking for "How to implement OnScroll events" you can trigger it on SB_ENDSCROLL and not on NOT SB_ENDSCROLL. But in this case your question was misleading and wasting our time.
  4. Attila Kovacs

    Prevent WM_VSCROLL on TScrollBox to be executed twice in a row

    That was never my intention to suppress standard windows messages. I answered the question: "I'm looking at this simple example to scroll 2 Scroll boxes at the same time." Does it scroll 2 scrollboxes the same time? (Vertically, I did not implement the horizontal scroll message)
  5. Attila Kovacs

    Prevent WM_VSCROLL on TScrollBox to be executed twice in a row

    There is a reason for the two calls. See msg.ScrollCode and https://docs.microsoft.com/en-us/windows/win32/controls/wm-vscroll Try this. TScrollBox = class(Vcl.Forms.TScrollBox) procedure WMVScroll(var msg: TWMVScroll); message WM_VSCROLL; end; procedure TForm1.ScrollBoxMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); procedure SetPos(ScrollBox: TScrollBox); var NewPos: Integer; begin NewPos := ScrollBox.VertScrollBar.Position - WheelDelta div 5; // sensitivity NewPos := Max(NewPos, 0); NewPos := Min(NewPos, ScrollBox.VertScrollBar.Range); ScrollBox.VertScrollBar.Position := NewPos; end; begin SetPos(ScrollBox1); SetPos(ScrollBox2); Handled := True; end; var InScroll: Boolean; procedure TScrollBox.WMVScroll(var msg: TWMVScroll); begin inherited; if not InScroll then begin InScroll := True; try if Self = Form1.ScrollBox1 then Form1.ScrollBox2.Dispatch(msg) else Form1.ScrollBox1.Dispatch(msg); finally InScroll := False; end; end; end;
  6. Attila Kovacs

    Making method with default encoding

    for TEncoding you can set it nil as default and use your favorite one (as default) if the param is nil
  7. Attila Kovacs

    Object Inspector text color

    right click on the object inspector and properties, not sure for themed skin
  8. Attila Kovacs

    Profiler for Delphi

    @Fr0sT.Brutal I was starting like that but I wanted a human readable output. But yes, basically you are right.
  9. Attila Kovacs

    Profiler for Delphi

    As I could not find anything measuring the InitUnits, and it has its reasons, I come up with this poor mans profiler: Two breakpoints is System.pas, one on TProc(P)(); in "procedure InitUnits;" and the other on the very next asm line: Then right-clink on the red bullets, "Breakpoint properties" -> "Advanced" On the first one: (actually you don't need the "Log result" here) On the second: (I have attached the InitHelper.pas to this post.) And just run the app. It will take a time to finish, then you can save the Events and process/investigate the output. Of course, the measured times are higher because of the debugger, but it gives a very good orientation for finding bottlenecks. To check the unit, place a conditional breakpoint on "I" somewhere. InitHelper.pas
  10. Attila Kovacs

    License key system

    @David Heffernan Actually I do. Actually I was the first who did. No clue why are you chanting the same.
  11. Attila Kovacs

    License key system

    @David Heffernan I'm telling the same. The phrase you quoted was referring to the action "wiping a disk", if a "bug" could cause that, that bug doesn't have to be on purpose.
  12. Attila Kovacs

    License key system

    Well, it's a bit overdramatized, this would also mean that any bug could wipe a disk, or eject the DVD with a speed which cuts off the customers head. Doesn't matter if on purpose or not. But you are right, it's a very bad solution. I would rather afraid that if any result caused by a bug on purpose results in any health/material/monetary loss, one could be held accountable for the damages. Irrespective of the fact if a software was licensed or not.
  13. Attila Kovacs

    Why this code fail?

    @aehimself Ah, I see. You are right, it should be ok. I have also used a helper like this for centuries, it was error prone and annoying initializing the querys to nil. Which is obviously the problem what OP has, unitialized parameter. Then I switched to ORM, since then I can't stand such code anymore 😉
  14. Attila Kovacs

    Why this code fail?

    @aehimself If it's not marked as "var" the parameter is just a preinitialized local var which won't be freed, as this was a factory logic originally. Or am I missing something?
  15. Attila Kovacs

    Why this code fail?

    @aehimself "var" also enforces passing a variable to the method, in this case it would be bad if you could call it with nil. Anyway, this kind of lazy initialization will fail on local variables as they are not automatically set to nil, I would forget it forever.
  16. Attila Kovacs

    Where did I come from

    Same goes for checkbox too... Did you check TDBRadioGroup? Can't you use that instead?
  17. Attila Kovacs

    TEmbeddedWB in a 64 Bit application

    TWebBrowser is in SHDocVw.pas which has FSetExceptMask(femALLEXCEPT); in the initialization section. I don't know ~WB.
  18. Also downloaded successfully with the orange button on the top right without any problem. Version 81.0.4044.113 (Official Build) (64-bit). The app looks interesting, is it like Regiograph?
  19. Attila Kovacs

    Threading question

    That's true. But if he goes: var FSomething: PChar; procedure HandleMessage(var Msg: TMessage); begin FSomething := PChar(Msg.WParam); end; then that was it. And depending on how he is populating the log messages, the memory manager could give him the same address for X times in the client thread. To have even more fun in debugging.
  20. Attila Kovacs

    Threading question

    @Darian Miller I've slightly modified your code, with the sleep you can fine-tune to get it synced 😉 procedure TMyThread.Execute; var Buffer: string; r: integer; begin while (not Terminated) do begin r := random(3242424); Buffer := TEST_STRING + inttostr(r); PostMessage(MainWindowHandle, WM_STATUSOUT, WParam(PChar(Buffer)), r); // Sleep(30); end; end; // Main thread procedure TForm1.WmStatusOut(var Msg: TMessage); begin if PChar(Msg.WParam) <> TEST_STRING + inttostr(Msg.LParam) then begin OutputDebugString(PChar(Msg.WParam)); end; end; or if we want more dramatic results: procedure TMyThread.Execute; var p: pchar; r: integer; begin while (not Terminated) do begin r := random(3242424); p := StrNew(pchar(TEST_STRING + inttostr(r))); try PostMessage(MainWindowHandle, WM_STATUSOUT, WParam(p), r); finally StrDispose(p); end; // Sleep(30); end; end;
  21. Attila Kovacs

    Difference between Pred and -1

    @Mike Torrettinni Nothing special, I thought you like exotic methods 😉
  22. Attila Kovacs

    Difference between Pred and -1

    @Mike Torrettinni Do you know Concat() ?
  23. Attila Kovacs

    Threading question

    Press F7 or F8 to start the debugging session for the application and in CPU View on the code pane press ctrl+g and enter $0040DD41. Which line is it in the code? But It's a low address, so it will be most likely system.pas, so you have to look after the call stack, either on AV or by putting a breakpoint there with a condition. Also, there is an inherited; in the message handler, how do the other handlers look like?
  24. "Debouncing". Slow users are out of luck.
  25. Attila Kovacs

    pipeline and visual feedback

    What is the proper way to display the progress from a pipeline stage when the main thread is blocked by WaitFor()? VCL.
×