If using Visual Studio 2005, go ahead and create a project via....
Visual C++, Win32, Win32 Project
and let visual studio plug in all that code for you.
Plug in the function below, in which you probably need to create a prototype for and call it from somewhere in the program.
Note: That this blog chops of source code into the other line. Make sure to adjust accordingly...
void insertMenu(void)
{
HWND hWnd = FindWindow(_T("Solitaire"),_T("Solitaire"));
//getting a handle what that find window returns.
//I'm passing the Window Name and the Class Name of
//Solitaire
if(hWnd == NULL)
//checking if I did not receive a handle to SOL.
{
MessageBox(NULL, _T("Error getting handle to SOL"), _T("Error"), NULL);
exit (1);
}
HMENU hMenu = GetMenu(hWnd);
//Getting a handle to Sol Menu
HMENU hNewMenu = CreateMenu();
//Create an instance of a new menu item
AppendMenu(hMenu, MF_STRING MF_POPUP, (UINT_PTR)hNewMenu, _T("My Sol &Hack"));
//Append the main menu bar
AppendMenu(hNewMenu, MF_STRING, IDTEST, _T("&Test"));
//Append the submenu
DrawMenuBar(hWnd);
// Drawing the menu bar
}
Visual C++, Win32, Win32 Project
and let visual studio plug in all that code for you.
Plug in the function below, in which you probably need to create a prototype for and call it from somewhere in the program.
Note: That this blog chops of source code into the other line. Make sure to adjust accordingly...
void insertMenu(void)
{
HWND hWnd = FindWindow(_T("Solitaire"),_T("Solitaire"));
//getting a handle what that find window returns.
//I'm passing the Window Name and the Class Name of
//Solitaire
if(hWnd == NULL)
//checking if I did not receive a handle to SOL.
{
MessageBox(NULL, _T("Error getting handle to SOL"), _T("Error"), NULL);
exit (1);
}
HMENU hMenu = GetMenu(hWnd);
//Getting a handle to Sol Menu
HMENU hNewMenu = CreateMenu();
//Create an instance of a new menu item
AppendMenu(hMenu, MF_STRING MF_POPUP, (UINT_PTR)hNewMenu, _T("My Sol &Hack"));
//Append the main menu bar
AppendMenu(hNewMenu, MF_STRING, IDTEST, _T("&Test"));
//Append the submenu
DrawMenuBar(hWnd);
// Drawing the menu bar
}
You will also need to create a string reference to IDTEST, so that the compiler understands it.....
No comments:
Post a Comment