Jump to content

Chris1701

Members
  • Content Count

    23
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Chris1701

    TStringgrid how to automatically set the column widths

    Thanks Remy, I found this code on an old StackOverflow thread so I didn't write it and was just trying to make it work. The change you suggested worked like a charm, thanks so much! Merry Christmas!
  2. I have a form with a TStringgrid that I'd like to be able to programmatically set the column widths based on the text lengths in the grid itself. I used Google to search and didn't find a whole lot but I did find someone who provided this: Procedure TEditSeriesForm.SetColumnFullWidth( Var Grid: TStringGrid; ACol: Integer); var I, Str_Width, Col_Width: Integer; begin { set the width of the defined column in a string grid to the width of the widest string } Str_Width:=0; Col_Width:=0; For i := 0 To Grid.RowCount - 1 do begin // get the pixel width of the complete string Col_Width := EditSeriesForm.Canvas.TextWidth(Grid.Cells[Acol,i]); // if its greater, then put it in str_width If col_width>str_width then str_width:=col_width; end; Grid.ColWidths[Acol] := col_width+5; // +5 for margins. adjust if neccesary End; The problem is that this line of code "Col_Width := EditSeriesForm.Canvas.TextWidth(Grid.Cells[Acol,i]);" generates an exception class $C0000005 with message 'C0000005 ACCESS_VIOLATION" so I have no idea why this doesn't work so does anyone know offhand what's wrong with this or have an alternate method for checking and setting the string grid column widths based on the length of the text values in each column?
  3. Chris1701

    Delphi 12 TADOConnection Provider not found?

    Sorry, I just gave up on this because no matter what I couldn't get it to work. I switched to Firebird V4 Embedded which seems to work fine. Thanks for trying to help.
  4. Chris1701

    Delphi 12 TADOConnection Provider not found?

    After I posted I did look at that and it does say MS Access database 64bit, I don't see any option to test a connection string?
  5. I'm in the process of rewriting a program that uses a simple Microsoft Access database which I access using TADOConnection the original program was like Delphi XE and 32bit and I'm now using Delphi 12 64bit. The problem that I'm having is that in the IDE if I check off the "Connected" it connects without an error but during runtime I get "EOleException with message Provider cannot be found. It may not be properly installed." Just an fyi I'm running Windows 11 Pro and I have Microsoft Office Pro 2019 x64 installed. The old version of this program still works without an error so I think it's pretty obvious that this is a problem with compiling to 64bit so I checked and downloaded and installed the Microsoft accessdatabaseengine_X64 installer but I'm still getting this error, so what do I need to do in order to resolve this problem? Thanks!
  6. Chris1701

    Delphi 12 Application showing two windows on the taskbar?

    The dpr file other than the usual uses is: begin Application.Initialize; Application.MainFormOnTaskbar := True; Application.CreateForm(TdmData, dmData); Application.CreateForm(TMainForm, MainForm); Application.Run; end. So no, I'm not setting Application.MainformOnTaskbar to false and I'm not doing anything to override the CreateParams method or CreateWnd.
  7. Chris1701

    Delphi 12 Application showing two windows on the taskbar?

    I'll see what I can do but this is the only project that I've migrated to Delphi 12 that has this problem, none of my other projects have this issue and I'm not sure why.
  8. Chris1701

    Delphi 12 Application showing two windows on the taskbar?

    This is not an MDI application, it's hard to get a screen capture while hovering the mouse over the taskbar icon but I don't believe a larger image will make a difference. This is a picture of the same program compiled and run under Delphi 11.3 and you can see that when you hover the mouse over the programs task bar icon you can see that there is only one program window compared to 12 where for some odd reason two program windows appear on the taskbar. When you hover the mouse over the taskbar icon on the V12 build and you see two Windows no matter which you click on you get the proper program window (on the desktop) showing the form with the proper caption i.e. "My Database application" and you can't bring up or maximize the window that doesn't have the forms caption but instead shows the executable name i.e. "MyDatabase.exe" as the caption.
  9. I have hundreds of various projects that I've created over the years, I just went to make changes to one that I haven't worked on for a few months and last time I worked on it was with Delphi 11.3 and now I'm compiling and running it in Delphi 12 and it's an x64 Vcl application. The problem that I'm having it that when I hover the mouse over the taskbar icon it shows two program windows (see picture) and when I hover the mouse over the left appearing window it shows me the proper program form and the form title is the correct caption for the applications main form but if I hover the mouse over the right window the caption of that form appears to be the executable name rather than the caption and if you click on it all that pops up is the left appearing and correct program window / form. None of the other applications that I've converted to Delphi 12 seem to have this problem and just on the off chance that it was a problem with the project, I closed the project and deleted the project files and recreated the project and the new project seems to have the same problem. Just to be sure this is a Delphi 12 problem I opened the project in Delphi 11.3 and when I run it I don't have this problem with two application windows appearing on the taskbar. Has anyone ever seen this in any program on Delphi 12?
  10. Chris1701

    Using Regex for file name matching?

    Thanks that's very helpful!
  11. I'm trying to figure out how to use regular expressions to test file names for matching results and the test program that I have is failing rather badly. It's basically a form with some labels / TEdits / a listbox and a button, so enter the pattern in the pattern tedit and enter the text in the text tedit and click the test button to see if it matches: procedure TMainForm.TestClick(Sender: TObject); begin If TRegEx.IsMatch( edText.Text, edPattern.Text ) Then lbData.Insert( 0, 'True' ) Else lbData.Insert( 0, 'False' ); end; For example if I enter "*.pas" in the edPattern edit and "myfiletest.pas" in edPattern and click Test the program throws an error "Project RegExpressText.exe raised exception class ERegularExpressionError with message 'Error in regular expression at offset 0: nothing to repeat'." So none of the things I see to try such as pattern "*mydata*.*" and text "thisismydata.csv" generate the same error however the preloaded test data Pattern "Er*" and text "Er S01 D01" does not cause and error and comes back True. What am I doing wrong here? Thanks!
  12. Chris1701

    Trap TFDConnection error on data module create etc?

    I unchecked both and checked compiled "Connected" and tried transferring the program to the tablet and that does fix the problem. Thanks so much, this was the most simple and straightforward fix for the issue.
  13. Chris1701

    Trap TFDConnection error on data module create etc?

    I'm not dismissing your approach out of hand and I see how that could work but I have maybe two dozen assorted query's that point to that connection. In the forms oncreate event I would then have to iterate through all TFDQuery's and populate the connection field after the creation of the TFDConnection. So I think that may be a little overkill for this instance, but I'm saving your post and code samples because I believe that I may have other projects where it would be very useful, thanks for taking the time to post!
  14. Chris1701

    Trap TFDConnection error on data module create etc?

    So if both of those are unchecked but the TFDConnection is checked when I build the executable will not have that Connected property checked on the data modules creation?
  15. So recently I had an issue that really drove me crazy and I'm trying to fix it so it doesn't happen again. Details: I have a Delphi VCL database application, I develop this on my desktop Windows 11 dev computer using the latest Delphi 11.3 Patch 1 and in that environment I connect to my Firebird 4 database server located on a dedicated Windows Server 2022 computer for the purpose of testing. The target for this program is a Windows 11 tablet where the Firebird server runs on the local machine. When the program runs normally in the OnCreate event of the data module the proper server settings are loaded into the TFDConnection and then the connection is opened. So when I build the application on my dev computer the TFDConnection obviously must not have Connected checked otherwise when the application is transferred to the target tablet and it's run I get a fatal error and the program exits. Recently while I was reviewing one or more TFDQuery's the IDE must have automatically checked the connected property of the TFDConnection so when the application was built then transferred and I went to use it, it was unusable and there was no way that I could figure out to fix the problem in the moment without going back to my office and opening the project in the IDE and unchecking the connected property, building and transferring the program again. So here's my question, if that happens again how can I trap the TFDConnection error so that the program can continue since once I'm in the program I can then manually set the connection options to what they are supposed to be and open the database and everything will work for that session? Now fyi I've tried several things but none of them seemed to work: First setup TFDConnection.OnError event to try and trap it; dropped a TApplicationEvents component on the Data Module form and tried to trap it using TApplicationEvents.OnException. So how can I trap that error? A second idea that crossed my mind, is there anyway in the IDE to script or to say somehow "On application build all TFDConnections.Connected should be unchecked?" so that the IDE unchecks those components before building? That would then make it unnecessary to add any error trapping code to the application.
×