Jump to content

Pat Foley

Members
  • Content Count

    367
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Pat Foley


  1. These forms show using CB items being created once referred then after.
    Showing the CB dropdown using messages.
    Using the CB to navigate other forms using only one list.
    Most of it is done by creating the ancillary form(s) in runtime.

     

    unit mainFocused;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Edit1: TEdit;
        Memo1: TMemo;
        mainCB: TComboBox;
        procedure Button1Click(Sender: TObject);
        procedure FormClick(Sender: TObject);
        procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
        procedure Button2Click(Sender: TObject);
        procedure Memo1Change(Sender: TObject);
        procedure Edit1Change(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure mainCBChange(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        formsSL, Headings: Tstrings;
        destructor Destroy; override;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    uses
      formAncillary;
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Headings.text := edit1.Text;
      UF.IniZ(self, formsSL, Headings);
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      I,C: integer;
      F: TForm;
      Ctrl: Tcontrol;
    begin
      with Screen do begin
        for I := 0 to formCount - 1 do // downto 0 do
          begin
            F := Forms[I];
            for C := 0 to F.ComponentCount - 1 do
              if F.Components[C] is TCombobox then
                begin
                  Ctrl := F.Components[C] as Tcontrol;
                  F.Show;
                  Ctrl.parent.Show;
                  Ctrl.Show;
                  caption := F.Name;
                  sleep(20);
                  Ctrl.Perform(CB_ShowdropDown,1,0);
                  application.ProcessMessages;
                  sleep(1200);
                  Ctrl.Perform(CB_ShowdropDown,0,0);
                  application.ProcessMessages;
                  Break;
                end;
        end;
        Headings.Text := Headings.Text + format(' %d',[I]);//I.ToString;
      end;
    end;
    destructor TForm1.Destroy;
    var
      I: integer;
    begin
      onclick := nil;
      with Screen do begin
        for I := formCount - 1 downto 0 do
          begin
            Forms[I].close;
          end;
      end;
    end;
    
    procedure TForm1.Edit1Change(Sender: TObject);
    begin
      Headings.Text := Edit1.Text;
    end;
    
    procedure TForm1.FormClick(Sender: TObject);
    begin
      Caption := 'clicked by ' + (Sender as TForm).Name;
      Self.Show;
      Button1.SetFocus;
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Headings := TStringList.Create;
      formsSL := mainCB.items; //borrowing created list
      formsSL.Add(self.Name);
    end;
    
    procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      Caption := 'Mouse over ' +  (Sender as Tcontrol).Name;
    end;
    
    procedure TForm1.mainCBChange(Sender: TObject);
    var
      I: integer;
      S: String;
    begin
      for I := 0 to Screen.FormCount - 1 do begin
        S := mainCB.Items[mainCB.ItemIndex];
        if S <> Screen.Forms[I].name then
          continue
        else
          Screen.Forms[I].show;
      end;
    end;
    
    procedure TForm1.Memo1Change(Sender: TObject);
    begin
      beep;
    end;
    
    end.

    Runtime created

    unit formAncillary;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
    
    type
      TfrmAncillary = class(TForm)
        Button1: TButton;
        Image2: TImage;
        remoteCB: TComboBox;
        procedure Button1Click(Sender: TObject);
        procedure remoteCBChange(Sender: TObject);
        procedure remoteCBDropDown(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        myHeadings,
        myLines: Tstrings;
        rfrmBoss: TForm;
        procedure IncomingTextUpdate(Sender: TObject);
        procedure ForwardFocus(Sender: TObject);
        procedure IniZ(bossForm: TForm; someLines, Headings: Tstrings);
      end;
    
    var
      UF : TfrmAncillary;
    
    implementation
    
    {$R *.dfm}
    
    procedure TfrmAncillary.Button1Click(Sender: TObject);
    begin
      beep;
    end;
    
    procedure TfrmAncillary.remoteCBChange(Sender: TObject);
    var
      I: integer;
      S: String;
    begin
      for I := 0 to Screen.FormCount - 1 do begin
        S := remoteCB.Items[remoteCB.ItemIndex];
        if S <> Screen.Forms[I].name then
          continue
        else
          Screen.Forms[I].show;
      end;
    end;
    
    procedure TfrmAncillary.remoteCBDropDown(Sender: TObject);
    begin
      remoteCB.Items := myLines;
      remoteCB.Text := myHeadings.Text;
    end;
    
    procedure TfrmAncillary.ForwardFocus(Sender: TObject);
    begin
      rfrmBoss.OnClick(self);
    end;
    
    procedure TfrmAncillary.IncomingTextUpdate(Sender: TObject);
    begin
      remoteCB.Invalidate;
    end;
    
    procedure TfrmAncillary.IniZ(bossForm: TForm; someLines, Headings: Tstrings);
    begin
      Application.CreateForm(TfrmAncillary, UF);
        with UF do
          begin
            mylines := someLines;
            myHeadings := Headings;
            remoteCB.Items := someLines;
            name := 'UF_' + Screen.FormCount.ToString;
            myLines.Add(name);
            Caption := name;
            setbounds(10,20,360,270);
            rfrmBoss := bossForm;
            onclick := ForwardFocus;
            onmousedown := nil;
            onmouseMove := bossForm.OnMouseMove;
            Color := RGB(random(255),random(255),random(255));
            show;
        end;
    end;
    end.

     

    • Sad 1

  2. Quote

    1) I did not said "edit". I've said - press Up/Down arrow keys to change selected item.

    2) I did not said "in combo box". Instead I've said - in currently opened drop-down.

     

    That's a big difference in logic.

    Good points.  Where I am the users don't use keyboards or even have them in some rooms. the application writes messages to combo boxes.  So over the years forgot some applications would allow user to change information in a combo box.     


  3. Sorry viewer = "UI" "UX".  Correctly the term should be viewport.  Memo1.text  :=    'Allows this text to be viewed'

     

    Since the CB has a text and dropdown we need pass string and strings to keep it updated.  The improvement is

    rather than passing the information each time.  We simply update using the references provided in the creation of form.

     

    I suspect some programs use timers to provide updates.  I will try to improve naming of the examples say 30 hours out.

     

        


  4. Quote

    Can you be more descriptive? I cannot understand what you want to say?..

    The combo box (CB) should only be used as a viewer. To set up a CB viewer do this  

    This scheme lets simple Tform, TStrings, {String} to allow code reuse. 

    {String} Is commented out untried but someLines will show current memo lines readily.

     

    the memo.sel is not needed here. presented simply to provide message flag to find

    its sisters in the source.     

    in TfrmdrawFocused
    ...
      myLines: Tstrings;
      myCBtext: String;
    ..
    procedure TfrmdrawFocused.IniZ(anOwnerForm: TForm;var someLines: Tstrings; {aText: string});
    begin
      Application.CreateForm(TfrmdrawFocused, UF);
        with UF do begin
                       mylines := someLines;
                       {myCBtext := AText} 
                      // remoteCB.Items := someLines; does not work needs freshened 
                       {remoterCB.Text := aText}
                       name := 'UF' + Screen.FormCount.ToString;
                       Caption := name;
                       setbounds(10,20,360,270);
                       toFocusAhead := anOwnerForm;
                       onclick := ForwardFocus;
                       onmousedown := nil;
                       onmouseMove := anOwnerform.OnMouseMove;
                       Color := $1E69D2;
                       show;
                     end;
    end;

    ple 


  5. There's a difference between focus and select. To help with combobox these bits should help.  the Memo stuff 

    only provides hints of selecting for your combobox

     

    //CB Recipe seasoning 
    Procedure TG1.SelectMemoLine(Memo : TCustomMemo) ;
    Var
      LineNumber : Integer;
    Begin
      LineNumber := Memo.Perform(EM_LINEFROMCHAR, Memo.SelStart, 0);
      Memo.SelStart := Memo.Perform(EM_LINEINDEX, LineNumber, 0);
      Memo.SelLength := Length(Memo.Lines[LineNumber]) ;
      Memo.SetFocus;
      ...
    
    //CB dropdown freshened in the form  
    procedure TfrmdrawFocused.remoteCBDropDown(Sender: TObject);
    begin
      remoteCB.Items := myLines; 
    end;
    
      ... 
    //CB text freshened with timer or update from mainform  
    remoteCB.Text := referenced editbox.text from other form.  
    remoteCB.Invalidate; 

     


  6. Here's a thought--take a screenshot and look for the mouse cursor? 

     

    In the long past  screen captures may had a cursor captured in it.  Would cause great confusion with the running cursor. So the big G himself washes the imaged cursor out so you don't have too!:classic_biggrin:

     

    Not exactly your question asked but a large part of why focus on active window is best.    


  7. unit mainFocused;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure FormClick(Sender: TObject);
    
        procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        destructor Destroy;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    uses
      unFocused;
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      UF.IniZ(self);
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      I,C: integer;
      F: TForm;
    begin
      with Screen do begin
        for I := formCount - 1 downto 0 do
          begin
            F := Forms[I];
            for C := 0 to F.ComponentCount - 1 do
              if F.Components[C] is TButton then
            begin
              F.Show;
              (F.Components[C] as TButton).parent.show;
              (F.Components[C] as TButton).Show;
              caption := F.Name;
              application.ProcessMessages;
              sleep(1200);
              Break;
            end;
          end;
          end;
      end;
    destructor TForm1.Destroy;
    var
      I: integer;
    begin
      onclick := nil;
      with Screen do begin
        for I := formCount - 1 downto 0 do
          begin
    
            Forms[I].close;
          end;
      end;
    end;
    
    procedure TForm1.FormClick(Sender: TObject);
    begin
      Caption := 'clicked by ' + (Sender as TForm).Name;
      Self.Show;
      Button1.SetFocus;
    end;
    
    procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      Caption := 'Mouse over ' +  (Sender as Tcontrol).Name;
    end;
    
    end.
    unit unfocused;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
    
    type
      TfrmdrawFocused = class(TForm)
        Button1: TButton;
        Image2: TImage;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        toFocusAhead: TForm;
        procedure ForwardFocus(Sender: TObject);
        procedure IniZ(anOwnerForm: TForm);
        Destructor Destroy;
      end;
    
    var
      UF, frmdrawFocused: TfrmdrawFocused;
    
    implementation
    
    {$R *.dfm}
    
    { TfrmUnfocused }
    
    procedure TfrmdrawFocused.Button1Click(Sender: TObject);
    begin
      beep;
    end;
    
    destructor TfrmdrawFocused.Destroy;
    begin
      tofocusAhead.free;
      inherited;
    end;
    
    procedure TfrmdrawFocused.ForwardFocus(Sender: TObject);
    begin
      //inherited; //squash local click
      toFocusAhead.OnClick(self);
    end;
    
    procedure TfrmdrawFocused.IniZ(anOwnerForm: TForm);
    begin
      Application.CreateForm(TfrmdrawFocused, UF);
        with UF do begin
                       name := 'UF' + Screen.FormCount.ToString;
                       Caption := name;
                       setbounds(10,20,260,170);
                       toFocusAhead := anOwnerForm;
                       onclick := ForwardFocus;
                       onmousedown := nil;
                       onmouseMove := anOwnerform.OnMouseMove;
                       Color := $1E69D2;
                       show;
                     end;
    end;
    
    end.

    Try these forms with aux forms Borderstyle set to  bsnormal  then no border.   


  8. Quote

    If we speak about combo-box like controls - yes it matters. The user percept main form de-activating/re-activating like flickering, like unwanted behavior.

    If there is flickering going on I would guess a onchange event is looping. radio buttons calling each other after being changed by the other.   

     

    The user needs to know only one window is in focus at a time.   To help the user we would still draw halo around the control using the popup, color the popup the same as launching form.    

     

    Or showing form with image.picture.bitmap of a active form saved as bitmap would work when shown as toolbar. But not recommended.  

     

      

     

     


  9. Quote

    Sounds like you've tried this, 

    Actually in VB I made video poker game.   The enumerations allow say washing machine to be emulated when combined with a case statement.   Each enum needs to be in order in the case statement.  As you add more features you just insert additional enum.  Also consider the scPlaying Its' ordinal value is zero so its first in case statement.  More importantly it helps laying out the program. Until you get around to making the play routine routine it just passes through waiting for change in game status.  I'll fab up a working example in week in week or two. A key or button click would change status then call procedure with case statement.      

     

    Pascal with Excellence quotes Alexander Pope--A little learning is a dangerous thing, drink deep, or taste not.   // I try to share knowledge so people need not read the documentation or hit a barn when learning to fly.  :classic_smile:     


  10. Quote

    I thought there was a way to bundle a whole project for export.  Did that go away.

    Might be easier if you see whole ball of wax.

    No need for that. Its your program and by doing it yourself will allow you to get higher up the hill. 

     

    promote isplaying, isgameover,isplayer2turn booleans to enumeration of Tsolcon  = (scPlaying, scGameover, scNewGameQ, scDeal)

     

    gamestatus:Tsolcon; global

     

    set gamestatus := scNewGameQ

     

    In a timer event place a case statement

     

    Case gameStatus of

    ...

    scNewGameQ:  begin gamestatus := scDeal; // next timer event the code in scDeal will be called

                              end;

    scDeal: //calls procedure dealCards  

     

    end;   

     

    Other events Buttonclick  simply change gamestatus  the timer's event acts on the status change 

     

       

        


  11. I used XL on Mac starting with 2 through XL 4. XL 4 added forms--by printing out the macro sheet and taping the sheets One had the big picture with all the forms and code together:classic_smile:

    Not sure what goes on Apple side now.

     

    Example does not to be on macro sheet.

    cellname         a       b           c

                  'name    'variable 'comment

                   'xvalue   1            'after being renamed "b2" shows as xvalue

                   'yvalue   1 

                   'zvalue   =xvalue+yvalue  '

     

    Naming ranges is number thing to do and use namemanager to help or F5 to navigate to named range F2 to edit in cell.

    To get VBA up <alt><f11> <alt><f10> new macro sheet?

    Also use record macro helps alot!I

     

    I been porting a XL Logging app to D. XL VBA is unsupported now.    Easier to share install package then .xlsm today. 

      

     

     

     

       

     


  12. 17 hours ago, m_pell_98037 said:

    Perhaps I should use subs.

    If subroutines mean procedures and functions also lists arrays and what not.   Marco Cantu has some free books out there.  Delphi has help built in plus source.

     

     

     

    For now take a Tshape and drop it in the design window.   Use the F11 key to change the Brush and Pen Properties this makes a nice card back.  

    In code window find Shape1: TShape; Hold down the control<key>to underline TShape then cllick on it.  This coding allows the Tshape to be made. Study how the paint works with pen and brush. 

     

    Calendar1: TCalendar;  Is another one that shows how change properties and a grid as well.  You not needing to make a control now just examine the plumbing.      

     

     


  13. Quote

    But, when building my application in debug mode I only get 1 hint. When building in release mode I get more hints. 

     

    DCUs are only recompiled when they are not found or a build all command is sent. Delphi may be doing this for you each time you switch from Debug to Release.

     

    If they are not recompiled no hints are generated.  Allowing faster compile times 🙂


  14. 11 hours ago, emailx45 said:

    The man is born a child ... he needs the care of those who were already here.
    The man gets old ... and continues to need those who will live here.

       From diaper to diapered.   What happens in between is accommodation by family, teachers, management, and the State.  A good manager accommodates his charges needs.  Consider the companion animal needed not needed.  I mentioned to the boss of all the shops I worked at this was the only shop that did not have pets.  More toilets can't be installed since the State requires new toilets to meet  accommodation laws. 

     

      The cost of Knowledge is angst.  Being able to share knowledge eases that angst  

     

        


  15. Quote

    It makes me wish I had another 20-30 years to work just to see where this could lead.

    You could. Deming worked on papers and was to present one at 92.   

     

    Jerry Pournelle when he worked in the Aerospace industry said they hired people of lower intelligence to connect the wiring harnesses in airplanes since they could focus on this mind numbing work and were happy to do it. 

     

    I was at a conference at a state where a company interned high teachers vs students so the teachers would know what to teach and the importance of the students knowing communication skills.  The goal is educate locally not pay finders fees and bonuses for someone that's homesick no matter what the bonus is. 


  16. procedure TForm1.btnuseListUXClick(Sender: TObject);
    var
      trianglePts: TtrianglePts;    //           Tlist of <Points>
      trianglePtsExtended: TtrianglePts;
    begin
      trianglePts := TtrianglePts.Create;
      trianglePts.Add(point(20,20));
      trianglePts.Add(point(200,100));
      trianglePts.Add(point(200,20));
      trianglePts.Add(point(20,20));
      Canvas.Pen.Color  := clgreen;
      Canvas.Polyline(trianglePts.List);
    
      trianglePtsExtended := TtrianglePts.Create;
      trianglePtsExtended.AddRange(trianglePts.ToArray);
      trianglePtsExtended.insert(1,point(20,100));
      Canvas.Pen.Color  := clRed;
      Canvas.Polyline(trianglePtsExtended.toarray);
    
      trianglePtsExtended.Free;
      trianglePts.Free;
    end;

    forgot generic example.

      TtrianglePts = TList<TPoint>;

  17. type
      ToldschoolArray = TPointerList; // array of pointer
      TusesSetlengthinternallyArray = TList;
      TtrianglePts = TList<TPoint>;
    ...
        
    procedure TForm1.btnmakeArrayClick(Sender: TObject);
    var
      oldSchoolArray: ToldschoolArray;
      things: TusesSetlengthinternallyArray;
      I, X, Getby: Integer;
      viewI, viewM: Integer;
      pI: PInteger;
    const
      bestguess = 10;
    begin
      x := random(10)-4;
      things := TusesSetlengthinternallyArray.Create;
      things.Capacity := bestguess;
             // ^setting may increase speed when 10000 + coming
      Try
        for I := 0 to pred(bestguess+x) do
        begin
          new(pI);
          pI^ := I;
          things.Add(pI);
          //oldSchoolArray.add(pI); can't do this :(
        end;
    
        oldSchoolArray := Things.List; // I was wondering why they added .list
        ViewI := PInteger(Things.Last)^;  // guessing generics helped add this goody:)
        Getby := bestguess + X - 1;
        ViewM := PInteger(oldSchoolArray[Getby])^;
        caption := 'Easy:' + viewI.tostring + ' Hard:' + viewM.tostring;
      Finally
        for I := 0 to things.Count - 1 do dispose(things[I]);
        things.Destroy;
      End;

    Older School would be slice with oversized fixed array.    To avoid DynaArray use D3.    

×