Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For example, if I'll want to change to "Copy" string under "edit" menu on notepad.

What I have tried:

I am trying to do the following:
use enumWindowsProc (works well):
C++
BOOL CALLBACK enumWindowsProc(
    __in  HWND hWnd,
    __in  LPARAM lParam
) {
    int length = ::GetWindowTextLength(hWnd);
    if (0 == length) return TRUE;

    TCHAR* buffer;
    buffer = new TCHAR[length + 1];
    memset(buffer, 0, (length + 1) * sizeof(TCHAR));

    GetWindowText(hWnd, buffer, length + 1);
    wcout << buffer << endl;
    wstring s2(buffer);
    wstring s3(L"Notepad");
    std::string::size_type found = s2.find(s3);
    if (found != std::string::npos)
    {
        EnumChildWindows(hWnd, EnumChildProc, 0);
    }
    delete[] buffer;
    return TRUE;
}

and than use EnumChildProc (does not give the required behavior. I hoped to get a tree of controls):
C++
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
    int length = ::GetWindowTextLength(hwnd);
    if (0 == length) return TRUE;

    TCHAR* buffer;
    buffer = new TCHAR[length + 1];
    memset(buffer, 0, (length + 1) * sizeof(TCHAR));

    GetWindowText(hwnd, buffer, length + 1);
    OutputDebugString(buffer);
    OutputDebugString(L"\n");
    
    EnumChildWindows(hwnd, EnumChildProc, 0);

    delete[] buffer;
    return TRUE;
}
Posted
Updated 2-Sep-20 0:42am
v4

1 solution

You cannot change it easily as menus are held in the application resource section. It is possible to modify resource items, but should be done with care as it could easily make the application unusable.

See Adding, Deleting, and Replacing Resources - Win32 apps | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900