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

  • SEARCH
  • Home
  • 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 7808963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:17:23+00:00 2026-06-02T03:17:23+00:00

Is there a simple/clever way to load the standard Windows TEdit menu into this

  • 0

Is there a simple/clever way to load the standard Windows TEdit menu into this TRichEdit?

I know that I could create a simple menu to simulate the TEdit menu for the simple operations like copy/paste etc. (Example), however I would also like to keep the more advanced menu options such as the unicode options, reading order, and to utilize the same localization strings.

Edit: I have found a possible lead (trying to figure it out as I’m not an MFC expert)…

  • 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-06-02T03:17:25+00:00Added an answer on June 2, 2026 at 3:17 am

    Based on the “possible lead” and a bit of MSDN, I came up with a possible solution.
    I’m still unable to resolve the reading order issue (and the unicode options). It seems that it works differently for RichEdit than for Edit, and simply setting or getting the WS_EX_RTLREADING flag does not work as excpected. Anyways, here is the code:

    procedure RichEditPopupMenu(re: TRichEdit);
    const
      IDM_UNDO   = WM_UNDO;
      IDM_CUT    = WM_CUT;
      IDM_COPY   = WM_COPY;
      IDM_PASTE  = WM_PASTE;
      IDM_DELETE = WM_CLEAR;
      IDM_SELALL = EM_SETSEL;
      IDM_RTL    = $8000; // WM_APP ?
    
      Enables: array[Boolean] of DWORD = (MF_DISABLED or MF_GRAYED, MF_ENABLED);
      Checks: array[Boolean] of DWORD = (MF_UNCHECKED, MF_CHECKED);
    var
      hUser32: HMODULE;
      hmnu, hmenuTrackPopup: HMENU;
      Cmd: DWORD;
      Flags: Cardinal;
      HasSelText: Boolean;
      FormHandle: HWND;
      // IsRTL: Boolean;
    begin
      hUser32 := LoadLibraryEx(user32, 0, LOAD_LIBRARY_AS_DATAFILE);
      if (hUser32 <> 0) then
      try
        hmnu := LoadMenu(hUser32, MAKEINTRESOURCE(1));
        if (hmnu <> 0) then
        try
          hmenuTrackPopup := GetSubMenu(hmnu, 0);
    
          HasSelText := Length(re.SelText) <> 0;
          EnableMenuItem(hmnu, IDM_UNDO,   Enables[re.CanUndo]);
          EnableMenuItem(hmnu, IDM_CUT,    Enables[HasSelText]);
          EnableMenuItem(hmnu, IDM_COPY,   Enables[HasSelText]);
          EnableMenuItem(hmnu, IDM_PASTE,  Enables[Clipboard.HasFormat(CF_TEXT)]);
          EnableMenuItem(hmnu, IDM_DELETE, Enables[HasSelText]);
          EnableMenuItem(hmnu, IDM_SELALL, Enables[Length(re.Text) <> 0]);
    
          // IsRTL := GetWindowLong(re.Handle, GWL_EXSTYLE) and WS_EX_RTLREADING <> 0;
          // EnableMenuItem(hmnu, IDM_RTL, Enables[True]);
          // CheckMenuItem(hmnu, IDM_RTL, Checks[IsRTL]);
    
          FormHandle := GetParentForm(re).Handle;
          Flags := TPM_LEFTALIGN or TPM_RIGHTBUTTON or TPM_NONOTIFY or TPM_RETURNCMD;
          Cmd := DWORD(TrackPopupMenu(hmenuTrackPopup, Flags,
            Mouse.CursorPos.X, Mouse.CursorPos.Y, 0, FormHandle, nil));
          if Cmd <> 0 then
          begin
            case Cmd of
              IDM_UNDO:   re.Undo;
              IDM_CUT:    re.CutToClipboard;
              IDM_COPY:   re.CopyToClipboard;
              IDM_PASTE:  re.PasteFromClipboard;
              IDM_DELETE: re.ClearSelection;
              IDM_SELALL: re.SelectAll;
              IDM_RTL:; // ?
            end;
          end;
        finally
          DestroyMenu(hmnu);
        end;
      finally
        FreeLibrary(hUser32);
      end;
    end;
    
    procedure TForm1.RichEditEx1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
    begin
      RichEditPopupMenu(TRichEdit(Sender));
      Handled := True;
    end;
    

    Any feedback would be nice 🙂

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

Sidebar

Related Questions

Simple query, possibly impossible but I know there are some clever people out there
Are there simple libraries out there (.NET and Java) that are able to validate
There is simple cipher that translates number to series of . ( ) In
Is there a simple way to detect collisions between 2 GL objects? e.g glutSolidCylinder
Is there a simple way of accessing the Jenkins API key (as described by
Is there a simple way to take a float value representing fractional hours and
Some time ago, I found a clever trick on stackoverflow that showed a way
Ok so I know there's other questions like this. But mine is a little
Is there a fast/simple way to calculate the frequency distribution of a .Net collection
There is simple JSON serialization module with name simplejson which easily serializes Python objects

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.