-
Content Count
1082 -
Joined
-
Last visited
-
Days Won
23
Everything posted by aehimself
-
I read a tip here on DelphiPraxis back in 10.x that disabling the Welcome screen altogether greatly improves stability. Since then that's the first thing I do after a Delphi installation and the IDE is rock solid since then. You get an AV if you click on the Welcome screen settings in Options, but that's a sacrifice I'm willing to live with :)
-
I'm using this code for alternating colors: Procedure TDBGrid.DrawColumnCell(Const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); Var dataset: TDataSet; {$IFDEF HIDECOLLINESIFEMPTY} colline: Boolean; {$ENDIF} editcolor: TColor; hidefocus: Boolean; Begin dataset := Self.DataSource.DataSet; // This method is only being called on DATA cells, which only happens if there is a dataset connected. Therefore, no // need to perform an assigned check here. {$IFDEF HIDECOLLINESIFEMPTY} colline := True; {$ENDIF} hidefocus := Not (csDesigning In Self.ComponentState) And (gdSelected In State) And Not Self.Focused; If (dgMultiSelect In Self.Options) And (Self.SelectedRows.CurrentRowSelected) Then Begin End Else If dataset.IsEmpty Then Begin {$IFDEF HIDECOLLINESIFEMPTY} colline := False; {$ENDIF} editcolor := TStyleManager.ActiveStyle.GetStyleColor(scEdit); Self.Canvas.Brush.Color := editcolor; Self.Canvas.Font.Color := editcolor; End Else // This code imitates the highlight of the whole row even if RowSelect is disabled. Note that it needs MultiSelect to be enabled! // If Not (gdSelected In State) And grid.SelectedRows.CurrentRowSelected Then // grid.Canvas.Brush.Color := clHighLight // Else If (dataset.RecNo Mod 2 = 0) And ((State = []) Or hidefocus) Then Self.Canvas.Brush.Color := TStyleManager.ActiveStyle.GetStyleColor(scButtonDisabled) Else If (dataset.RecNo Mod 2 = 1) And hidefocus Then Self.Canvas.Brush.Color := TStyleManager.ActiveStyle.GetStyleColor(scEdit); If hidefocus Then Self.Canvas.Brush.Color := TStyleManager.ActiveStyle.GetStyleColor(scCategoryButtonsGradientBase); {$IFDEF HIDECOLLINESIFEMPTY} If HIDECOLLINESIFEMPTY And colline And Not (dgColLines In Self.Options) Then Self.Options := Self.Options + [dgColLines] Else If HIDECOLLINESIFEMPTY And Not colline And (dgColLines In Self.Options) Then Self.Options := Self.Options - [dgColLines]; {$ENDIF} inherited; Self.DefaultDrawColumnCell(Rect, DataCol, Column, State); End; Supports VCL styles and works fine for a couple of years now. I used the "lazy" technique. Save this as uDBGrid.pas, add is to the uses clause of your form and in the declaration change "grdMyDBGrid: TDBGrid;" to "grdMyDBGrid: uDBGrid.TDBGrid". Since the class name is the same no modification in the dfm is necessary. Drawback is, it only works runtime. And it's hacky.
-
should be simple: is computer on home network?
aehimself replied to bobD's topic in Network, Cloud and Web
I never personally used FireDac, but doesn't it have a configurable timeout property? If no, what you can do is to attempt to connect in a background thread. Use your local connection until DB connection succeeded then simply swap them out and sync changes. -
should be simple: is computer on home network?
aehimself replied to bobD's topic in Network, Cloud and Web
Why to have any additional checks then...? When you initiate a connection to a host name / fqdn, name resolution is done automatically by the DB client library. Just attempt a connection to your database server. If that fails for any reason, fall back to the local DB. -
should be simple: is computer on home network?
aehimself replied to bobD's topic in Network, Cloud and Web
This check will trigger on all networks, which are set to private which is probably not a desired behavior. While these will work, OP's solution will be a different design pattern. What if you put the code in a separate DLL, which you are not distributing; and lives only on your home dev PC? -
should be simple: is computer on home network?
aehimself replied to bobD's topic in Network, Cloud and Web
When you are trying to detect your home network, don't rely on a successful (reverse) DNS lookup. I usually ping my home router (using fqdn) but even better, attempt a connection to a well-known service. However I only use this method to decide if VPN should be fired up or not; it's better to set up your DNS properly so tools will work from inside and outside. If you are keen to go this way I found these two snipplets in my codebase: Function LookupHostName(inIP: String): String; Var host: PHostEnt; addr: Integer; dat: TWSAData; Begin Result := ''; WSAStartup($0101, dat); Try addr := inet_addr(PAnsiChar(AnsiString(inIP))); host := GetHostByAddr(@addr, 4, PF_INET); If host <> nil Then Result := String(host.h_name); Finally WSACleanup; End; End; This one was abandoned halfway as no variables seem to be declared: Write('Attempting to resolve ' + HostName + '...'); If WSAStartup($0101, wsdata) = 0 Then Try tmp := GetHostByName(PAnsiChar(HostName)); If tmp <> nil Then Begin tmpin.sin_addr.S_addr := LongInt(PLongInt(tmp^.h_addr_list^)^); IPAddress := inet_ntoa(tmpin.sin_addr); WriteLn(IPAddress); End; Finally WSACleanup; End; May I ask why your program needs to behave different from a specific network? There might be a better way than relying on simple checks, which might trigger in places you don't want them to. -
The basic ones (label, edit, memo, etc.) are self-explanatory. For the rest I'm usually creating an empty project, dropping one of the components on the form and start experimenting in what I can do with it.
-
Set StyleName for one single control, yet no style for the rest of the app
aehimself replied to CyberPeter's topic in VCL
I had one situation when VCL styles flickered a lot, and that was if they were on an anchored / aligned panel and the form was being resized. Setting .ParentBackround := False on the panel solved this though. -
In theory, you can use XP... I'd love to give it a spin and see if the latest Delphi runs fine or not :)
-
Windows 11 moved further away from privacy, prefers "innovation" noone asked for over functionality and requires way too much hardware just to sit on the desktop, doing nothing. I'm eyeing Windows 10 IoT Enterprise LTSC. Price is not that high and you get a fully functional and debloated WIndows 10, supported until 2035. Until then I hope a Delphi IDE will be released for Linux :)
-
Long story short - if you don't have to, don't. I am forced to use it at work and the only positive thing I can say about it is even XE7 runs on it without issues.
-
Build time affected with an updated component...
aehimself replied to Ian Branch's topic in General Help
Antivirus exclusion? If only specific bds.exe-s are set (not the whole Program Files\Embarcadero\Studio folder) your real time scanner can and will affect build times. -
I personally used MySQL for my projects and a bit of MsSQL server. I advise against FireBird and Oracle, my personal experience shows you'll have extra issues to keep an eye on. On Windows servers my suggestion is MsSQL, on Linux MariaDB. That way updates / patches are included in the regular process.
-
AppWatcher - Remote Application Management for Delphi Developers
aehimself replied to maumsti's topic in I made this
Unfortunately that is true. If the old version running, it will stay that way until it is closed. At least you can make sure that the new instances are the updated version :) -
AppWatcher - Remote Application Management for Delphi Developers
aehimself replied to maumsti's topic in I made this
I'm not sure because we are talking about a network share, but renaming the file and placing the new .exe (with the same name) might still work. A lot of us use this technique in updating our applications. -
AppWatcher - Remote Application Management for Delphi Developers
aehimself replied to maumsti's topic in I made this
With this I completely agree. Meaningful attacks (and their mitigation) are out of the scope of this project however (especially if we are somewhat "controlling" endpoints) we should do our part in cybersecurity :) -
AppWatcher - Remote Application Management for Delphi Developers
aehimself replied to maumsti's topic in I made this
Include some security. The first glance there's nothing stopping me from shutting down all your programs if I get into your network. Are you sure you need to keep a TCP connection up with each agent? UDP would be a lot more practical, plus you could do the discovery with a simple broadcasted message. -
Multithread and thread-safe TClientDataSet?
aehimself replied to snodev's topic in RTL and Delphi Object Pascal
The only benefit I see here is the usage of data aware controls. A Dataset descendant is never going to be as efficient in storage or manipulation as arrays are. Also keep in mind that you are doubling the resources used every time you are cloning a Dataset, which - by your own words - is already pretty large. To simplify/standardize I would create my custom data storage class with thread safe access and then look into DataBinding or writing my own helpers to display the data in this storage. If speed is not an issue you also can use an indexed TFileStream to cut back on memory requirements.- 5 replies
-
- delphi
- tclientdataset
-
(and 1 more)
Tagged with:
-
I'd strongly advise against UPX especially in production executables. I had my fair share of after-the-last-moment struggle because of it
-
It's "normal". The same happens in my home project which has 10-ish frames only. At least the fix is easy 🙂
-
Borland had a pascal "IDE" and compiler called Turbo Pascal - with that you could only develop console applications - as there was no Windows at that time yet. Delphi was born in reaction to this, this was it's magic as you could target the brand-new shiny platform. Delphi is and was always designed in the RAD fashion: events firing here and there and you react to these events - let it be a click of a button or the closing of a form. My opinion is this is why books start off with GUI applications. If you have an amphibious car, you'll mainly show it off on water as every other car can drive on the road already. An other thing is if you code in the RAD way you only have to write and maintain only a small portion of code as the majority is handled by the framework. You'll also have more sense of success (and therefore the will to continue to learn) as you can recreate a fully functional notepad clone with 10 lines of written code. These are just my 2 cents though but based on these it makes sense to introduce Delphi this way. And if this was (at least the part of) the reason I'd also advise to start this way. Throw some controls on the form, make them do something you fancy. With time, you'll eventually meet the necessity to separate UI and business logic but when you reach that point you probably will have enough expertise to create the backend.
-
You can add a message pump to any thread, VCL or not. If you need window messages, you can call AllocHwnd. Just because we are talking about console it doesn't mean these things do not work.
-
Hello all, I have an issue with some of our components in the application we support where an event handler simply disappears (gets unlinked, code stays in .pas) when a frame is opened. The main container is a frame which is the 3rd or 4th descendant of a simple TFrame (with 2-3 levels of visual inheritance included). The event handler is the OnDataChange event of a custom TDataSource descendant component. This frame has ~50 of these datasources, but only 2 are affected. No other datasources / frames have the same issue (which we have hundreds, if not thousands). When you open the file in Delphi, the tab indicator already shows that it is modified and can be saved. Upon saving the event handler is simply unlinked, leaving the actual code in the .pas file. Restoration is easy, just double-click the handler in object inspector so it gets linked back which you can save perfectly... until next time someone forgets to check the modifications and roll back the removals; which already happened at least 5 times in the past half a year. inherited frmCustom: TfrmCustom [...] object dtsMyDTS: TCustomDataSource [...] OnDataChange = dtsMyDTSDataChange <-- this line disappears [...] end [...] end I bet it will be some rare edge case but it already caused lots of headaches and it would be a blessing if it could be fixed. I am not able to share the sources as they are proprietary plus you'd need the whole custom component package as well to be able to open it 🙂 I'm simply looking for indicators, what I can try, what I can check to find the root cause. Anyone saw something like this? Cheers!
-
Long story short, the issue was in the custom component itself. Someone wanted to have a constant OnDataChange code to run every single time and - as TDataSource is an INSANELY bad component with no overridable methods whatsoever - this is how they solved it: TCustomDataSource = class(TDataSource) protected procedure Loaded; override; private FOnDataChangeDesigned: TDataChangeEvent; end; procedure TCustomDataSource.Loaded; begin inherited; FOnDataChangeDesigned := OnDataChange; OnDataChange := DataChangeDef; end; In the moment the component was successfully streamed (run- or design time) the event handler was "saved" and reset, only to be called from the internal method. But since it's a private method the Object Inspector could not access it, therefore clearing the event handler alltogether. Saving only wrote this inconsistent state back to the disk. And yes, it seems all of the TCustomDataSources were affected, the event handler just disappeared so long ago that noone seemed to realize it. After fixing it and relinking all DataChange events found in the entire application... it seems to be working properly now.
-
The datasource is on the last frame not on an ascendant (object dtsMyDTS instead of inherited dtsMyDTS). Inheritance only plays a role here if Delphi bugs out due to the long frame chain I think.