Jump to content

Pat Foley

Members
  • Content Count

    367
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Pat Foley

  1. Pat Foley

    Community edition form designer

    Almost. I use a custom Desktop that hides the side bars and messages across bottom. Just hide the side bars and save desktop. I named mine Startup layout since its used to add controls to the form and see more code when making a new application using <F12> to switch. A side effect is the object inspector gains height when invoked from flyout view or <F11> key. This is in 10.4.2. Above gives about same size view as a second view window.
  2. These fragments may help.. Jobs: Tlist<TProc>; .... for var job: TProc in Jobs do job(); //TProc(job); //parens help compiler and old VBers to know whats going on. Using dictionary allows using components directly may be of use. //source Remu Lebeau:) https://stackoverflow.com/questions/64145742/cannot-change-tedit-text-in-delphi TtextPair = Tpair<Tcomponent, Tcomponent>; .... Edits: TList<TtextPair>; tp: TtextPair; begin for tp in Edits do begin Edit := TEdit(tp.Key); dLabel := TLabel(tp.Value); var I: NativeInt; for I := 1 to Length(Edit.text) do if ((Edit.text[I] = ' ') and (I <> Edit.tag)) then begin dLabel.Transparent := False; dLabel.Color := clYellow; dLabel.caption := 'gap at pos ' + I.tostring; Edit.tag := I; break; end
  3. Pat Foley

    Code feedback

    The difference between a mathematician and an engineer is the engineer uses pictures. We use some very abstract concepts to solve efforts and flows using first principles and plot to chart when needed. Process control scheme for brewery or a sewage plant might be source of model to use. The rumen reticulated* could be reduced to flash tank, holding tank, settling tank with vents and reflux. The process variables are moved between tanks and then computed. The variables are made persistent by list of pointers loaded at runtime to use with procedures and save state and used in UI. The ash or minerals passing through helps decide if the stool is sinker or floater. *networked
  4. Pat Foley

    Code feedback

    procedure TEventBoss.moveMouse(AC: Tcontrol); const gravity =-9.8;//gravity wind = 17; //West wind derecho force buoyancy = 62; //lbs floated in firken of displaced snowmelt buoyancySteamAir = 18/28; //MW of water/Mw of Air assume water returns as hailStones; //:( XYtolerance = 6; var eX, //MouseXError eY, X, Y: integer;// nativeInt; vtX, vtY: integer;//terminal velocity newMousePT: TPoint; MainF : TControl; begin X := AC.CLientOrigin.X + AC.Width div 2; Y := AC.CLientOrigin.Y + AC.Height div 2; eX := round(0.4 * (x - mouse.CursorPos.X + wind)); eY := round(0.4 * (y - mouse.cursorPos.y - gravity)); vtX := 12 + sign(eX) * wind div 2; vtY := 8 + sign(eY) * trunc(-Gravity) div 2; eX := Min (abs (eX),vtX) * sign(eX); eY := Min (abs (eY),vtY) * sign(eY); newMousePT.X := mouse.CursorPos.x + eX; newMousePT.Y := Mouse.CursorPos.y + eY; mouse.CursorPos := newMousePT; If (abs(eX) + abs(eY)) < XYtolerance then // MN for XYtolerance; moveMousetoInstance := nil; if AC.parent = nil then MainF := AC else if AC.Parent.Parent = nil then MainF := AC.Parent else MainF := AC.Parent.Parent; // following adjusts for the ocean domain // form floats up after "submerging" into water if newMousePT.Y > Screen.Height - buoyancy * 3 then MainF.top := MainF.Top - abs(eY); // following adjusts for the troposphere domain // form floats on denser air if newMousePT.Y < Screen.DesktopTop + round(buoyancySteamAir * 350) then MainF.top := MainF.Top + abs(eY); // form in left ditch pull it out a little each timer event. if newMousePT.X < 0 then MainF.Left := MainF.Left + abs(eX); if newMousePT.X > screen.width then MainF.Left := MainF.Left - abs(eX); end; This code example shows code that moves the mouse to a component on a form when it is opened. When Y is small the form floats in air domain. When Y is big form floats in water domain The example shows how the errors eX and wY, caused by the influence of wind and gravity*, is solved by integrating the error correction over time into mouse path as it moves towards the control. When movemousetoInstance is nil the timer skips the call to movemouse in the timer routine. Chemical tensions could be modeled in your rumen domain. Further setting initial conditions and saved model state would be good allowing the model converge quickly. I thinking about the cruft, would the pH be locally lower with carbonic acid working on what's floating or is it floated by CO2 offgas? * Imaginary use of green energy to power the mouse.
  5. Pat Foley

    Code feedback

    The source needs documented as to the sources used for model. If source is based on work of researchers at Public Universities or use reverse engineered patented technology. The documentation helps when other company patents similar technology and puts first company out of business with a Patent suite. The value of program like this could be extended by including ear tag information on each cow which allow better documentation of the pharma given to each animal. Some farmers like the tag program but the packing houses do not. Hopefully a program like this could be used for public good and allow inspection of data by researchers. One example of good technology on dairy cows. The modern milker machine senses exactly when the cow milked out--over milking makes for an unhappy cow. When milk production decreased in an area, researchers found that a modern milker when powered by poorly grounded mains supply would shock the cow.
  6. Pat Foley

    EReadError "Property does not exist"

    Have you tried a search in Windows Explorer looking for mycontrol.dcu? check the filedatetime of dcu(s) found. Use Projects>build all Projects and see which one recompiles. Next open code window and click on mycontrol in uses cause to open it. then hover over the tab to see the file's path in the hint. Since you have mycontrol open put a breakpoint on Tmycontrol.create and see if it is called. For some reason I need to set Target "Release configuration - ... platform" search path then setting "Value from ""Release...xxx platforms"" needs to have all config path set for each config. directly setting Search path does not take
  7. Pat Foley

    FMX cross platform approach?

    How about using a ProjectGroup with multiple dpr/dprojs that share a code base. Just select the project to compile in upper righthand window. Also works when running second IDE. This works fairly well on the VCL side except need different Exe names and only one debug at a time. IDE will prompt when time/date by other IDE. I compiled to an Android and in another IDE compiled a VCL program in the group with the caveat the fmx VCL library didn't load. One Android Studio uses 3.5 gig-why not load a few lithe Delphi IDEs! Added able to load fmx library plus use <ctr> b keys to switch projects!
  8. Pat Foley

    StyleControls: how to single-click 2nd button?

    In this example the first click moves the focus to underlying form, then the button on the underlying form can be clicked. It would better to fix the "flow" of the program--have the dropdown drill in with a list selection or escape with a cancel button.
  9. Does that mean a push push and remember to pop pop when using Turbo C ? There was a way to connect the buss to a i/o breakout board using the parallel printer port after cutting a few diodes off... To bring it up to 486 spec here's this https://chapmanworld.com/2018/02/09/lockless-multi-threading-in-delphi/
  10. Pat Foley

    Simple FFT

    Here's a http://delphiforfun.org/programs/oscilloscope.htm program that reads audio from the sound card. The code uses a TP library. It compiles in Laz with a little work. 🙂
  11. Pat Foley

    Bookmarks dead?

    Where's the RestDebugger fit on your favorite additions to Delphi. Thanks for your DelphiCon presentation on it. We can only assume the Booksmarks are floating off shore on container ship... Hopefully they can unship and ship by Christmas. 🙂
  12. Pat Foley

    Delphi 11 Debug Inspector hangs

    showstopper on 10.4.2
  13. The previous code I posted was based on Marco's Sydney book comments about changing event assignments at runtime. I think the OP is wanting to use reference. Here is further example procedure TForm30.Button1Click(Sender: TObject); var A: Double; ptrA: PDouble; ptrB: PDouble; ppB: PDouble; pC: PDouble; F, pF: TForm; refF: Tform; begin new(ptrB); //http://rvelthuis.de/articles/articles-pointers.html ptrB^ := 2.02; //initialize value in new instance location ppB := ptrB; // second PDouble get address of first PDouble; Showmessage(ppB^.tostring); A:= 1.01; ptrA := @A; // PDouble given address of double named A showmessage(ptrA^.tostring); pC := ptrB; // Use reference to store pB value; ptrB^ := ptrA^; //overwrite pB with ptrA value ptrA^ := pC^; //overwrite ptrA data showmessage(ptrA^.tostring); // Delphi hides the explicit details of above in VCL // but accessing the properties of components can be done with above. F := TForm.create(self); pF := F; // pF is reference no create needed! pF.Caption := 'EZ PZ'; refF := pF; // refF is a reference refF.Show; Dispose(ptrB); //manual dispose //pF.free; commenting out allows new form each button click! end;
  14. what happen at runtime when we are declaring some Objects ? i mean exactly this Declaration : vObj_Instance: TClass_Type; does this Allocate something in Memory ? or system resources .... No it does not I think you want a reference. Here is example where several forms have created and they may have Comboboxes in them. We use screen to find the forms and component list to find a combobox for the demo. procedure TEventBoss.showComboBoxDropDowns; var I,C: integer; F: TForm; //Ctrl: TControl; //hint need learn about the child lists in here plus Parent prop!// ComboBox: TcomboBox; begin with Screen do begin // access the applications forms here for I := 0 to formCount - 1 do begin F := Forms; // point F to form instance for C := 0 to F.ComponentCount - 1 do if F.Components[C] is TCombobox then begin ComboBox := F.Components[C] as TcomboBox; F.Show; F.BringToFront; ComboBox.Show; The 'found' combo box instance is told to show //how? The ref has its address.// sleep(1200); caption := F.Name; ComboBox.Perform(CB_ShowdropDown,1,0); sleep(1200); ComboBox.Perform(CB_ShowdropDown,0,0); break; end; end; end; end;
  15. Pat Foley

    New Android does not launch

    Unsure about class segmentation error. To use the location demo on my phone I need to touch the (..)menu located in in the center of app title. Under 10.2 the menu was on the left. I would try one of the demos or a simple hello world program on the new device to learn what it likes.
  16. Pat Foley

    New Android does not launch

    Just a guess is the new phone setup for allowing debugging/connecting to PC.
  17. Pat Foley

    Is anybody but me using monitors with different scaling?

    I am running 17" 1920*1080 main and a 23"1920*1080 sec. since the 17" T550 laptop is smaller it's at 125. (running D10.4.2) Anyway using pbrush and alt-screen I took snapshots of your ASCII chart and it was reduced in size depending on monitor taken. I snapped a form in the different monitors and it "pasted" the same even though the form appears bigger on the bigger monitor. Shank when form scaled set to true. Grew when setting pixelsperinch to 120 was 96. Edit // Just dragging a form across monitors produces an interesting effect if Scaled := True. Hard to capture with alt-PrtScr. Using PrtScr key the image shows the form across the screens not adjusted for the dots per inch of the monitors. // end edit.
  18. Pat Foley

    Re-Index a PageControl.PageIndex

    You do not need to modify the PageIndex as Uwe mentions. Since you didn't change the tabIndex at that modification, the pagecontrol is giving out of synch results. Simply remove the for loop changing the pageIndex. Its wrong.
  19. You could say the same about clYellow, clMoneyGreen. By setting a couple of adjustable colors UserColorBrush: Tcolor; UsercolorPen: Tcolor; begin ColorDialog1.Options := [cdFullOpen,cdShowHelp]; if ColorDialog1.Execute then begin MachineColor:= ColorDialog1.Color; EngineSubModel[11]:= inttostr(MachineColor); //for saving loading adding these to a list to get a count.
  20. Pat Foley

    Prevent OnClick to be handled twice

    You could have single click event and assign all custom TUButtons onClick to it. This could stored in eventForm code. Somewhat like a DataModule Only we keep message handlers in there. Also panels to use as needed by setting panel parent property to different form. The DataModule would use the eventForm code for future events Say enable submit button when channel is on line and data fields all entered.
  21. Oops. sidetracked into Application.Run
  22. Pat Foley

    How to create a grid that looks like this

    I like the Tshape in VCL It surfaces the pen and brush for setting in Object inspector properties. Here's some simple drawing techniques. implementation {$R *.dfm} uses Vcl.Imaging.pngimage; var png: TPngImage; type TStarArray = array[0..10] of TPoint; var StarPoints: TStarArray; procedure drawStar(aImage: Timage; aPoint: TPoint; Ascale: single); begin var r: FixedInt := round(1 * ascale); var r12: FixedInt := round(0.45 * ascale); var tau: double := 2 * pi; for var I := Low(StarPoints) to High(StarPoints) do begin var rf: double; If odd(I) then rf:=r12 else rf := r; StarPoints[I].X := round(apoint.x + rf * SIN(tau * I/10)); StarPoints[I].Y := round(apoint.Y + rf * -COS(tau * I/10)); end; aImage.canvas.Brush.color := clred; aImage.canvas.polyGON(StarPoints); end; procedure drawStarBM(aBM: TCanvas; aPoint: TPoint; Ascale: single); begin var r: FixedInt := round(1 * ascale); var r12: FixedInt := round(0.45 * ascale); var tau: double := 2 * pi; for var I := Low(StarPoints) to High(StarPoints) do begin var rf: double; If odd(I) then rf:=r12 else rf := r; //SineCosine() StarPoints[I].X := round(apoint.x + rf * SIN(tau * I/10)); StarPoints[I].Y := round(apoint.Y + rf * -COS(tau * I/10)); end; aBM.Brush.color := clred; aBM.polygon(StarPoints); end; procedure TForm21.Button1Click(Sender: TObject); begin with // self. // PaintBox. Image1. // finally persistent and could be passed as an argument if refactored canvas do begin var s := 'Stars'; var Ycount := Height div 40; // var Xcount := Width div 80; var r: TRect; Brush.Color := clSilver; FillRect(ClientRect); for var Y := 0 to Ycount do for var X := 0 to Xcount do begin var Xa := 0 + round(X / Xcount * width); var Ya := 0 + round(Y / Ycount * Height); if ((Xa=0) and (Ya=0)) then continue; if((Xa=0) or (Ya=0)) then Brush.Color := clSkyBlue else Brush.Color := clYellow; r.SetLocation(Xa, Ya); r.width := 145; r.Height := 80; roundrect(TRect(r), 18, 8); Textout(Xa + 6, Ya + 6, s); if not ((Xa=0) or (Ya=0)) and (random(10)>7) then DrawStar(Image1,point(Xa + 65, Ya + 15), 11); end; //Image1.Picture.SaveToFile('blobs.bmp'); (*png := TPngImage.Create; png.Assign(Image1.Picture.Bitmap); png.SaveToFile('blobx.png'); *) // publish as html png later done end; end; // extended Tshape paint { TSuperShape } procedure TSuperShape.Paint; var w, h: integer; textSize: TSize; begin inherited; Brush.Color := clBtnFace; with Canvas do begin drawStarBM(Canvas,point(50,50),25); font.Size := -15; textSize := TextExtent(Moniker); w := (Width - textSize.cx) div 2; h := (Height - textSize.cy) div 2; TextOut(w,h,Moniker); end; end;
  23. Pat Foley

    DBGrid DrawColumnCell

    btnChangeS := TButton.Create(grid1);
  24. Not that's important or relevant , found this https://stackoverflow.com/questions/7090053/read-all-ini-file-values-with-getprivateprofilestringthis . Would be able to go back to D1 🙂 Wouldn't the subclass work since would still descend from TcustomIniFile?
×