JonRobertson
Members-
Content Count
278 -
Joined
-
Last visited
-
Days Won
6
Everything posted by JonRobertson
-
Not impossible. If the "system buttons" to minimize, maximize, and close the application are not important, set the form's BorderStyle property to bsNone in the Object Inspector. Note that the window will not be movable or sizable without some additional code. You could paint the caption bar yourself, although that is not trivial. See StackOverflow for one possible answer: Change the color of the applications title bar I suggest experimenting more with CustomTitleBar and TTitleBarPanel. Use TTitleBarPanel instead of TPanel for pnlTitlebar, then set CustomTitleBar.Control to your TTitleBarPanel. Unfortunately I don't have specific advice on property values for CustomTitleBar. But experimenting is a great way to learn. You could start a new VCL Project and experiment with an empty form.
-
I have not explored the CustomTitleBar parameter or TTitleBarPanel component until today. Columbo's project gave me an opportunity to do so. When using an image that spans the width of the window, it covers TTitleBarPanel CustomButtons. I suspect buttons would need to be painted in OnPaint and "clicking" them handled in an OnClick handler. But I am still exploring those options... However, moving the form using the mouse is possible by adding an OnMouseDown event handler to the Image1 component: procedure TfrmDino.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); const sc_DragMove = $F012; begin ReleaseCapture; Perform(wm_SysCommand, sc_DragMove, 0); end;
-
The easy way is via frmDino.BorderStyle. Forms.TFormBorderStyle Value Meaning bsDialog Not resizable; no minimize/maximize menu bsSingle Not resizable; minimize/maximize menu bsNone Not resizable; no visible border line bsSizeable Standard resizable border bsToolWindow like bsSingle but with a smaller caption bsSizeToolWin like bsSizeable with a smaller caption
-
The code below assigned ItemIndex + 1 to iSelect, then assigned lbxData.Items[iSelect] to selectedItem. In the source you posted, selectedItem is not used for anything. However, that assignment does result in a "List index out of bounds" error if you click on the last item in the list box. iSelect := lbxData.ItemIndex +1; //Get the item number of the slected item in the listbox. Add 1 because item list starts at zero (0). lboxNum := iSelect -1; selectedItem := lbxData.Items[iSelect]; This attached version builds the paths for the DB and images using Application.ExeName, as Remy suggested. It shows an alternate way of building the full path for both images. It still expects your database and image folders to be in the same folder as Dinobase_p.exe. Jon Dinobase_u.pas
-
That works if you always run it from the location where Delphi writes the .EXE. If you want it use it on another machine or give it to your friends, that doesn't work so well.
-
You have a misunderstanding of Delphi list controls. Nearly everything in Delphi is zero indexed. Strings (UnicodeString, AnsiString, etc) are a notable exception. iSelect := lbxData.ItemIndex +1; //Get the item number of the slected item in the listbox. Add 1 because item list starts at zero (0). You use iSelect to retrieve the selected item from lbxData: selectedItem := lbxData.Items[iSelect]; If the last item in the list is selected, an "Index out of bounds" error will occur. Since the "item list starts at zero", you need to use a zero-based index for lbxData.Items[]. I wanted to show how you can use the dataset's events to your advantage. I have attached a modified Dinobase_u.pas/.dfm that implements TFDTable.AfterScroll to eliminate duplicating code/work in other methods. Dinobase_u.zip
-
The first thing to change is to set conPLife.Connected to False before building the project. When Dinobase launches and loads your main form, it is attempting to immediately open the database connection because Connected is set to True at design-time. Setting Connected to True is very useful while you are developing, but it needs to be set to False before building a project that will run anywhere except on your development machine. This is a pain and there are ways to automate it. But that is a different post. ;) I would have expected removing the path in Params.Database to resolve the path issue. But I do not have experience with SQLite or FireDAC. If you are certain the database will always be in the same folder as the .EXE, the path can be adjusted before opening the database. Here is one approach, which I put at the top of FormCreate: procedure TfrmDino.FormCreate(Sender: TObject); //Form creation begin conPLife.Params.Database := IncludeTrailingPathDelimiter(TDirectory.GetCurrentDirectory) + conPLife.Params.Database; conPLife.Connected := True; tblPLife.Active := True; Note that System.IOUtils needs to be added to your uses clause to resolve the reference to TDirectory. This is still not ideal, but it works for your first project. An ideal solution would be to store the database and images in a folder intended for app data, such as TPath.GetPublicPath (typically C:\ProgramData). There are other folders that you could use. Through the years, Microsoft has changed gears on app data folders a few times. After that, I copied the dino_images and dino_size folders from your earlier zip to my project folder and was able to run your project, navigate the db, and see the images. I have a couple of quick suggestions from a brief look at your form's code. Your Exit button calls "self.Close". "self." is not needed here. There are times that it is useful for clarity, but not necessary. The btnExitClick method is a member of TfrmDino, so calling Close calls the Close method of TfrmDino. You declared sName, recno, and recnum as globals in the var section of the unit. You should get in the habit of declaring "form" related variables as members of the form, as private members when possible. (Although it seems recno and recnum are not currently needed.) private sName: String; Lastly, pay attention to warnings from the compiler: [dcc32 Warning] Dinobase_u.pas(126): W1036 Variable 'iSelect' might not have been initialized How should lbxDataClick "behave" if lbxData.ItemIndex is not greater than -1? Jon
-
Same for me. I suspect your code is still hardcoding the path to the database.
-
Take a look at the AfterScroll event of the dataset. If the code that loads an image is not already a separate function/procedure, move it to one. Then call that from the AfterScroll event. https://docwiki.embarcadero.com/Libraries/Sydney/en/Data.DB.TDataSet.AfterScroll
-
He meant don't use a modified TDBNavigator. You said at some point something about adding your own buttons. If the buttons provided by TDBNavigator provide the functionality you are wanting but you weren't able to get it to work as intended, that can be corrected. If you want additional buttons to provide functionality that is not built into TDBNavigator, that is a different story. For what you are doing, you should get the project working using single dataset component and a single datasource component. Based on your posts, it seems as though you may be using multiple datasets. I would use a separate dataset to load the picture. But that is easier to implement once the project works using a single dataset.
-
That code would add sName. But sName may be an empty string ('') at that point of code execution. Have you confirmed that sName contains a value when LoadFromFile is called? Have you set a breakpoint to examine sName before LoadFromFile is called? Or added a ShowMessage(sName) before calling LoadFromFile?
-
I was able to get his project working on my machine. I don't use SQLite either. So as a test I tried several combinations of character case on the table name and they all worked. Table names (and likely any object name) do not seem to be case sensitive. His project also works with the database connection and query assigned 100% in code, with zero design-time configuration.
-
His project was building to Project\Win32\Debug and dat2.sqlite was in the root Project folder.
-
Delphi 12: Install Packages inconsistency?
JonRobertson replied to PeterPanettone's topic in Delphi IDE and APIs
I disagree. No reason for the IDE to load packages if they won't be needed by my next action. My next action could be closing the IDE or loading a different project that also does not use all of the default packages. The only issue that occurs to me is if my next action was to create a new form, without loading or starting a project first. In that case, I may be confused why a package is not loaded that I would expect to be loaded. But I wouldn't want to change the design or code of a form without having a project loaded. There is a lot of IDE functionality unavailable in that scenario. -
Sure, because that is the path that you hardcoded to FDConnection1.Params.Database: Try this instead: FDConnection1.Params.Database := ExtractFilePath(Application.ExeName) + 'dat2.sqlite'; If ExtractFilePath is an undefined identifier, add SysUtils to the uses statement below the implementation keyword.
-
The easy way to test anything in programming is to intentionally break code. For example, in your SQLite project, change Database= to a file that you know does not exist. When I did that, I got a dialog saying "unable to open database file." Using the link you provided, I did that tutorial with the Employee.s3db database in Embarcadero's samples folder, and it worked as expected. And if I change the query to SELECT * from dat2, I get the same error you are (as I would expect with this database). Attached is my version of the tutorial project. Object names don't match the tutorial and I added output when no rows are returned. It attaches to a database named dat2.db in the same folder as the project. The screenshot you posted of the database & table did not have "data type" for each column. Are you sure you have completely created *and* saved the database? I used DB Browser for SQLite and there is a button to "Write Changes". My best guess is the database file that your Delphi project is opening does not have a table named dat2. Tutorial.zip
-
Good delphi learning sites for new team member
JonRobertson replied to mvanrijnen's topic in Tips / Blogs / Tutorials / Videos
I would not suggest jumping into the source of an IDE Expert. There are many open source repos that could be beneficial. Here are a few, and these are just github. Embarcadero GitHub - Project samples included with the past several versions of Delphi and some other interesting repos. Delphi topic on GitHub - Over 2,200 open source projects Edit: This may be useful: Coding Boot Camp 2022 -
Good delphi learning sites for new team member
JonRobertson replied to mvanrijnen's topic in Tips / Blogs / Tutorials / Videos
Search engines are your friend. Here is a small list. None of these offer structure like a training course or a classroom curriculum. But there are some worthwhile articles and videos. https://delphi.fandom.com/wiki/Delphi_Wiki https://www.delphibasics.co.uk/ Embarcadero YouTube LearnDelphi.tv Delphi Programming Tutorials Not free: Embarcadero Academy I personally prefer books. Shortly after I started using Delphi, my go to Delphi bibles were Mastering Delphi 2 and Delphi Developer's Handbook, both by Marco Cantu. Most everything in those books still apply, although they were written nearly 30 years ago. There are several good "current" Delphi books that would cover more recent language additions but may assume the reader already knows the basics. Coding in Delphi and More Coding in Delphi by Nick Hodges are good for the Delphi language itself. But check out other authors as well. There are a number of excellent books on Delphi by some great authors. -
Is that tutorial online? If so, please post a link.
-
That isn't the ConnectDB_u.dfm for the ConnectDB_u.pas that you posted above. The name of the form in that DFM is TForm1 and none of the components on your TfrmConnectDB form are in the DFM code you posted. It should look more like this: object frmConnectDB: TfrmConnectDB Left = 0 Top = 0 Caption = 'frmConnectDB' ClientHeight = 442 ClientWidth = 628 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Segoe UI' Font.Style = [] TextHeight = 15 object btnConnect: TButton Left = 280 Top = 232 Width = 75 Height = 25 Caption = 'btnConnect' TabOrder = 0 OnClick = btnConnectClick end object btnExecute: TButton Left = 280 Top = 312 Width = 75 Height = 25 Caption = 'btnExecute' TabOrder = 1 OnClick = btnExecuteClick end object memOutput: TMemo Left = 320 Top = 56 Width = 185 Height = 89 TabOrder = 2 end object SQLConnection1: TSQLConnection DriverName = 'Sqlite' Params.Strings = ( 'DriverUnit=Data.DbxSqlite' 'DriverPackageLoader=TDBXSqliteDriverLoader,DBXSqliteDriver280.bp' + 'l' 'MetaDataPackageLoader=TDBXSqliteMetaDataCommandFactory,DbxSqlite' + 'Driver280.bpl' 'FailIfMissing=True' 'Database=') Left = 304 Top = 384 end object SQLQuery1: TSQLQuery Params = <> Left = 416 Top = 296 end end
-
Open ConnectDB_u.dfm in Notepad, copy entire contents to the clipboard, and paste that in a reply to this post. I am curious how SQLQuery1 is configured in the form designer. Another approach is to select SQLQuery1 in the form designer, press ctrl-c to copy just that component to the clipboard, and post it. But there could be other helpful details in the entire DFM, such as how SQLConnection1 is configured.
-
Has anyone attempted to add VCL Styles support to TChromeTabs? In my search, I see Jerry Dodge asked the author on StackOverflow back in 2015, who responded he did not use VCL Styles and had no plans on adding the support. I can attempt to do it. I think most of the work would be in TCustomChromeTabs.DrawCanvas. Unfortunately, I have very little experience writing custom drawing/painting code and no experience implementing VCL Styles in a component. Can anyone recommend a book or online resource to get my feet wet?
-
VCL Styles support for TChromeTabs
JonRobertson replied to JonRobertson's topic in Delphi Third-Party
Thank you for the suggestion. I have looked at code by Ray, Chris Rolliston, and Rodrigo Ruz. My first attempt was a good learning experience. Now I need to start over and do it piece by piece. -
Favorite feature(s) of other editors that Delphi does not offer
JonRobertson replied to dummzeuch's topic in Delphi IDE and APIs
Except you don't run the Delphi IDE on any system. An IDE that is not cross-platform will have limited cross-platform capabilities. Going down that discussion is going off-topic, imo. That said, I agree that an editor having "front-end" capabilities is a good thing. And some of those may depend on integrating with backend services, such as a LSP server, which may or may not be on the local machine. -
Favorite feature(s) of other editors that Delphi does not offer
JonRobertson replied to dummzeuch's topic in Delphi IDE and APIs
Yes. I have a license for Pro Edition. I have been a user and fan of BC since version 1. But I do not care for the Delphi IDE integration. I use the Explorer integration and have TortoiseGit configured to use BC.