Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help with GetMenu

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
The0neThe0nly
Expert Cheater
Reputation: 0

Joined: 08 Dec 2009
Posts: 119
Location: In a box

PostPosted: Wed Apr 25, 2012 8:26 pm    Post subject: Help with GetMenu Reply with quote

I want to use GetMenu to get the handle to a menu.

I want the handle to be shown in a message box.

I'm still learning C++ and I have everything running except I do not know how to get the getmenu's return value into my message box. How do I do this?

Code:

   GetMenu(hookWindow); // HookWindow is the HWND for a RichEdit
// I'm not sure if I am using GetMenu correctly. Please correct me if I am wrong.

   MessageBoxA(NULL, "Menu", "The GetMenu's return value goes here",0); // This message box already shows, I just need the return value to be in the text
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Apr 26, 2012 1:32 am    Post subject: Reply with quote

GetMenu:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms647640%28v=vs.85%29.aspx

The return is HMENU which is just a handle to the menu. A handle isn't really important data to show in a messagebox since it is not going to be the same always. At most, you would want to check if the return was null.

Code:

HMENU hMenu = GetMenu( hookWindow );
if( hMenu == NULL )
{
   // The handle has no menu..
}
else
{
   // A valid handle was returned.
}

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
661089799107
Expert Cheater
Reputation: 3

Joined: 25 Jan 2009
Posts: 186

PostPosted: Thu Apr 26, 2012 10:59 am    Post subject: Reply with quote

Code:

template <typename T>
std::string toString(T in)
{
   std::stringstream ss;

   ss << in;

   return ss.str();
}


Code:

MessageBoxA(0, "Menu", toString<HMENU>(GetMenu(hookWindow)).c_str(), 0);


Last edited by 661089799107 on Thu Apr 26, 2012 9:33 pm; edited 1 time in total
Back to top
View user's profile Send private message
The0neThe0nly
Expert Cheater
Reputation: 0

Joined: 08 Dec 2009
Posts: 119
Location: In a box

PostPosted: Thu Apr 26, 2012 8:25 pm    Post subject: Reply with quote

Bill87 wrote:
Code:

template <typename T>
std::string toString(T in)
{
   std::stringstream ss;

   ss << in;

   return ss.str();
}


Code:

MessageBoxA(0 "Menu", toString<HMENU>(GetMenu(hookWindow)).c_str(), 0);


It gave an error.
Code:
ss << in;

Code:
error C2297: '<<' : illegal, right operand has type 'HMENU '
Back to top
View user's profile Send private message
661089799107
Expert Cheater
Reputation: 3

Joined: 25 Jan 2009
Posts: 186

PostPosted: Thu Apr 26, 2012 9:30 pm    Post subject: Reply with quote

Make sure you are including everything you need.

Code:

#include <Windows.h>
#include <string>
#include <sstream>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites