

PiedSoftware
Members-
Content Count
67 -
Joined
-
Last visited
Community Reputation
5 NeutralAbout PiedSoftware
- Birthday 02/01/1961
Technical Information
-
Delphi-Version
Delphi 10.4 Sydney
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
I tried this, which is similar to what you said, and it seemed to make no difference: procedure SetComboWidth(Combo: TComboBox); var width: integer; begin Combo.Canvas.Font := Combo.Font; //<<<<< width := MaxTextWidth(Combo.Canvas, Combo.Items) + 26; // Include arrow button if Combo.Style = csDropDown then inc(width, 8); Combo.Width := width; end{ SetComboWidth};
-
Hi I want to be able to expand a small modal dialog that offers the user just a combo box to the minimum size able to show all values in the dropdown list of a TComboBox. I wrote the following code to calculate the size required by the combobox: function MaxTextWidth(canvas: TCanvas; list: TStrings): integer; var s: string; begin result := 0; for s in list do result := Max(result, canvas.TextWidth(s)); end; procedure SetComboWidth(Combo: TComboBox); var width: integer; begin width := MaxTextWidth(Combo.Canvas, Combo.Items) + 26; // Include arrow button if Combo.Style = csDropDown then inc(width, 8); Combo.Width := width; end{ SetComboWidth}; It had the desired effect on my machine, a NUC box still on good ole' Windows 10. The users however on Windows 11 find that the calculated with is not enough. The longest values were clipped. I don't know if the OS is the problem. My machine doesn't let me update. Does this problem look familiar to anyone? -- Mark
-
How can you list all the datasources linked to a dataset?
PiedSoftware replied to PiedSoftware's topic in VCL
Rollo62: Yes, there is a way to see it like that. I can't think of another more theoretically pure place to put it, unless the datasources were all under some manager at the application level. But the fact is that both are declared in Data.DB, and TDataset already has a member variable of type FDataSources: TList<TDataSource> and property DataSource: TDataSource, used for setting indexes or something. -
How can you list all the datasources linked to a dataset?
PiedSoftware replied to PiedSoftware's topic in VCL
Done. https://embt.atlassian.net/servicedesk/customer/portal/1/RSS-3336 -
How can you list all the datasources linked to a dataset?
PiedSoftware replied to PiedSoftware's topic in VCL
I don't know if it has the right meaning though. And since in Delphi there can only be one helper, I would avoid that approach in case someone else had a better use for it. -
Ho to list all data-aware controls attached to a datasource
PiedSoftware replied to PiedSoftware's topic in VCL
Here is the code when reduced in size because it works: type TLocalDataSource = class(TDataSource); // Exposes protected property DataLinks function GetDataAwareList(ds: TDataSource): TArray<TControl>; var lds: TLocalDataSource absolute ds; link: TDataLink; fldLink: TFieldDataLink absolute link; begin result := []; for link in lds.DataLinks do begin // See, I told you if (link is TFieldDataLink) and (fldLink.Control is TControl) then begin result := result + [TControl(fldLink.Control)]; end; end; end{ GetDataAwareList}; -
Hi It seems like a natural thing to want: is there a way to get all the datasouces that have dataset = ADataset? Other than looping through the components property of the owner of course. I was looking at the code of TDataset. It even has a private member variable FDatasources: TList<TDatasource>, but it is not exposed. So close! TIA Mark
-
Ho to list all data-aware controls attached to a datasource
PiedSoftware replied to PiedSoftware's topic in VCL
Thanks for the thought, Uwe. I should have said I'm using Delphi 10.4. I tried this function: uses Vcl.DBCtrls, System.Generics.Collections, System.Classes; type TLocalDataSource = class(TDataSource); function GetDataAwareList(ds: TDataSource): TArray<TControl>; var lds: TLocalDataSource absolute ds; links: TList<TDataLink>; link: TDataLink; fldLink: TFieldDataLink; cmp: TComponent; begin result := []; links := lds.DataLinks; for link in links do begin if link is TFieldDataLink then begin fldLink := link as TFieldDataLink; cmp := fldLink.Control; if cmp is TControl then begin result := result + [TControl(cmp)]; end; end; end; end{ GetDataAwareList}; It keeps seizing in the middle there, no particular line, sometimes reading fldlink.Control, sometimes when adding it to the array. I've been hacking at that for a while, stretching it out with more local variables to make it finer grained, but it has never worked for me. I'll just have to go ahead with code that is aware of what controls it needs to manage. EDIT: It seems that it does actually work. It was the debugger that was freezing. When I don't single step through it, it works fine. -
Hi How can I get a list of all the data-aware controls whose datasource is one that is specified? I have googled and even consulted Claude, without success, but I thought there was a way. Any ideas?
-
I just used claude for a while. I asked it to write a function to return the number of bytes in a string. It generated code that looked right, but I didn't check the unicode specs to confirm. But it had an error. It use a for i := loop but in the loop had inc(i) which of course does not compile. But I just told it that that wouldn't work and it replaced it with a while loop. Also it responded well to my style specifications, like having all the reserved words in lower case. I haven't tried others. Maybe DeepLink will be worth a look. I hope that helps.
-
Delphi uses OneDrive. How can I make it use my local storage?
PiedSoftware replied to PiedSoftware's topic in Delphi IDE and APIs
I meant the only option for disconnecting that OneDrive offered. It didn't let me disconnect some directories by not others. -
Delphi uses OneDrive. How can I make it use my local storage?
PiedSoftware replied to PiedSoftware's topic in Delphi IDE and APIs
Thanks for clarifying that. I surfed around and disconnected OneDrive entirely. That was the only option. -
Delphi uses OneDrive. How can I make it use my local storage?
PiedSoftware posted a topic in Delphi IDE and APIs
I keep getting messages from OneDrive that it is close to full (4.5GB of 5GB), with of course an offer for me to purchase more. I went looking at at the folder and found that most of it (4.53 GB) is in C:\Users\Mark\OneDrive\Documents\Embarcadero\Studio Is there some process for making Delphi use some other folder for that and getting away from OneDrive? I'm concerned about the risk of corrupting my Delphi installation. Regards Mark -
How to refer to a single value from an enumerated type declared in a set type?
PiedSoftware posted a topic in RTL and Delphi Object Pascal
In Delphi in System.Class we have this declaration: TShiftState = set of (ssShift, ssAlt, ssCtrl, ssLeft, ssRight, ssMiddle, ssDouble, ssTouch, ssPen, ssCommand, ssHorizontal); Given that declaration, how can I declare a variable that will be just one of those values?- 7 replies
-
- pascal
- enumerate type
-
(and 1 more)
Tagged with:
-
Type inference in assignment but not comparison??
PiedSoftware replied to PiedSoftware's topic in RTL and Delphi Object Pascal
Thanks for thinking about it Dave. But ... It already knows the type of a to be an array, so a set interpretation is ruled out. And for arrays, nil and [] mean the same thing. That is why the assignment operator works. So, I think it is reasonable to expect the compile to test for equality with the same syntax.