Jump to content

aehimself

Members
  • Content Count

    1028
  • Joined

  • Last visited

  • Days Won

    22

Posts posted by aehimself


  1. Hello,

     

    I am trying to "dim" a whole tabsheet so a notification can be clearly shown - blocking the sheet itself, but not blocking the main form. I guess I'd need an alpha blended panel or a semi-transparent bitmap drawn on a TImage... never really worked with imaging until now so I'm not sure about the terms. Other than the standard components I have Graphics32 installed; can this be achieved with a custom TPanel descendant or with Graphics32 somehow? I would like not to install any 3rd party component just for this if not needed.

     

    Worst case scenario I'll capture the tabsheet as a bitmap and draw it on a alClient panel with Canvas.Draw - which supports opacity.

     

    Using Delphi 10.4.2 if it matters.


  2. There is no portable version of Delphi available afaik, however I suppose if you copy all necessary files from a PC where you installed Delphi to an other, it might work.

    But, you have to read the EULA carefully though; I'm not sure if this kind of deployment is allowed.

     

    Why installing it is not an option? In my personal opinion a fresh reinstall is always cleaner, guaranteed to work than attempting to "force it to life".


  3. When I saw the release notes on 10.4.2 and read that TEdgeBrowser now works with the GA Edge, I got excited. I thought it means you have Windows 10 installed with Edge and it works. Well, unfortunately it's not the case, What it means is that you no longer need the Canary edition, you simply can download the runtime from Microsoft's website.

     

    In all cases, you need WebView2.dll. It can come from GetIt, or you can download and extract the .NuGet package from Microsoft. You'll find the DLL under build\native folder.

     

    Next, download the WebView2 Runtime. Evergreen is the easiest, it downloads and keeps a system wide runtime up-to-date. If you choose this, you are set and ready, everything should work.

     

    If you choose the fixed version, things will be a bit different, as you have to tell TEdgeBrowser where to look for the files. Extract the fixed version, and simply add

     

    EdgeBrowser1.BrowserExecutableFolder := 'C:\Users\user\Downloads\Microsoft.WebView2.FixedVersionRuntime.89.0.774.54.x86';

     

    before the .Navigate. All set, right?

     

    Nah. Embarcadero simply forgot about the TWebBrowser component, which can use Edge mode, but it does not publish this property - so normally it can only be used with Evergreen editions.

    Fortunately though, this can be fixed with the usual dirty hack:

    Type
     THackBrowser = Class(TWebBrowser);
    
    procedure TForm2.FormCreate(Sender: TObject);
    begin
    // EdgeBrowser1.BrowserExecutableFolder := 'C:\Users\user\Downloads\Microsoft.WebView2.FixedVersionRuntime.89.0.774.54.x86';
     THackBrowser(WebBrowser1).GetEdgeInterface.BrowserExecutableFolder := 'C:\Users\user\Downloads\Microsoft.WebView2.FixedVersionRuntime.89.0.774.54.x86';
     WebBrowser1.Navigate('https://www.whatismybrowser.com/');
    end;

    Now, you can give your users the freedom. If they decide to download the Edge Runtime, your application will use Edge engine. If not, it still works in IE11 mode. Just don't forget to set FEATURE_BROWSER_EMULATION in the registry 🙂

     

    Hope it helps others!

    • Like 2

  4. 3 hours ago, Fr0sT.Brutal said:

    Why do you think so?

     

    1 hour ago, Lars Fosdal said:

    Pretty simple but effective. Hasn't failed me yet. 

    I tried creating a batch file from within the service. It slept 5 seconds (so I can see the process start) called NET STOP, slept 5 seconds (giving time for the service to stop) and NET START. When I called this batch from within the service I remember seeing the process starting and ending when the service terminated. This is why I never used this method.

    As it works for others I am sure I did something wrong; unfortunately I don't have the code snipplet to debug now.

     

    @Lars Fosdal this looks promising, I'll make a dummy service app to test it 🙂


  5. 8 hours ago, amit said:

    Is there any other way to check whether there is no problem at all on the server side?     Please suggest.   Thank you.

    Well, I have 2 ideas. 1 - use the HTTP status codes. 200 means all fine, it was inserted. 500 means an error happened, transaction was rolled back, resend is needed from the client.

    If you can not control the status codes, you can add a "status check API". After a 200 OK for inserting the record, the client can query the inserted IDs for verification.

    If I understand the question completely, that is.

     

    But, I never really worked with stuff like this so take this with a grain of salt. I always liked to control everything, so when it was needed I launched my own webserver via ICS. That way I could set return codes, headers, session cookies, and even send detailed answers in any format whenever I wanted to.


  6. Thank you all for the replies guys but I don't want to hijack OP's topic. The methods here seem to be "hacky" (to crash the service and let Windows to restart it - it's a tricky approach I have to admit, though!) or already tried (creating a batch file to sleep for 5 seconds, and issue the NET TOP/START commands. Issue is, as parent program stops, it stops the child processes and therefore the batch file execution too).

     

    I was curious if there is a trick to restart a service from within the service itself without the need of a loader, maintenance service - an other executable in general. As it is not that important for me at the moment I'll just keep my eyes open to see if such method was unearthed already.


  7. On 2/23/2021 at 1:06 PM, Lars Fosdal said:

    Our services runs on domain controlled servers and are descendents from TService, but they must be configured to run with a specific AD user (i.e. not the default system user) that has the necessary rights to access it's own file, and to start and stop services to be able to upgrade themselves. 

    It's not related to the topic, but may I ask how you implemented the update mechanism? Without a "loader" (e.g. actual code is in a DLL, service only loads and executes the DLL,) I never managed to achieve this. I never figured out how to restart the service from within the service.


  8. On 2/27/2021 at 12:59 PM, amit said:

    I want to use them to construct the SQL to update record flag in SQL table.   The Bracket in the RetIDList will be romoved and finally the RetIDList will be '1,2,3,4,5'.   Then I will create Update SQL as 
     

    
      qry.SQL.clear;
      qry.SQL.add('Update Table1 Set Flag=0 where ID in ('+RetIDList+');'); 
      qry.ExecSql;

     

    Just two notices. If you will ever use Oracle and RetIDList will contain more than 1000 elements, the code will fail. I don't know if any other RDBMS has this limitation though.

    How trusted is the file? Taking a string value from somewhere and putting it in a SQL command exposes your application to injection attacks.

    • Like 2

  9. Can anyone who has 10.4.2 confirm (or just explain if I misundrestood) but TEdgeBrowser now works without the +200 MB download requirements if Windows has the Chromium-based Edge installed?

    New TEdgeBrowser Extensions

    The TEdgeBrowser VCL component introduced in 10.4 (a wrapper around the Windows 10 Chromium-based Edge WebView2 control) has been updated with support for the GA version of Microsoft's WebView2 control and its SDK. Besides better compatibility, the component now offers enhanced support for files cache management and the use of custom WebView2 versions.


  10. 1 minute ago, pyscripter said:

    In the SvgIconImageList demo case, the application was compiled with the Windows default style and the error occurs when you change the style at runtime.   I think that may be significant because it causes the controls to be recreated.

    This is interesting. I am also changing the style runtime, when the application starts. However at this stage the frame including the TreeView does not exist yet in my case so I'd say it's irrelevant.


  11. 2 minutes ago, balabuev said:

    I was not able to reproduce the issue. Tried with Form>PageControl>TabSheet>Frame>PageControl>TabSheet>TreeView.

    Can you upload simplified demo project?

    My issue is that I have 5-6 TreeViews in my application in different locations and only one seems to be affected. I don't know what is the difference, this is what I was attempting to debug in the first place. If I know more, I will be able to make a small test case.


  12. 2 minutes ago, pyscripter said:

    The bug is not related to frames.

    I had a guess about it, but since at me it is on a frame... but you are right, let me rephrase it to "moving Items.Clear to the owning component's BeforeDestruction event" to be more inclusive 🙂


  13. Hello all,

     

    I was trying to get my head around this for a while but I simply can not find the solution. In my project I have a frame which I create runtime on a TTabSheet. On this frame I have 2 TTreeView components. 1 is on the frame itself, the second one is on an inner tabsheet:

     

    image.thumb.png.d780d91d9793db104c89bfdcbe213fbb.png

     

    Now, if the TreeView on the TabSheet has ANY items created if the application has a VCL style active, those items will not be freed up. I put a breakpoint in TTreeNode.Destroy and I can confirm that those are ONLY being called for nodes in the other TreeView.

     

    I even put TreeView2.Items.Clear in the frame's destructor, but as Owner.HandleAllocated is false at that stage, deleting all nodes never happen. So I put a breakpoint in the frame destructor and TTreeNode.Destroy, and the thing I quickly realized is that the nodes of the first TreeView are being freed before the destructor, because of a window message (TVN_DELETEITEMA or TVN_DELETEITEMW). This is actually deleting the nodes in Vcl.ComCtrls.pas : 11910.

     

    But, this message is sent only to the TreeView on the frame, not to the one in the PageControl. Again, only when VCL styles are active.

     

    I will try to send this message manually in the destructor (or explicitly deleting all nodes...?) to see if it solves my issue, but it bugs me to hell that I don't know what is happening.

     

    If I'd know where this message is sent, I could investigate why it is sent to / received by one TreeView only.

    Anyone has any ideas?

     

     

    Edit: Manually trying to delete nodes will fail, as TreeView.Items.Count shows 0 at the destructor already.

     

    Edit-edit: I have an event on the frame itself which is being called BEFORE the .Free is called upon the owning tabseet. If I move TreeView2.Items.Clear in that handler, the memory leak disappears. I guess it's an other quirk of the VCL styles but I'd still like to know the reason...

    • Like 1

  14. 6 hours ago, M.Joos said:

    Specifically you would not want for the components to be recreated. Have a look at the TReader events, specifically TReader.OnCreateComponent

    I already started to experiment with the TReader component, unfortunately OnCreateComponent will only let me to use a different constructor other than the default. If the component is not created in the handler it will be created anyway.

    This thing is still a mess to me though... how do I specify WHERE the new components will be created...? As it needs a stream I need to get it from the executable - I guess it will be stored as a resource...?

    I'm only at the beginning. I'll find the answers soon enough.

     

    6 hours ago, Uwe Raabe said:

    What about creating a new form instance and adjust the components and properties in question from that?

    This is actually a really neat idea. As the TReader method will create the components anyway I suppose the memory usage will be close to equal anyway. As a huge bonus, I know how to create a new form instance 🙂

     

    3 hours ago, Stano said:

    A Tag can be used for this purpose. Unless it is used for something else.

    An other good idea. Tags are - unfortunately though - already in use in said project 😞

     

     

    I'll dig into the TReader a little bit so I'll have a basic understanding of how it works / what it does. It never hurts to know something, you never know when you'll need such a thing.

     

    Thank you all for your answers!


  15. Hello,

     

    I have a method that hides, rearranges and resizes components based on some conditions runtime. All is working fine, but the question eventually arrived: is is possible to "reset" everything to it's original (design time) state?

    Instead of creating a list of all changed components (and it's properties) I'm wondering if it's possible to re-read and re-apply the .DFM settings to a number of selected components?

     

    A list would be easier, but the DFM streaming seems to be the "professional" way to do it.

     

    I guess I'll need a TReader for that but I have absolutelly no idea how that works 🙂


  16. On 2/8/2021 at 3:49 PM, Anders Melander said:

    I don't care about the minor improvement in compile speed sharing DCUs can give me. I do care about the time that is wasted when I have to track down some obscure problem caused by using out of sync DCUs.

    Let's say I have aeSuperDuperUtilities.pas and I compile it to all platforms, all configs. Then I set my library / debug DCU path to the relevant output folders, browsing path to the source.

    If I make a change in said unit, I recompile it again with all platforms / configs.

     

    At the moment I cannot imagine a way how any of the compiled DCUs would get out of sync. Then again, most probably I never worked on as many, as complex projects as you did.

    Can you please give me a theoretical scenario / direct me to an article so I can learn more about this?


  17. 3 hours ago, Anders Melander said:

    Bad idea IMO.

    Sharing DCUs among projects only leads to problems in my experience. When I do a clean build I want everything built from scratch, with the options I have enabled at that time. I don't want the compiler to link in some old DCUs that were compiled with god knows what options.

    I did not really make components up until this point - maybe that's why I never faced an issue you are talking about. But if I'm not contributing to a component the practice of "download / update -> rebuild DCUs -> ??? -> profit" always worked for me.
    It seems being the end user has it's benefits sometimes 🙂


  18. So back to the original topic I went ahead and created the two packages based on the article @dummzeuch shared. I coped everything from the original package to this, changed the platform to Win64 and moved the parts what caused the compilation to fail to the design time package (Only design time editors and registration procedures). It worked 🙂

     

    I was finally able to build 64 bit DCUs but then I realized that my design time package contains only ~4-5 of the 20 components. A quick search showed that there are still at least 40 files with RegisterComponents call in my new runtime package, but it still compiles... is this normal? 🙂

×