Jump to content

Pat Foley

Members
  • Content Count

    428
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Pat Foley


  1. 2 hours ago, PeterBelow said:

    One thing too keep in mind is the fact that form variables created by the IDE  do not get assigned any form reference if the unit is part of a package and the form is also not autocreated. If you create the form in code it is your responsibility to assign the created form reference to the variable if you intend to use it (which is a bad idea in the first place IMO).

    Would not using global variables for any forms and using unique name for forms to use make it a better idea.  To reduce complexity a TreeView is loaded in mainform with nodes referencing the forms being created.  The Treeview can then be parented to the Active form to let the user navigate the app readily. A DM can help surfacing the data through the UI.         

     


  2. You might to study and use this to move cursor to control being selected.  I want to add it to IDE <F6> or <Ctrl>.  function it only jumps to selection without any animation 🙂  

    procedure TTaskmaster.moveMouse(AtaskDetail: TInstruction);
    var
      x, y, MouseXError, MouseYError: integer;
      ControlCenter: Tpoint;
      AC: TControl;
    begin
      findControl(AtaskDetail, AC);
      if not assigned(AC) then exit;
    
      if assigned(AC.Parent) then
        AC.Parent.Show;
      AC.Show;
    
      x := AC.ClientOrigin.X + AC.width div 2;
      y := AC.ClientOrigin.y + AC.height div 2;
      begin
        MouseXError := round(1.12 *(x - mouse.CursorPos.X));
            MouseYError := round(1.12 * (y - mouse.cursorPos.y));
    //            MouseXError := min(MouseXError, 10 * sign(MouseXError));
    //                MouseYError := min(MouseYError,  10 * sign(MouseYError));
        controlCenter.X := mouse.CursorPos.x + MouseXError;
        controlCenter.Y := Mouse.CursorPos.y + mouseYError;
        mouse.CursorPos := ControlCenter;
      end;
      repeatTask := (abs(MouseXError) > 7) or (abs(MouseYError) > 7);
    end;

     


  3.  This should yield control asked for. 

     

    procedure TTaskMaster.findControl(AtaskDetail: TInstruction; var AC: TControl);
    var
      ff, ii : integer;
      sForm, sControl: string;
    begin
      with AtaskDetail do
      begin
        if Control <> nil then
          AC := Control
        else
        begin
          sForm := controlForm + ' not found.';
          sControl := controlName + ' not found.';
          //screens move about on windows list top window usually 0 :(
          for ff := 0 to Screen.FormCount - 1 do
          if Screen.Forms[ff].name = controlform then
          begin
            sform := controlForm;
            with Screen.Forms[ff] do begin
              for ii := 0 to componentcount - 1 do
              if Components[ii].Name = ControlName then
              begin
                sControl := controlName + ' comps ' + ii.ToString;
                Control := Components[ii] as Tcontrol;
                //onBS(False, format('Item %d Found %s',[ii,controlName]));
                break;
              end
              //else//if name
              //run := false;
              //  onBS(False, format('Item %d not found %s',[ii,  controlName]));
            end;// with screen forms
          end;  //if screen.forms
          onBS(False, sForm + ' ' + sControl);
        end;// else
      end;//with taskdetail
    end;

    What TInstruction is

      TInstruction = class  //position in Db
        Atom: PAtom;
        Control: TControl;
        ControlForm: string;   //3
        ControlName: string;   //2
        Description: string;//6
        //Nu: integer;       //0
        Kind: string;     //1  was integer
        KindNU: integer;
        referenceValue: Double;//5
        tagName: string;    //4
        tagValue: Double;   //no data in table
      end;

     


  4. One thing about XML is on a treeview each node needs a unique caption so as tabSheets or the parent of control wanted are added a number is added to the node's caption as the forms are added.  

     

    Second thing is the Control could have data reference added.  

     

    type
      // On the UI controls side carry some data references for convenience
      // the data side could use Dependance Injection to tie in UI controls
      TDataButton = class(TButton)
        Form: TControl;
        Strs: TStrings;
    end;

    What's neat about MDI you can create a new childform inside a begin..end.  To access the form elsewhere use Application.Screen 


  5. I used the code for reverse phone lookup that's for an xxx with xx,xxx outlook accounts.    

     

    You need to make a custom list of clients, a Client group email and ... then as employees come and go you add remove their access to the companies Client email account.    

     

    Or you could enhance your application by logging when clients are added, contacted, removed from client list.  I sent out emails and SMS each week to departments as client schedules were updated.  


  6. Again I would use OutLook to make the output using export.

     

    example mapping

    https://jkp-ads.com/rdb/win/s1/outlook/mail.htm

     

    Also here is some old (2017) Excel code from Ron's earlier site 

    Sub DemoAE()
        Dim colAL As Outlook.AddressLists
        Dim oAL As Outlook.AddressList
        Dim colAE As Outlook.AddressEntries
        Dim oAE As Outlook.AddressEntry
        Dim oExUser As Outlook.ExchangeUser
        Set colAL = Outlook.session.AddressLists '("Offline Global Address List")
        For Each oAL In colAL
            'Address list is an Exchange Global Address List
            If oAL.AddressListType = olExchangeGlobalAddressList Then
                Set colAE = oAL.AddressEntries
                For Each oAE In colAE
                    If oAE.AddressEntryUserType = _
                        olExchangeUserAddressEntry _
                        Or oAE.AddressEntryUserType = _
                        olExchangeRemoteUserAddressEntry Then
                        Set oExUser = oAE.GetExchangeUser
                       ' Debug.Print (oExUser.JobTitle)
                       ' Debug.Print (oExUser.OfficeLocation)
                      '  Debug.Print (oExUser.BusinessTelephoneNumber)
                       ' Range("A1").Offset(X, 1) = oExUser.JobTitle
                        Range("A1").Offset(X, 9) = oExUser.ID
                        'OfficeLocation
                        Range("A1").Offset(X, 8) = oExUser.MobileTelephoneNumber
                        'HomeTelephoneNumber
                        Range("A1").Offset(X, 7) = oExUser.Name
                        'Range("A1").Offset(X, 5) = oExUser.PrimarySmtpAddress
                        
                        X = X + 1
                    End If
                Next
            End If
        Next
    End Sub

      


  7. Even holding the mouse over the symbol should show its unit and line!

    1380662124_Screenshot2025-06-18132023.png.f0dcc8fd6253fb18bdac51a63abfa82e.png

     

     

    // since I loaded it look how TStrings Visualizer vs the IDE code screen in rendering in 12.2  

     

    441790586_Screenshot2025-05-30102320.thumb.png.0d3de2ea4cd323a98fc69a571657ee31.png


  8. I think the issue lies in the coding, each series properties needed be updated consistently.  This example shows renaming the series and the labels to allow a consistent means of updating the control. Consistently meaning each control deals only with the data it was named and Created for.

    procedure TForm1.Button1Click(Sender: TObject);
    const labelAft = 'Afternoon';
     labelNite = 'Nite';
     labelDay = 'Day';
     ShiftDayFraction = 8/24;
     clNite = clRed;
    var
      seDay, seAfternoon, seNight: TGanttSeries;
    begin
      seDay := Series1;
      seAfternoon := Series2;
      seNight := Series3;
    
      seNight.Clear;
      seDay.Clear;
      seAfternoon.Clear;
    
    
      var addC: Boolean := CheckBoxBreakLabels.Checked;
    
      var startDate: TDateTIme := Now;
      startDate.SetTime(4, 0, 0, 0);
    
    
    
      seDay.AddGanttColor(startDate + ShiftDayFraction, startDate + 2 * ShiftDayFraction, 1, labelDay, clGreen);
    
      if addC then
        seAfternoon.AddGanttColor(startDate + 2 * ShiftDayFraction , startDate + 3 * ShiftDayFraction, 3, labelAft, clBlue);
    
      seNight.AddGanttColor(startDate, StartDate + ShiftDayFraction, 2, labelNite, clNite);
    
    //  seNight.AddGanttColor(startDate, StartDate + ShiftDayFraction, 1, 'Sametimeline', clNite);
    
    end;

     


  9. Somewhere I have a control that draws a focus rect and tests rect intersect of all controls in componentlist to add to selected list. Just as lost is a control that draws a connector between selected controls  using clienttoscreen.  I will look for the controls later. 

     

    I'll attach the mention control. Depending how you assign the mouse events either drop on the form or resize it manually the TCustomPanel does not have the align prop. Unsure why I was drawing the focus rect with DC back then.1507810985_ScreenshotCXPanel.thumb.png.348d8a0695ca897887da775480621fee.png

     

    I use a Tshape brush style set to bsClear and pen dotted line now.  


  10. On 2/20/2025 at 2:15 AM, Tom Mueller said:

    I have a control (TWinControl) that contains an other control (TPanel)

    You need to add the paint event to draw the control in the IDE plus WMSIZE to allow sizing of controls being drawn.  Changing to descend from Tpanel allows working control base to add control to.  Later the control can be switched to TCustomControl or TWinControl. 

     

    unit uTestSelectMarker;
    
    interface
    
    uses
     Classes, Vcl.Controls, Vcl.ExtCtrls, Winapi.Messages;
    
    type
    
      TTestSelectMarker = class(TPanel)  //change to TcustomControl or TWinControl
      private
        FPanel: TPanel;
      protected
        procedure Paint; override;
        procedure WMSIZE(var message:TWMSIZE); message WM_SIZE;
      public
        constructor Create(AOwner: TComponent); override;
      end;
    
    procedure Register;
    
    implementation
    
    uses
      Graphics;
    
    constructor TTestSelectMarker.Create(AOwner: TComponent);
    begin
      inherited;// Create(AOwner);
     Color := clBtnFace;
    
      FPanel:= TPanel.Create(self);
    //  FPanel.SetSubComponent(True); // Uwe mentioned this in SO post 
      FPanel.Parent:= self;
      FPanel.BevelOuter:= bvNone;
      FPanel.Color:= clCream;
      FPanel.Visible := True;
    end;
    
    procedure Register;
    begin
      RegisterComponents('Test',  [TTestSelectMarker]);
    end;
    
    procedure TTestSelectMarker.Paint;
    begin
      inherited;
      FPanel.Caption := Name;
    end;
    
    procedure TTestSelectMarker.WMSIZE(var message: TWMSIZE);
    begin
      FPanel.setbounds(10,10,Width- 2 * 10, Height - 2 * 10);
    end;
    
    end.

     

    Screenshot 2025-02-25 010433.png


  11. 15 minutes ago, Remy Lebeau said:

    Create a temporary button or something that you can trigger at will to log the current HWNDs, then invoke a standby+wakeup, then trigger the log again and compare the results.

    Here's my logger I had suspected some issue with timer restarting I wrapped the timer event to disable the timer when in the event seemed to help and removed a show event on the logging form seemed to have fixed.

    The following sleep states are available on this system: //Pats win 11 pro
        Standby (S0 Low Power Idle) Network Connected
        Hibernate
        Fast Startup
    
    The following sleep states are not available on this system:
        Standby (S1)
    	The system firmware does not support this standby state.
    	This standby state is disabled when S0 low power idle is supported.
    
        Standby (S2)
    	The system firmware does not support this standby state.
    	This standby state is disabled when S0 low power idle is supported.
    
        Standby (S3)
    	This standby state is disabled when S0 low power idle is supported.
    
        Hybrid Sleep
    	Standby (S3) is not available.
    	The hypervisor does not support this standby state.
    	
    //Events app1 sidebar	
    memoShowMessages
    h18.834 ZeroIndex 985940 Comp 199704
    18.835 TSideBar on top//1
    18.838 Shell_TrayWnd on top // closing logged on App1
    
    18.858 Windows.UI.Core.CoreWindow on top//opening App1
    18.861 LockScreenControllerProxyWindow on top
    18.861 Shell_TrayWnd on top
    18.864 TSideBar on top
    
    //events Second running App sidebar
    memoShowMessages
    18.826 TSideBar on top
    18.827 CabinetWClass on top
    18.829 Shell_TrayWnd on top
    18.834  on top
    18.834 TSideBar on top  //1
    18.838 Shell_TrayWnd on top// closing logged on App2
    18.858  on top
    18.859 Windows.UI.Core.CoreWindow on top//opening logged on App2
    18.861 LockScreenControllerProxyWindow on top
    18.861 Shell_TrayWnd on top
    18.864 TSideBar on top
    
    // made with this coding
    var
      TopWinControl: HWND;
    
    procedure TSideBar.TaskTimerTimer(Sender: TObject);
    const
      MAX_VALUE = 255;
    var
      pcClassName: Array [0 .. MAX_VALUE] Of Char;
      aClassName: string;
      Hnd: HWND;
    begin
      TaskTimer.Enabled := False;
      Hnd := GetForegroundWindow;
      // shows apps being used.
      if Hnd <> TopWinControl then
      begin
        TopWinControl := Hnd;
        GetClassName(Hnd, pcClassName, MAX_VALUE);
        aClassName := Trim(pcClassName);
        label1.Caption := aClassName;
        memoShowMessages.Lines.add(format('%2.3f %s on top', [Time * 24, aClassName]));//Screen.Forms[0].Name]);
      end;
    // show now can change bringtofront getfocus best not use here
     //boo 100xs Jumper.Show;  // not needed and perhaps fighting the debugger
    
      TaskTimer.Enabled := True;
    end;

    Needs to be 64 bit.

    • Like 1

  12. On 1/18/2025 at 7:37 AM, DelphiUdIT said:

    22) Generics and collections;

     

    One.  Generics allow the tags to be quickly set to the Sims IC initial conditions,  adjusted with the various faceplates and output to the UI chart and legends. as so  

    
    TsimUIout = Record
      faceplate: Tform;
      Controller:Tsimcontroller;
      Value: Pdouble;
      Span,
      Min: Integer;
    end;
    
    procedure Update;
      Compute;
      var UIstuff := TList<^TmyUIout>;
      for var ui in UIstuff do update;
    end;
        
    
    
    
    
    
    
    
    
    
    
    

      Two. Use a transpiler pas2js can emit JS that runs on a browser.

     

    Three. Value = validity, number of seats , subject matter.  If the simulator can increase interaction and communication between the crew members during training-- knowledge transfer plus teamwork can happen        🙂

    • Confused 1

  13. 17 hours ago, PhilBoy said:

    Can anyone offer a learning roadmap to be proficient enough to do the task above?

    Much of the roadmap should include reticulation of the system you are modeling.   Bond graphs allow cause effect, modular construction, and the relationship between the domains to be surfaced with causal strokes the bonds (effort vs flow) are drawn  .  To avoid paying 20 K to Twente sim,  I draw the system out in bound book. these drawings help in connecting sources to sinks. A book on bond graphs mentioned that eigenvalue  would be easier to understand written as characteristic wert. 🙂   

     

     

     

    Delphi to Laz.    

    // in lpr  was dpr
    {$IFDEF FPC}
      {$MODE Delphi}// saves using specialize in generic constructs
    {$ENDIF}
    
    uses
    {$IFnDEF FPC}
    {$ELSE}
      Interfaces, // lets the laz work
    {$ENDIF}

     


  14. 2 hours ago, Mark Williams said:

    2. Can't see how TMessageForm helps. Don't see that it addresses the theming issue.

    2. May need to review how the opendialog uses style in the source then. I am running 12.2 but next year will test some stuff with 10.2 win 7 and will compare the source 

     

    3. Pix shows showmessage with and without style.

    Twohead3.png


  15. 1.  put a "banner" on the form say a tpanel and get the textextent of its caption there. use to set bounds of form add in 20*button count and be done.

     

    2. Look at TMessageForm in Vcl.dialogs source that shows how team Emba does it. Time ~ 3 hours.  

     

    3. Pix shows windows dialog vs a TmessageForm. (arrows point out differences in needing different code to view classtype of dialogs when not using style this is 12.2 though.) 

     

    TwoHead.png


  16. How are the () implemented then are they to be implied?

    procedure X(i: Integer);
    begin
    end;
    
    procedure Y;
    
    begin
      var f: TFunc<Integer>;
      //X(f);  You need give the compiler a "Clue"
      X(f()); //runs
    
     //(procedure begin Beep; end);  Boo
     (procedure begin Beep; end) ();  //Yay!
     
     //In VBA need use either Call or add (); 'To even add a line of code. 
    
    end;

     


  17. What keys or click did you use to connect the append.  Under windows code seems to add a line when tabbed?

     

    // if you wire up onClick In Events in Object Inspector
    procedure TForm13.ComboEdit1Click(Sender: TObject);
    begin
      if Sender is TComboEdit then
      begin
        var CE := Sender as TComboEdit;
        CE.Items.Insert(0, CE.text);
        //CE.Items.add(CE.Text);
        //CE.Items.Insert(CE.Items.Count, CE.text);
        CE.Text := '';   //clears for newline
      end;
    end;

     

    • Like 1

  18. I thought Remy mentioned using Add with a memo control. Here is a Sample using a nested procedure and a procedure with arguments that pass in controls that update the UI as needed.  This sample uses both Format and ToString to help show the logic in the  Controls as the program runs. 

    implementation
    
    {$R *.dfm}
    
    const
      BooleanOperators: TArray<string> = ['And', 'or', 'xor','NotAnd','NotOr'];
    
    var
      A, B, RC: Boolean;
    
    procedure TForm13.Button1Click(Sender: TObject);
    begin
      A := True;
      B := True;
      // filter the controls props here use nil or '' if control or string not made yet
      demo357Repair(Memo1.Lines, Listbox1.Items, nil, A, B);
    end;
    
    { TForm13 }
    /// <summary>
    ///  The TStrings of TMEMO are passed and requires a Memo1 and a Listbox1 to work
    ///
    /// </summary>
    procedure TForm13.Demo357Repair(const memoStrs, lbAItems, lbBItems : TStrings;var argA,argB: Boolean);
          // this flyover updates the value of RC each pass
          // how would you update A each time
          function flyoverCase(const Idx: NativeInt): Boolean;
          begin
            case Idx of
              0: Result := argA and argB;
              1: Result := argA or argB;
              2: Result := argA xor argB;
              3: Result := not argA or argB;     // adjust these to suit your schema
              4: Result := argA and not argB;
            else
              begin
                Result := False;
                memoStrs.Add('flyover needs attention');//surface errors
              end;
            end;
            // A := Result;
            // UX = User outputs
            memoStrs.Add( Format('%2s = %2s %s %2s', [RC.toString, argA.ToString(True), BooleanOperators[Idx], ArgB.ToString(False)]) );
            lbAItems.Add(RC.ToString);
            //how would you connect lbBItems
    
          end;
    begin
      for var I := Low(BooleanOperators) to High(booleanOperators) do
        RC := flyoverCase(I);
    end;

      

     

     


  19. 16 minutes ago, Vandrovnik said:

    My futile fight with toolbars in Delphi started with Delphi X?? and continues to this day. But I found a solution: I turned off all toolbars and left only the palette on top 🙂(To be honest, I did not try to enable any of toolbars in Delphi 12.2, so I am not sure that problems persist.)

    I like the extra one or two code lines showing gained by not showing them.  If only the debug pause button had a key. :classic_angry:

×