

Pat Foley
Members-
Content Count
437 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Pat Foley
-
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. 🙂
-
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. 🙂
-
showstopper on 10.4.2
-
Class Instance vs Object Instance
Pat Foley replied to bravesofts's topic in Algorithms, Data Structures and Class Design
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; -
Class Instance vs Object Instance
Pat Foley replied to bravesofts's topic in Algorithms, Data Structures and Class Design
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; -
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.
-
Just a guess is the new phone setup for allowing debugging/connecting to PC.
-
Is anybody but me using monitors with different scaling?
Pat Foley replied to dummzeuch's topic in GExperts
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. -
Re-Index a PageControl.PageIndex
Pat Foley replied to Henry Olive's topic in RTL and Delphi Object Pascal
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. -
is it possible to create an Enumeration Type at runtime ?
Pat Foley replied to bravesofts's topic in Algorithms, Data Structures and Class Design
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. -
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.
-
Why compiler allows this difference in declaration?
Pat Foley replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Oops. sidetracked into Application.Run -
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;
-
Why compiler allows this difference in declaration?
Pat Foley replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
-
btnChangeS := TButton.Create(grid1);
-
TCustomInifile.ReadSubSections in older Delphi versions
Pat Foley replied to dummzeuch's topic in RTL and Delphi Object Pascal
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? -
TCustomInifile.ReadSubSections in older Delphi versions
Pat Foley replied to dummzeuch's topic in RTL and Delphi Object Pascal
How about Type TdzIniFile = Class(TmemIniFile) {$if ver < 12} // procedure dealwithsubsections {$endif} TdzRegFile = Class(TRegIniFile) procedure dealwithsubsections Having two components would match better with their mem or reg business. Unsure if switch is usable or needed. -
Delphi Daily WTF / Antipattern / Stupid code thread
Pat Foley replied to Tommi Prami's topic in RTL and Delphi Object Pascal
Upgraded to D14.4.2 For EU End User input errors should provide helpful feedback. 'not enough data entry', 'too much data' masked tedits help Exceptions need to be surfaced! -
Hey, codebox </> selector just reappeared. Copying text from browser to IDE and back again to browser window did sometime to the browser edit window the day before 😞 So another question how to cancel a post before saving? Thanks
-
More info. procedure TpfEngine.AddScreenMenuitems; var tabpageCount: integer; // used in menuclick handler and tag business ScreenMenu: TMenuitem; begin menucount := 0; extendedTScount := 0; For tabPageCount:= 0 to ComponentCount - 1 do if Components[tabpageCount].ClassNameIs('TTabSheet')then if (Components[tabpageCount] as TTabSheet).TabVisible then begin inc(MenuCount); ScreenMenu:= TMenuItem.Create(self); ScreenMenu.caption:= (Components[tabPageCount]as TTabSheet).Caption; ScreenMenu.Tag:= tabPageCount; extendedTScount := ScreenMenu.Tag; ScreenMenu.onClick:= MenuScreenClick; // dirty patch if ScreenMenu.caption = 'Prime Mover' then begin ScreenMenu.Enabled := False; ScreenMenu.Bitmap.LoadFromResourceName(HInstance,'BITMAP_ST');//:= Image1.Picture.Bitmap; end; .... Screens.add(screenmenu) // Screens:TMenuItem end;
-
Menu.Break := mbBarbreak //mbbreak example ScreenMenu.Break := mbBarBreak; ScreenMenu.Enabled := False; // ScreenMenu.Bitmap:= Image1.Picture.Bitmap; ScreenMenu.Bitmap.LoadFromResourceName(HInstance,'BITMAP_3');
-
Delphi Daily WTF / Antipattern / Stupid code thread
Pat Foley replied to Tommi Prami's topic in RTL and Delphi Object Pascal
Concede. -
Delphi Daily WTF / Antipattern / Stupid code thread
Pat Foley replied to Tommi Prami's topic in RTL and Delphi Object Pascal
// lost editor code box somehow sorry. Fix up at top Result := False; once function BlankControl(EditControl: TObject; const EditMess: string; ShowErrorMsg: Boolean; MaxLen: Integer): Boolean; //fall back label gotoTrue spare procedure gotoTrue; begin Result := True; Exit; end; begin Result := false; if EditControl is TCustomEdit then if length(trim((EditControl as TCustomEdit).Text)) < MaxLen then gotoTrue; if EditControl is TComboBox then if length(trim((EditControl as TComboBox).Text)) < MaxLen then gotoTrue; if EditControl is TDBComboBox then if length(trim((EditControl as TDBComboBox).Text)) < MaxLen then gotoTrue; if EditControl is TDBRadioGroup then if ((EditControl as TDBRadioGroup).Value = '') then gotoTrue; if EditControl is TDBLookupComboBox then if ((EditControl as TDBLookupComboBox).Text = '') then gotoTrue; if EditControl is TDBCheckBox then if ((EditControl as TDBCheckBox).State = cbGrayed) then gotoTrue; //gotoTrue: //result := True; end; ... if BlankControl(EditControl, EditMess, false, ShowErrorMsg,0) then Showerror(EditControl, EditMess, false, ShowErrorMsg);// Move the spaghetti hidden in the goto sauce -
StrToFloat () all combinations of decimal separator and lang. settings
Pat Foley replied to bernhard_LA's topic in Algorithms, Data Structures and Class Design
numeric keypad shows . writes , -
subclass (extend) Tshape with Tmyshape = class(Tshape) protected procedure Paint; public Moniker: string; end ... { TmyShape } procedure TpatShape.Paint; var w, h: integer; textSize: TSize; begin inherited; Brush.Color := clBtnFace; with Canvas do begin font.Size := -15; textSize := TextExtent(Moniker); w := (Width - textSize.cx) div 2; h := (Height - textSize.cy) div 2; TextOut(w,h,Moniker); end; //At runtime create custom shapes setting their parent to a floatPanel