Jump to content

Chris1701

Members
  • Content Count

    23
  • Joined

  • Last visited

Everything posted by Chris1701

  1. 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?
  2. 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!
  3. 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?
  4. 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!
  5. 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.
  6. 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?
  7. 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.
  8. 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.
  9. 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.
  10. 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!
  11. Chris1701

    Using Regex for file name matching?

    Thanks that's very helpful!
  12. 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.
  13. 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.
  14. 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!
  15. 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?
  16. Chris1701

    KSVC 7.0 rzCommon fatal error..

    I had the same problem and the best place to ask about Raize Component questions is always Ray Konopka's forums at his web site www.Raize.com, there is already a thread about this problem that he addressed and this is what he had to say: So you can try the fix he outlines and I'm sure if he says it works it will, sadly I uninstalled the components and was going to reinstall to see if that was the problem prior to reading this but Embarcadero has removed the Konopka Signature Controls from GetIt for the moment and I guess they will put it back when it's fixed.
  17. Chris1701

    Setting Scroll Bar Width problem

    I've been working on a Delphi VCL app mainly meant to be used on a Windows 10 tablet (running Win 10 x64 1909) that has no keyboard or mouse, it's generally been working really well but occasionally I'll do some debugging of non-UI code on my desktop development system and not too long ago I switched from an Intel system running Windows 8.1 to a AMD system running Windows 10 x64 1909, I'm also using Rad Studio 10.4.1 with the latest updates and patches. One of the problems that I initially had was that the default scrollbars were too small to use touch on in that I couldn't reliably scroll them with my fingertip, I had posted asking about this on the old Embarcadero Delphi forums and Peter Below said that there was no way to change just your programs scrollbar width but that he used a method that changed the default system scrollbar width and then set it back when exiting the program. This is the code he gave me that doubles the scrollbar width and then resets it: procedure TMainForm.SetScrollbarwidth; Var LTemp: TNonClientMetrics; begin ResetScrollBarsClick( Self ); FillChar(LTemp, sizeof(LTemp), 0); LTemp.cbSize := sizeof(LTemp); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(LTemp), @LTemp, 0); FOldScrollbarWidth := LTemp.iScrollWidth; LTemp.iScrollWidth := LTemp.iScrollWidth * 2; SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(LTemp), @LTemp, 0); end; procedure TMainForm.RestoreScrollbarWidth; var LTemp: TNonClientMetrics; begin If FOldScrollbarWidth <= 0 then Exit; FillChar(LTemp, sizeof(LTemp), 0); LTemp.cbSize := sizeof(LTemp); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(LTemp), @LTemp, 0); LTemp.iScrollWidth := FOldScrollbarWidth; SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(LTemp), @LTemp, 0); end; The problem that I'm suddenly having is that this works fine on the tablet (and used to work fine on my old Intel system with Windows 8.1) but on my desktop development machine when I get to the last line of code in SetScrollbarwidth "SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(LTemp), @LTemp, 0);" that line of code is executed (the scrollbar width doubles) the program seems to hang up there; the debugger says "Running" but it never exits back to the OnCreate procedure of the main form that called SetScrollbarwidth to the next line of code and no matter how much time I leave it running it never continues and Process Explorer says that it's using zero cpu time. I also created a small sample x32 application that has a form and a button that sets the default scrollbar width back to the default which seems to be 17 and it seems to have the exact same problem, the scrollbar width is set but it doesn't continue after that last line and gets stuck there. Anyone have any idea's why this is a problem on my desktop but not the tablet?
  18. Chris1701

    Setting Scroll Bar Width problem

    I couldn't get it to work with the Raize controls dbgrid so I had to switch to the Alpha Controls dbgrid and it worked fine so problem solved
  19. Chris1701

    Setting Scroll Bar Width problem

    I actually own Alpha Controls and have a lifetime license, I'll take a look into this too
  20. Chris1701

    Setting Scroll Bar Width problem

    I'll give it a try and get back to you.
  21. Chris1701

    Setting Scroll Bar Width problem

    Because that only allows me to scroll to the top or bottom and up or down one item at a time, with the expanded scroll bar I can scroll up or down a page at a time making navigation of the dbgrid much easier; if there's a way to create a button that scrolls the dataset or dbgrid by a page at a time up or down I haven't been able to find it. I suppose I could determine the number of lines in the dbgrid and then scroll up or down in a loop by that number but I vaguely recall trying something like that before using this double the scrollbar width method and there was some kind of problem with it I couldn't resolve.
  22. Chris1701

    Setting Scroll Bar Width problem

    Yeah but as I said it works fine on the Windows 10 tablet and it did work fine on my old i7-6850K Intel Windows 8.1 desktop but on my new Ryzen-3950X Windows 10 desktop the line of code that sets the width works but gets stuck on that last line of code and never exits from the procedure setting the scrollbar width so I can;t debug code on my desktop anymore which makes it real hard to fix problems.
  23. Chris1701

    Setting Scroll Bar Width problem

    Thanks for the idea's but I'm kind of an old time guy and I just don't have the knowledge to make my own components or descendants of existing components to replace this changing of the system default scrollbar width so that's kind of out for me. Just to give a few more details that perhaps I should have included, the main form of this VCL application uses a Raize Components TrzDBGrid now I could replace that component with any other dbgrid that does the same thing but it's a navigation problem that it's too hard to scroll or search in the dbgrid using touch when the scroll bar which I understand from Peter is a windows common control and there's no way in either the default dbgrid or any of the alternate dbgrid's I have access to (the SMComponents dbgrid or the Alpha Controls dbgrid) to make it replace the windows common control with an alternate scrollbar and as I said my skills just aren't up to creating my own dbgrid descendant or my own scrollbar. Btw Peter Below has been a VIP in the Delphi forums for more than 15 years and he's helped me out more times than I can count (and he's never steered me wrong) so I don't think he would have suggested something that was very problematic and in fact he said he's used this method for the same reason.
×