Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7002669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:57:30+00:00 2026-05-27T20:57:30+00:00

Is it possible to make readonly source code (eg., .pas & .dfm) writable from

  • 0

Is it possible to make readonly source code (eg., .pas & .dfm) writable from within the Delphi IDE? The right click option to make files Readonly/Writable within the IDE doesn’t change the properties on the file system. Is there an IDE extension or similar that can achieve this?

A way to do this without having to integrate a source control system would be preferable. I am using Delphi XE and Delphi 6.

Thanks!

sse

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:57:30+00:00Added an answer on May 27, 2026 at 8:57 pm

    This is how I would do it.

    Create a new package which will be installed into the IDE at designtime. If you have an existing package handy then you could carry on using it. Make sure the package requires the designide package. You can do this in the project manager, or just by viewing the project source and adding designide to the requires clause.

    Now add the following unit to your package.

    unit MakeEditable;
    
    interface
    
    procedure Register;
    
    implementation
    
    uses
      Windows, SysUtils, Menus, ToolsAPI;
    
    type
      TMakeEditable = class(TObject)
      private
        FEditorServices: IOTAEditorServices;
        FFileMenu: TMenuItem;
        FMakeEditable: TMenuItem;
        function MenuItemWithCaptionLike(const Menu: TMenuItem; const DesiredCaption: string): TMenuItem;
        procedure MakeEditableClick(Sender: TObject);
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
    constructor TMakeEditable.Create;
    var
      Index: Integer;
      PreviousMenuItem: TMenuItem;
    begin
      inherited;
      FEditorServices := (BorlandIDEServices as IOTAEditorServices);
      FFileMenu := MenuItemWithCaptionLike((BorlandIDEServices as INTAServices40).MainMenu.Items, 'File');
      if Assigned(FFileMenu) then begin
        PreviousMenuItem := MenuItemWithCaptionLike(FFileMenu, 'Reopen');
        if Assigned(PreviousMenuItem) then begin
          Index := PreviousMenuItem.MenuIndex;
          if Index>=0 then begin
            FMakeEditable := TMenuItem.Create(FFileMenu);
            FMakeEditable.Caption := 'Ma&ke Editable';
            FMakeEditable.OnClick := MakeEditableClick;
            FFileMenu.Insert(Index, FMakeEditable);
          end;
        end;
      end;
    end;
    
    destructor TMakeEditable.Destroy;
    begin
      FMakeEditable.Free;
      inherited;
    end;
    
    function TMakeEditable.MenuItemWithCaptionLike(const Menu: TMenuItem; const DesiredCaption: string): TMenuItem;
    var
      i: Integer;
      Target, Found: string;
    begin
      Target := StringReplace(LowerCase(Trim(DesiredCaption)), '&', '', [rfReplaceAll, rfIgnoreCase]);
      for i := 0 to Menu.Count-1 do begin
        Result := Menu.Items[i];
        Found := StringReplace(LowerCase(Trim(Result.Caption)), '&', '', [rfReplaceAll, rfIgnoreCase]);
        if Pos(Target, Found)>0 then begin
          exit;
        end;
      end;
      Result := nil;
    end;
    
    procedure TMakeEditable.MakeEditableClick(Sender: TObject);
    
      procedure MakeFileEditable(const FileName: string);
      var
        Attributes: DWORD;
      begin
        Attributes := GetFileAttributes(PChar(FileName));
        SetFileAttributes(PChar(FileName), Attributes and not FILE_ATTRIBUTE_READONLY);
      end;
    
    var
      FileName: string;
      FileExt: string;
      LinkedFileName: string;
      EditBuffer: IOTAEditBuffer;
    
    begin
      EditBuffer := FEditorServices.TopBuffer;
      FileName := EditBuffer.FileName;
      if FileExists(FileName) then begin
        MakeFileEditable(FileName);
        EditBuffer.IsReadOnly := False;
    
        FileExt := ExtractFileExt(FileName);
        if SameText(FileExt,'.dfm') then begin
          LinkedFileName := ChangeFileExt(FileName, '.pas');
        end else if SameText(FileExt,'.pas') then begin
          LinkedFileName := ChangeFileExt(FileName, '.dfm');
        end else begin
          LinkedFileName := '';
        end;
        if (LinkedFileName<>'') and FileExists(LinkedFileName) then begin
          MakeFileEditable(LinkedFileName);
        end;
      end;
    end;
    
    var
      MakeEditableInstance: TMakeEditable;
    
    procedure Register;
    begin
      MakeEditableInstance := TMakeEditable.Create;
    end;
    
    initialization
    
    finalization
      MakeEditableInstance.Free;
    
    end.
    

    When you compile and install this package you will now have a new menu item on the File menu which both clears the read-only flag in the input buffer and makes the file writeable.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Make iPhone app paid version replace free version on install from app
Is it possible to make a POST request from Ruby with open-uri?
Possible Duplicate: What is the difference between const and readonly? So from what I
Is it possible make some handler that will do something when user shutdown computer
is possible to make own help message or attach own event on help option
How is it possible to make prototype methods in C#.Net? In JavaScript, I can
Is it possible to make a site with ASP.NET MVC Framework using .NET 2.0?
Is it possible to make it appear to a system that a key was
Is it possible to make such buttons ( http://img225.imageshack.us/img225/6452/buttonslw9.jpg ) using CSS? It should
Is it possible to make efficient queries that use the complete regular expression feature

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.