Dismiss Notice

REGISTRATION IS AFTER ADMIN ACTIVATION

DONATIONS WITH PAYPAL CLICK TO BUTTON

3 MONTHS VIP - 10$; 6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$

DONATIONS WITH Bitcoin Address:3NRs3CK3fhXifrNYxHEZKpETDd9vNLMsMD

Dismiss Notice
The registration is approved by the Administrator. It takes about 1 day to approve your registration
Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

News/Info How to Run Windows Explorer with a specified Bounds(Left-Top-Width-Hieght)

Discussion in 'News, Freeware, Open Source and Discussions' started by Bravesaw, Aug 27, 2018.

  1. Bravesaw
    Online

    Bravesaw DF Junior

    Ok Let Talk About this as it Never Donne before .....
    • First of All we have to use the ShellExecute by adding the unit ShellApi to the uses Clause and like this code we can call the windows Explorer :
    Code:
    ShellExecute(Application.Handle, nil, PWideChar('explorer.exe'), PWideChar(ImagesDir), nil, SW_SHOWNORMAL);

    where the variable
    Code:
     ImagesDir 
    is the directory of Images that I want to show by the Windows Explorer...

    or by using this Function here:
    Code:
      FUNCTION ExploreDirectory(CONST Dir : STRING) : BOOLEAN;
      BEGIN
        Result :=(ShellExecute(GetDesktopWindow,'open',PWideChar(Dir),'','',SW_SHOW)>32)
      END;
    • But How can I run the Windows Explorer beside my application at a specified Bounds, for exemple like this image here (where should i set the bounds of Windows Explorer before show up ) ?
    [​IMG]
    • Well it's so Easy .... when we open any File with windows Explorer (such as going to C:\ ) , the Windows Explorer has a specific saved window size that it opens with. So when you resize it, either horizontally and/or vertically, close it and re-open it again, it saves the size of the window,and the location within the Registry where this information is saved is this:
      On my system:
    • Code:
      HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell\WinPos1366x768x96(1).position
    where
    Code:
     position
    is (left, right, top or bottom), gives the position of the window border in pixels like this
    Code:
    96
    in the code above ...
    I assume the name of the key depends on the screen resolution like this Picture here :

    [​IMG]
    and the code will be like that:

    Code:
    .....
    
    const
       AMainKey = '\Software\Classes\Local
       Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell\';
    
    var
      FrmMain: TFrmMain;
      ImagesDir: string;
      AWinPos_left, AWinPos_Top,
      AWinPos_Right, AWinPos_Bottom: string;
    
    implementation
      Uses
        ShellApi, Registry;
      {$R *.dfm}
    
    procedure ExploreDir_With_Bounds(AFile_Dir: string;ALeft, ATop, AWidth, AHieght: DWORD);
      FUNCTION ExploreDirectory(CONST Dir : STRING) : BOOLEAN;
      BEGIN
        Result :=(ShellExecute(GetDesktopWindow,'open',PWideChar(Dir),'','',SW_SHOW)>32)
      END;
    var
      ListNames, ListPosition: TStringList;
      I, AScreen_Width, AScreen_Hieght, APixelPI: Integer;
      AWinPos_Uses: string;
    begin
      ListNames    := TStringList.Create;
      ListPosition := TStringList.Create;
      With TRegistry.Create Do
      Try
        RootKey := HKEY_CURRENT_USER;
        OpenKey(AMainKey,FALSE);
        GetValueNames(ListNames);
    
        AScreen_Width  := Screen.Width;
        AScreen_Hieght := Screen.Height;
        APixelPI := Screen.PixelsPerInch;
        AWinPos_Uses := 'WinPos'+AScreen_Width.ToString+'x'+AScreen_Hieght.ToString+'x'+APixelPI.ToString;
    
        for I := 0 to ListNames.Count - 1 do
        begin
          if Pos(AWinPos_Uses, ListNames) <> 0 then
          begin
            ListPosition.Add(ListNames);
          end;
        end;
    
        for I := 0 to ListPosition.Count - 1 do
        begin
          if (Pos('left', ListPosition) <> 0) then
          begin
            AWinPos_left := ListPosition;
            Lbl_Left.Caption := AWinPos_left;
            Continue;
          end else
          if (Pos('top', ListPosition) <> 0) then
          begin
            AWinPos_Top := ListPosition;
            Lbl_Top.Caption := AWinPos_Top;
            Continue;
          end else
          if (Pos('right', ListPosition) <> 0) then
          begin
            AWinPos_Right := ListPosition;
            Lbl_Right.Caption := AWinPos_Right;
            Continue;
          end else
          if (Pos('bottom', ListPosition) <> 0) then
          begin
            AWinPos_Bottom := ListPosition;
            Lbl_Bottom.Caption := AWinPos_Bottom;
          end;
        end;
    
        if (AWinPos_left <> '')and(AWinPos_Top <> '')and
          (AWinPos_Right <> '')and(AWinPos_Bottom <> '') then
        begin
          WriteInteger(AWinPos_left, ALeft);
          WriteInteger(AWinPos_Top, ATop);
          WriteInteger(AWinPos_Right, ALeft + AWidth);
          WriteInteger(AWinPos_Bottom, ATop + AHieght);
        end;
    
        CloseKey;
      Finally
        Free;
        ListNames.Free;
        ListPosition.Free;
      End;
    
      ExploreDirectory(AFile_Dir);
    end; 
    
    procedure TFrmMain.FormCreate(Sender: TObject);
    begin
      ImagesDir := TDirectory.GetParent(TDirectory.GetParent(ExtractFileDir(ParamStr(0))))+ '\My Images To Test';
    
      ExploreDir_With_Bounds(ImagesDir, (50 + Width)+10{Left}, 50{TOP},
                             Screen.Width - (Left + Width +20){width},
                             Screen.Height - 150{hieght});
    end;
    
    procedure TFrmMain.FormShow(Sender: TObject);
    begin
      Left := 0;
      Top  := (Screen.WorkAreaHeight div 2)-(Height div 2);
    end; 
    
    end.

    • Finally the Result will be like That:
    [​IMG]
    with best regards : BraveSaw ...;):)o_O
    the Full Code Example can be downloaded from here
    Hidden Content:
    **Hidden Content: You must click 'Like' before you can see the hidden data contained here.**
    ... i have add some extra codes within like how to drop Any Image inside the TImage Control and add the Progress Event ...:rolleyes: well Have a Nice Day o_O
     
    PHARMUTIL, Pichit and realist like this.

Share This Page

Laws
Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.
Donate Help To Us and Be VIP
DONATIONS WITH PAYPAL CLICK TO BUTTON
6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$
Social Block