Jump to content

Pat Foley

Members
  • Content Count

    418
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Pat Foley

  1. Pat Foley

    Can Control Elements have "EventHandlers"?

    1. form := GetParentForm(AControl); 2. example speedbutton click overridden to allow click to jump to control on another form. TpfJumper = class(TSpeedButton) private FgotoName: string; FgotoControl: TControl; procedure SetgotoControl(const Value: TControl); procedure SetgotoName(const Value: string); // procedure onclick; protected procedure Paint; override; public property gotoControl: TControl read FgotoControl write SetgotoControl; property gotoName: string read FgotoName write SetgotoName; published { Published declarations } procedure Click; override; end; 3. The events for the Control. Procedure TpfJumper.Paint; begin with Canvas do begin brush.Color := clMoneyGreen; Point(85,21),Point(17,0)]); polygon([Point(68,0),Point(68,7),Point(85,7),Point(85,34),Point(68,34),Point(68,41), Point(0,21),Point(68,0)]); end; end; procedure TpfJumper.click; begin inherited; gotoControl.Show; end; 4. In the designer you can assign several controls to one event. In the handler cast the sender as needed.
  2. Pat Foley

    "Death to WITH" in your Delphi Code

    How about qualified with. procedure TMyForm.UpdateInventoryItem(const NewQty: Integer); procedure &With(A: TDataModule; B: TTable; const NewQty: Integer); begin B.Edit; B.FieldByName('Qty').AsInteger := NewQty; B.Post; end; begin &With(dmStoreInventoryData, dmStoreInventoryData.tblUpdateItemForStore, NewQty); end;
  3. Pat Foley

    How do I return to the 'Constructor'??

    How about a second machine for the user. They can view old work flows to gain insight on the work flows they are working on presently. This second machine is simply left on so it doesn't need to download the "knowledge base" each time a user wants to know how a work flow was implemented last time. Since a second machine and screen is used you could charge additional license fees. If the user can get more done each day by running a second application on second machine it should pay off since first machine used for work orders and IT work done concurrently on second machine albeit losing their "knowledge base" view when backing up. In short, Historian functions adds a lot of overhead in bandwidth and screens!
  4. Pat Foley

    How do I return to the 'Constructor'??

    How about procedure TChangeForm.dostuff(inDBName, inDBTable, inTable: Variant) begin if not assigned(Changeform) then Changeform := Tchangeform.create(Application); // hookup up the incoming // end;
  5. Pat Foley

    Issue with dynamic panel creation

    Here's example of finger measure applied*. The example refactored your code into a mypanel. This code surfaces the numbers to aid in sizing. *finger measure ~ 13 mm grid layout size. I added a panel inside the ScrollBox unit Unit8; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.UITypes, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ToolWin, Vcl.ComCtrls, Vcl.ExtCtrls; type TmyPanel = class(TPanel) const // 96 dpi ~ 25.4 mm * 4 baseFinger = 96 div 2; baseFatFinger = 3 * 96 div 2; public TopOffset: Integer; Finger: Integer; class var UsedHeight: Integer; procedure Paint; override; procedure WMSIZE(var message: TWMSIZE); procedure SetUp(AParent: TWinControl; const AColor: TColor; const Offset: Integer; const AAlign: TAlign); end; TForm8 = class(TForm) ScrollBox1: TScrollBox; ToolBar1: TToolBar; Button3: TButton; Button4: TButton; Button1: TButton; Panel1: TPanel; procedure Button4Click(Sender: TObject); end; var Form8: TForm8; implementation {$R *.dfm} // Let's pass ScrollBox1 using ScrollBox in SetUp procedure parameter} //var // ScrollBox: TScrollBox; procedure TForm8.Button4Click(Sender: TObject); var panel : TmyPanel; TagNu: NativeInt; Prnt: TWinControl; Aln: TAlign; begin Prnt := panel1;//ScrollBox1; Aln := alTop;// alNone; panel := TmyPanel.Create(Self); TagNu := (Sender as TControl).Tag; Case Tagnu of 0: panel.SetUp(Prnt, clSkyBlue, 8, aln); 1: panel.SetUp(Prnt,clMoneyGreen, 4, aln); 2: panel.Setup(Prnt, clCream, 2, aln); End; end; { TmyPanel } // Note how only current numbers are used and top offset used for naming not used for scrolling! procedure TmyPanel.Paint; begin inherited; canvas.TextOut(10,10,format('%s class Top %d Rect.Top %d',[Name, UsedHeight, BoundsRect.Top])); end; procedure TmyPanel.SetUp(AParent: TWinControl; const AColor: TColor; const Offset: Integer; const AAlign: TAlign); begin Parent := AParent; self.Color := AColor; ParentBackground := False; // moved top to here to avoid firsttime flag // and when align = alNone sets panel top else // size the parent to fit with resize event finger := baseFinger; Top := UsedHeight + 2 * finger; Inc(UsedHeight, (Offset+1) * finger); TopOffset := UsedHeight; AParent.Height := TopOffset; Name := 'MyPanel'+'_'+ UsedHeight.ToString; Caption := '';//Name;// + ' ' + UseCount.ToString; Height := Offset * finger; Left := 2 * finger; Width := 200;//aParent.Width - 34 - Left; Align := AAlign; show; // if ScrollBox1.height > anOwner.Height div 2 then // begin // ScrollBox1.AutoSize := False; // ScrollBox1.Height := anOwner.Height div 2; // end; //e end; procedure TmyPanel.WMSIZE(var message: TWMSIZE); begin //Finger adjusted here finger := basefinger * {DPI/96} 1; end; end.
  6. Pat Foley

    Android - debugging

    If 12 acts up I been restarting it several times just to freshen the file caches MRU. A pinched network cable caused some issues last spring.
  7. Pat Foley

    Android - debugging

    Mm, What happens using F7 vs F9 key to run the program.
  8. Pat Foley

    Android - debugging

    Hey, Where's the blue dots I would check in project manager that debug is bolded. Pat
  9. Oops! Should stuck with mouseover events to allow a "Proper" FocusRect to be drawn when over the area or subtracted the Control's ClientOrigin.Y
  10. procedure TForm23.PaintBox1Click(Sender: TObject); begin if Mouse.CursorPos.Y > 100 then exit; end; procedure TForm23.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Y < 100 then dostuff end; Try an OnMouseOver event and perhaps a PtinRect for the cursor's xy position.
  11. Pat Foley

    'View as Text' command menu item?

    I usually use notepad++ when touching the dfms as text. But for viewing you could do the following. Select desired nest in design and copy. Open new Vcl form. Paste selected controls on edit form Adjust controls Paste adjusted controls back to source design window. Make new unit an inline or embedded frame to reduce nesting in source form? Lazarus leaves the text view up once viewed as text but not really useful most of the time.
  12. Pat Foley

    TTabControl and TabItems in android

    Tell they tabs Ok in IDE or XL spreadsheet viewed across a sizable monitor not for a phone! Set the tabvisible to False and use a Button captioned with '...' to show list that 'spins on touch'. show they the MultiviewDemo or TCardPanel for alternatives. Pat
  13. Pat Foley

    Unable to rename source file on save?

    Could it be that a 11.0 project was copied and renamed to a 11.2 project without changing the guid of new 11.2 project so Delphi 11.2 still looks at 11.0 project source history? Pat
  14. Assign the same mouse enter and mouse leave event for each of the controls in question. Looking at the .dfm as text we can see that the same mouse enter / leave event was manually set. object Rectangle1: TRectangle Position.X = 80.000000000000000000 Position.Y = 232.000000000000000000 Size.Width = 489.000000000000000000 Size.Height = 177.000000000000000000 Size.PlatformDefault = False OnMouseEnter = Panel1MouseEnter OnMouseLeave = Panel1MouseLeave object Button1: TButton Position.X = 128.000000000000000000 Position.Y = 74.000000000000000000 TabOrder = 2 Text = 'Button1' TextSettings.Trimming = None OnMouseEnter = Panel1MouseEnter OnMouseLeave = Panel1MouseLeave end object Button2: TButton Position.X = 352.000000000000000000 Position.Y = 70.000000000000000000 Size.Width = 89.000000000000000000 Size.Height = 27.000000000000000000 Size.PlatformDefault = False TabOrder = 1 Text = 'Button2' TextSettings.Trimming = None OnMouseEnter = Panel1MouseEnter OnMouseLeave = Panel1MouseLeave end end The following is assigned event. procedure TForm8.Panel1MouseEnter(Sender: TObject); begin Caption := 'Hovering over ' + TControl(Sender).name; Rectangle1.Fill.Color := TAlphaColorRec.Red; end; procedure TForm8.Panel1MouseLeave(Sender: TObject); begin Caption := 'Not hovering over ' + Rectangle1.Name; Rectangle1.Fill.Color := TAlphaColorRec.Green; end;
  15. Pat Foley

    F2047 Circular unit reference.

    Alternate way. Consider program schema to 'Broker' serving UI by listening to events In FMX you can use TControl where in VCL TWinControl usually needed. Meaning only deal with the components. The broker or server of Application sits in a Datamodule. This broker listens for User generated events and updates the Control UI in response. Also the broker updates the UI on timer events. Using java style to find controls ClassName 'TStringGrid' vs ClassType(TStringGrid) to find controls to assign the update. The FMX allows forms considered as TControls where in VCL screen.formname is used to find form needed. Stream in the forms dfm Controls change fixup~to bind the updates Need less timers Uwe's shows one cycle three deep on a project with 30 forms Alex's graph works well too.
  16. Pat Foley

    Looking for Coder in Gilbert, AZ

    For Gilbert AZ, I would visit the local maker spaces and visit with the people in each to find possible people looking for full time work. https://www.yelp.com/search?cflt=makerspaces&find_loc=Gilbert%2C+AZ The University down should have a space too. Crash one of their job fairs for students looking for work or contact their placement office for candidates. Plan B: Conduct training sessions at one of these spaces to roll your own enlightened employee.
  17. Pat Foley

    How to debug a Not Responding program element

    Another source is the source in Vcl.WinXCalendars.pas if your Delphi is new enough. Look at TBaseCalendarAnimation in how it updates on its timerevent.
  18. Pat Foley

    RAD Studio 12 Update 1 IDE Instability

    I had a path issue to my mycontrolLibrary. I fixed by making a hard path to it. Though this is on Windows and not ARM it still may useful. Is check if the IDE can "see" the namespaces in uses clause by hovering over them. If not try a syntax check or compile after manually loading unit not "seen" until the IDE shows the blue tag. After a few days the need to 'prime' the IDE went away and no more small empty blue tags.
  19. Pat Foley

    How to debug a Not Responding program element

    Pre-make may be a bad 'fork' 😞 Otherwise saving the treeview and and reloading the treeview could allow a game to be restarted at the level the game was when tree was saved. Rather than needing to play the game at lower levels each time starting the game. Loading the game saved at higher level would save the users time. Or does the menu already have this feature?
  20. Pat Foley

    How to debug a Not Responding program element

    One. Just load a pre made with TV.LoadFromFile(wellformedTV.txt) and hookup as needed. Two. Your onidle is missing the pausing and userpause Booleans used in other Lemmix repros. So a Pause can not exit the onidle event.
  21. Pat Foley

    How to debug a Not Responding program element

    What does the SetInfo do on the TV.onclick? I populate my treeview childnodes by finding all the menuitems at startup. Then assign the menuitems onclick to the TV. The TV then follows the menu settings. Emba has Space Rocks game on Getit. Jim M uses a list to animate the rocks as they created and destroyed. Treeview has savetofile and loadfromfile. How is the game paused? is it ctrl- C? In the future pause the game not the IDE, insert a breakpoint, and restart the game. The IDE will then pause at breakpoint.
  22. Pat Foley

    Access violation installing a component

    Also the 290 version should be given a new guid unless using the '280' source is wanted. A new interface needs a new guid.
  23. Pat Foley

    TTabControl OwnerDraw Styled

    I didn't know about tabcontrols. Just started styles last month. Here's my stab at it using 'Tabber' for the symbol of the TabControl Sender vs 'control' and an assignable TStylefont enum. procedure TForm7.TabControl1DrawTab(Tabber: TCustomTabControl; TabIndex: Integer; const Rect: TRect; Active: Boolean); var TabStr:String; Pt : TPoint; R: TRect; TabUnderMouse:Integer; JohnFontcolorStyle: TStyleFont; begin with Tabber do begin Pt := ScreenToClient(Mouse.CursorPos); TabUnderMouse := IndexOfTabAt(Pt.X, Pt.Y); // Setting default font color to normal JohnFontcolorStyle := sfTabTextActiveNormal; if (TabUnderMouse = TabIndex) and Active then JohnFontcolorStyle := sfTabTextActiveHot; if Active then JohnFontcolorStyle := sfTabTextActiveNormal; if TabUnderMouse = TabIndex then JohnFontcolorStyle := sfTabTextInActiveHot; with Canvas do begin R := Rect; Font.Color := TStyleManager.ActiveStyle.GetStyleFontColor (JohnFontcolorStyle); if TabIndex = 0 then Font.Style := [fsStrikeout]; TabStr := (Tabber as TTabControl).Tabs[TabIndex]; // ? Brush.Style := bsClear; DrawText(Handle, PChar(TabStr), Length(TabStr), R, DT_SINGLELINE or DT_VCENTER or DT_CENTER); end; end;
  24. Pat Foley

    Set form in read only mode

    Set the DB to read only in viewing mode to prevent inadvertent record changes. Have the user log in when updating a record.
  25. Pat Foley

    Insert/Repalce image in MS Word Document

    Inside of Word record a macro doing your steps. Then use the terms found in Word's macro source in your Delphi source.
×