Jump to content

Pat Foley

Members
  • Content Count

    439
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Pat Foley


  1. This is one place using the IDE Insight helps greatly. In the design window.

    • use <F6> if your fingers are on the top row of the keyboard.
    • or simply the <Ctrl .> if closer to bottom row. 
    • type in Control name or Class type of control. 
    • Select with Enter Key.  
    • Press <F11> then the Object inspector finder is focused and type in property to edit.

     

    Or  simply tab thru the controls, moving/sizing them with control keys Shift or Ctrl with the arrow keys.  Avoiding this practice in your case by simply pressing <F11> key instead. (Also verifies the tab order)

     

    Or the Structure panel is either mouse able or arrow keys to avoid touching the controls with mouse in the design window.    

     

    Or View revisions by selecting Alt-F12 and select History there. 🙂


  2. 5 hours ago, david berneda said:

    So A and B don't know and don't use each other directly or indirectly, but the end result is for example a tabsheet created in B is displayed in A.

    Use class names vs class types to avoid adding B in uses clauses. Existing controls and forms are renamed to fit existing inifile naming scheme. And as the controls loaded, if their parent is not found, they make one--example a Serie or line needs a Chart if not found we make a chart parenting it to the named form or control.  So all Tee.* is only in mainform BOSS uses. letting the Boss code update the charts and legends parented elsewhere.    

     

    Use ComponentClass and add "fixup" and parenting later for UI controls and List<TMyControl>for non-visual controls.    

     

    A startup inifile is embedded in file to allow the program to run in "Demo" when inifile not found. Mainly to build menu and tree Navigation. But more importantly reduce the need for global variables by using 'names'.

     

    Then with empty uses clauses we stick in a DM needed to share Imagelist. and a Boss unit that reads in the controls needed. 

     

           


  3. To fix your example set the tabstop to False on the Edit controls.   Better to set the Key = 0 when Key = VK_RETURN is handled to let the focus move to next control (Excel style moves to next cell on enter).  More important is have the tabs z-order end at a submit button that confirms the entries.     Sample's editkeydown handles the Edits and a Listbox  to let the user select the right item the first time rather a screen that covers not only the app but other running apps to fix typos.  Also the InputBox allows an edit of its items.     

    procedure TForm1.EditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    var
      ii : Integer;
      s  :string;
    begin
      var MoreZ := not (ssShift in Shift);
    
      if (Key = VK_RETURN) and (Sender is TEdit) then
      begin
        Key := VK_Tab;
        var Edit := Sender as TEdit;
        if not MoreZ then
            Edit.text := InputBox('Fixer', '?', Edit.text);
    
        SelectNext(Edit,MoreZ,True);
      end;
    
      if (Key = VK_RETURN) and (Sender is TListBox) then
      begin
        Key := VK_TAB;
    
        var LB := TListBox(Sender);
                SelectNext(LB,MoreZ,True);
        ii := LB.ItemIndex;
        if ii > -1 then
    
          s := LB.Items[ii]
        else
          begin
            s := 'Select something in' + LB.Name;
            MoreZ := True;
          end;
    
        if MoreZ and (ii > -1)
          then
            LB.Items[ii] := InputBox('lister', '?', s);
        end;
    end;

     

     


  4. Did you use Turbo pascal Programmers Library by Jamsa back then and and how about Ready-to_Run Delphi 3 Algorithms both mention using generic coding for code reuse back then should help in learning code reuse and simply reusing someone else code now.  Tstringlist.Commatext may be able to lift your old code and Format('%s,%,s', ['name', Number.tostring])to feed Stringgrid.Rows[0].commaText := 'name,Number'; 


  5. 18 hours ago, Freeeee said:

    I got the idea from Microsoft.  There year zero date is 01/01/1980.

    mine is 01/01/0000 .  good in a long integer (and a 5 digit year) until 31,999/12/31.

    mmm,  I run win 11 are you still using DOS.  

    procedure TForm16.Button4Click(Sender: TObject);
    var
      SL: TStrings;    // F1 click bait
    begin
    
       SL := memo1.Lines;
       for var aDate in [0, 1,2,3, 30000-2*365-32-17 , 30000, 40000, 50000, 100000] do
       begin
         SL.Add(DateToStr(aDate));
       end;
    end;

     

     

     


  6. 1 hour ago, Stano said:


    Note 2: in such cases I use a list of components. Your TLabel. Then you just need to do everything in a loop. And not list every Tlabel and line of the Tmemo.

    By switching to Static text like a label but the advantage of windows handle so it be selected then you add a event to the win control like so.  F2 is an Edit control.  I'm sure Marco Cantu has much examples in his books.

    procedure  TForm16.Clicker(Sender: Tobject);
    begin
      EZ := F2.Text;
      (Sender as TStaticText).Caption := EZ;
      end;
    
    procedure TForm16.RzButton1Click(Sender: TObject);
     var Labels: Array[0..9] of TStaticText;
     var stlabela: TStaticText;
    begin
     var count:= 0;
     for var stlabel in Labels do
       begin
    
         Labels[Count] := TStaticText.Create(Self);
    
         stlabela := Labels[Count];
         stlabela.Parent := self;
         stlabela.SetBounds(24,20*count,50,23);
         stlabela.onClick := Clicker;
         stlabela.Caption := count.ToString;
         stlabela.Show;
         Inc(count);
       end;
    end;

     


  7. I actually looked at some JS code and Physics for Game Developers by Bourg for stuff on Quaternions.  The Model-3D sample may be a start. 

     

    Years ago at a talk about making the Matrix movie the speaker said the stuff in background was all 2D "decals". And it takes three years of schooling for 3D. (Also even a graphic artist needs know linux to get hired.)  

     

     

    procedure TModel3DTest.Form3DMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Single);
    begin
      if (ssLeft in Shift) and Mouse then
      begin
        DummyX.RotationAngle.X := DummyX.RotationAngle.X - (Y - Down.Y)* 0.3 ;
        DummyY.RotationAngle.Y := DummyY.RotationAngle.Y + (X - Down.X)* 0.3 ;
        Down.X := X;
        Down.Y := Y;
      end;
    end;

     


  8. What making One Application for now. And Run it Three times at a time.  

     

        set the Parameters     Data1.dat , Data2.dat, Data3 for first app.

        set the Parameters     Data2.dat , Data3.dat, Data1 for Second app.

        set the Parameters     Data3.dat, Data1.dat, Data2 for Third app.  

     

    ... procedure FindDeltas( const Param{1}, Param(2), Param(3));
    
       begin 
    
            Old code in here 
    
            
    
      end;
    

      

    Is it a lazy steer that its 'looking' at?

           


  9. What version I using 12.2 and tried this IDE insight and it works well with the keyboard.

     

    • start Delphi
    • Press <F6> and enter VCL
    • Using down arrows select Windows Application
    • Press<F6> enter VCL select VCL form
    • Press<F6> Enter TButton 
    • Repeat above as needed.
    • Press<F6> Enter Help 

  10. 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.         

     


  11. 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;

     


  12.  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;

     


  13. 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 


  14. 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.  


  15. 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

      


  16. 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


  17. 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;

     


  18. 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.  


  19. 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

×