Jump to content

PawelPepe

Members
  • Content Count

    34
  • Joined

  • Last visited

Posts posted by PawelPepe


  1. @David Schwartz

    Thank you for your comment. I have to say I don't know what you wanna tell me...

    Are you working for TMS Team? I almost bought it reading your post 😛

    But no - I am not gonna spend so much money for it. I was looking for freee stuff not because I think paying for code is bad - but because I don't have money! Simple.

    I am sure TMS did great job and it works fine.

     

    @Harry Bego

    Yup, but that will only upload the file onto server... with no direct link to download.

     

    @Angus Robertson

    Good to know! Will check ICS stuff.

     

    To sum up, I think you are right. The best way is to use some commercial product (option not for me right now).

    Thanks.

     


  2. Hi,

    I would like to ask you about some help with accessing Cloud Services like Dropbox / Google Drive / Microsoft One Drive.

    As far as I know, every Cloud gives access by some API.

     

    I want to be able to send a file (text file or Image file) into one of this services. Is that possible?

    I mean:

    1. User launches my application

    2. Loads an Image (for example bitmap.bmp)

    3. Chooses Cloud service provider

    4. Uploads file into cloud and generates download link

     

    I assume that user has full access to cloud service (has an account, password and all needed authorization data).

    Have any of you dealt with such an issue?

     

    Where can I find some help? Maybe some example code? Where to start?

     

    -Pawel

     


  3. @Remy Lebeau

     

    Yes, I will change it and create virtual CreateWnd() and DestroyWnd() methods (I read about it somwhere in StackOverFlow, I think).

     

    @Remy Lebeau @Kas Ob.

    I checked GetClipboardSequenceNumber(). Indeed, it is incremeneted when Clipboard change - but not in our situation, as Clipboard contents is not changing, only message is sent.

     

    EDIT: I see your answer, Remy - I think you may have right. Will have to test it more. If not, then will do some comparison.

     

    I will have to find some good way to compare last Clipboard Content and every next one. If it differs - make action - if not, ignore.

    Hmm, maybe I will write it into disk and calculate hash. 

    -Pawel


  4. @Brian Evans

    @Kas Ob.

     

    Thanks, good to know. Yes, I think I will have to think about some compare data system, to check if clipboard data really changed.

     

    @Attila Kovacs

    OK Captain!

     

    Here is a simple code that demonstrate the problem:

     

    unit Main_Form;
    
    interface
    
    uses ...;
    
    
    type
      TMainFrm = class(TForm)
      
      ...
      
      private
          procedure MESSAGE_WM_CLIPBOARDUPDATE(var Msg: TMessage); message WM_CLIPBOARDUPDATE;
              { Private declarations }
      public
        { Public declarations }
      end;
      
    implementation
    
    {$R *.dfm}
    
    uses ...;
    
    
    
    procedure TMainFrm.MESSAGE_WM_CLIPBOARDUPDATE(var Msg: TMessage);
    var
       Success : boolean;
       RetryCount : integer;
    begin
       Inherited;
       
       if ALLOW_WM_CLIPBOARDUPDATE = True then 
          begin
             RetryCount := 0;
             Success := False;
             while Success = False do
                begin
                   try
                      Success := True;
    
                      if (Clipboard.HasFormat(CF_PICTURE) OR Clipboard.HasFormat(CF_TEXT)) then
                         begin
    						// ACTION!!!!
    						// Unfortunatelly, this is fired even when clipboard content not change - but message is received
                         end;
    
                      except
                         on E: EClipboardException do
                            begin
                               Inc(RetryCount);
                               if RetryCount < 3 then
                                  begin
                                     Sleep(RetryCount * 100);
                                  end
                               else
                                  begin
                                     //raise Exception.Create('Cannot set clipboard after three attempts');
                                  end
                            end
                         else
                            begin
                               //raise;  // if not a clipboard problem then re-raise
                            end;
                   end;
                end;
          end;
    end;
    
    
    procedure TMainFrm.FormCreate(Sender: TObject);
    begin
       AddClipboardFormatListener(Handle);
    end;
    
    procedure TMainFrm.FormDestroy(Sender: TObject);
    begin
       RemoveClipboardFormatListener(Handle);
    end;

     

    -Pawel


  5. Hey,

    I have got a serious problem with detecting Windows Clipboard changes.

    I am trying to write simple application that detects clipboard changes and offers to user some actions.

     

    To make it work I capture the WM_CLIPBOARDUPDATE message (Of course, I first add listening options -> AddClipboardFormatListener(Handle); which I release when exiting the program -> RemoveClipboardFormatListener(Handle);).
    And it works. I respond when the clipboard has an image (Clipboard.HasFormat(CF_PICTURE)) or text (Clipboard.HasFormat(CF_TEXT)).

     

    BUT - apparently this message is sent when I run system services (even though the clipboard contents DO NOT CHANGE), e.g.
    Computer Management (compmgmt.msc)
    Event Viewer (eventvwr.msc)
    Performance Monitor (perfmon.msc)
    and probably other programs I don't know about. 


    Why!!!!?

     

    That is, it only happens when the clipboard has some content (if it is empty, nothing happens). If it has text or an image or anything else - my application receives a message about changing the contents of the clipboard (which is in fact the same - nothing changes). Why do these services send WM_CLIPBOARDUPDATE?
    Or in other words - what to do to ignore this specific situation (i.e. I receive the message, but I don't want to react - because nothing has changed in the clipboard).
    Somehow I don't see anything in the Clipboard implementation in Delphi that would help me...

     

    Thanks for any help,

    -Pawel


  6. I am hiding and reshowing Form2 on each message.


     

    Quote

     

    Application.ShowMainForm only affects the startup of Application.Run()

     

     

     

    You are right!

     

    Quote

    Also, hiding/showing the Application.Handle is only useful in this case if Application.MainFormOnTaskbar is false, which is not the default in modern Delphi projects.

    Again, you are right (I use default - Application.MainFormOnTaskbar := True).

     

     

    So, now it looks like this. Hiding:

       MainFrm.Hide;
    

    Showing:

       MainFrm.Show;
       Application.BringToFront();

     

     

     

    Unfortunatelly, nothing has changed. 

    Maybe I will prepare example test app to show what I have and what I want to achieve?

    I also tried to dynamically create Form2 and destroy it on each message (but I failed with my "animation" and modal window).

     

    -Pawel

     


  7. Hey,
    I am trying to write simple application that works with Windows Clipboard (capture Clipboard changes (WM_CLIPBOARDUPDATE) and do some actions.

    Application uses TTrayIcon component. So, I can hide main window in notification area.

    If user press Print Screen button or copy text into Clipboard my application do some actions. One of the features is to show user a message (with some description text, icon etc) when application is hidden in tray. I do not use TTrayIcon Balloon hint (it is not good for me). Instead, I created second form and display it when clipboard change its content.

     

    It works fine, when application main window is visible (on screen). I set some options in form OnShow event and do some animation (to slide from right screen corner) in OnActivate event. It is OK.

     

    When application main window is hidded there is a big problem! 
    What I do:
    Form2.Show; -> OnShow And OnActivate events are fired.
    BUT, if I show form2 again (second, third time), only OnShow event is fired - OnActivate event is not working! WHY?

     

    I hide mainform to Tray:

       Application.ShowMainForm := False;
       MainFrm.Hide;
       ShowWindow(Application.Handle, SW_HIDE);

     

    And I show it using:

       MainFrm.Show;
       Application.ShowMainForm := True;
       ShowWindow(Application.Handle, SW_SHOW);
       Application.BringToFront();


    -Pawel


  8. Hi,

    I got a problem with TListView and Data. It seems that I got memory leaks, because Data pointers are not released (if I understand it well).

    Let me show you what I do:

     

    Here is a simple TListView (LV_Data). I add few items to the list (Report Style) into 3 Columns.

     

    var
       i        : Integer;
       ListItem : TListItem;
       PObject  : PChar;
    
       for i := 0 to 3 do
          begin
             // Caption
             ListItem := AList.Items.Add;
             ListItem.Caption := 'My Caption' + '_' + Inttostr(i+1);
    
             // Language Name
             ListItem.SubItems.Add('Language' + '_' + Inttostr(i+1));
             // User Name
             ListItem.SubItems.Add('User Name' + '_' + Inttostr(i+1));
    
             // User Data Path
             PObject := StrAlloc(250);
             StrPCopy(PObject, 'PATH_TO_USER_DIRECTORY' + '_' + Inttostr(i+1));
             ListItem.Data := PObject;
          end;

     

    As you can see, I also add "hidden" data (in this example a path to directory, as string). I can use it in program, without displaying it to user in listview.

    I can read it in simple way (for examle, in ListView OnClick event:)

    var
    	sPath : string;
    
       if (LV_Data.Items.Count > 0) AND (LV_Data.ItemIndex <> -1) then
          begin
             sPath := StrPas(PChar(LV_Data.Items[LV_Data.ItemIndex].Data));
          end;

     

    Everything works very nice... but, when I close program, I see there are some memory leaks.

     

    ---------------------------
    Unexpected Memory Leak
    ---------------------------
    An unexpected memory leak has occurred. The unexpected small block leaks are:

    473 - 520 bytes: Unknown x 3

    ---------------------------
    OK   
    ---------------------------
     

     

    As far as I know, I have to free those List View Data bymyself. How to do this?

     

    procedure TMainFrm.LV_DataDeletion(Sender: TObject; Item: TListItem);
    begin
       if Item.Data <> nil then
          begin
             FreeMem(Item.Data);
             Item.Data := nil;
          end;
    end;

    Above code not working (why!?), got Invalid Pointer Operation.

     

    Could you please tell me how to free this data to avoid memory leak?

     

    Thank you in advance,

    -Pawel

     


  9. Yup, I am sure there are many different methods. I can not use any that need to pass login data (user name,password).

    It seems the one I have (unfortunatelly in c) is the simplest. 

     

    Ps: There is a simple way to do this without complication, just run explorer:

    ShellExecuteW(0, 'open', 'explorer.exe', PWideChar(AFileNameToRun), '', SW_SHOW);

    But, this can not send mail with default client... so the best is to run any app with normal user privileges.


  10. 2 hours ago, Der schöne Günther said:

    Just saying: Your source is just a copy from @Remy Lebeau's original post on https://stackoverflow.com/a/37949303

    @Der schöne Günther

    Did you read my post?

    No, my code is not a copy - this is C->Delphi translation. But, not working.

    I din't write original code! I made delphi code based on linked code. To be clear.

    -Pawel

     

    @DelphiUdIT

    Thanks, will check that out.


  11. Hi,

    Here is a problem. 
    I would like to run an application with normal user privileges from elevated process.
    My installer (elevated process) is written in Delphi. It launches some programs at the end of installation.
    Now, as Installer is elevated, lauched process is also elevated - we don't want this!

     

    The goal is to launch non-elevated process from elevated installer process. So:
    - Launch any application with normal user privileges
    - Launch default web browser with given webpage
    - Send email to given person (with protocol Sendto:)


    As far as I know it can be done using Windows Explorer process. I couldn't find any Delphi code for that in Internet 😞 I only found C- based.
    Here is one that suppose to work: https://www.appsloveworld.com/coding/delphi/48/createprocess-with-lower-privileges-than-the-caller

     

    Could you please try to convert it into Delphi?

     

    I tried, but without success (see below example).
    There are some problems with pointers (I tried to do pointers typecasting - it compiled, but with access violation)...

    For example: FindDesktopFolderView(IID_IShellView, spsv); --> FindDesktopFolderView(IID_IShellView, Pointer(spsv));
    I am sure, this is not a way I should do.

     

    Here is my code in simple project.
    Source: https://www.dropbox.com/s/6ndno59brgbn6l0/ExecAsUser.zip?dl=1

     


    Thanks in advance,
    -Pawel


  12. Hey,

    I would like to ask you guys for some help... I am using now Delphi Community Edition 11.3 with VCL Styles.

    I downloaded from GetIt Package Manager nice Windows 11 Dark Style (Windows11_Modern_Dark.vsf).

    I am trying to modify this to my taste... There are few problems...

     

    The question is:

    Why TLabel text (with font color = clWindowText) is painted with White color? I changed this color in Style file(*.vsf) into red (using Bitmap Style Designer)  (see the image).

     

    I know, I can disable styles for control (by removing seFont -> ExampleLabel.StyleElements :=  [seClient,seBorder] ) but I want to make it global, for all Tlabels controls (or any other using clWindowText).

    Is that a bug or am I doing something wrong? How to change controls text in vcl style?

    The style I am talking about uses White (#FFFFFF) color for text (I think it is to bright for Dark Mode, it should be something like #E7E9EA, for example)

     

    Hope, you can help.

    Thanks in advance.

     

    Styles.thumb.png.20f7c1a99abf8e8d577f3b65499e12af.png


  13. I need to make it clear.

    I could build any of my projects with Delphi Community Edition 10.4.2 before my environement broke. So it was legal and that was functional in free Delphi version.

    But, when I reinstalled Delphi CE (the same version) it saddenly do not let me use command line compiler! On the same license, the same delphi version and the same Windows installation.

    This is why I am asking what happended. This is why I requested Delphi CE 10.4.2 users (who can use command line compiler) to send me those file (dcc32.exe). How can it be illegal when Delphi CE is free (I do not sell my programs - it is my hobby). Btw, my dcc32270.dll library is 27.0.40680.4203

     

    -Pawel

×