Currently I have a problem with the menu bar of the notepad, when I use Spy ++ I realize the only thing it only has is the Edit class and I can get the handle of the Edit class. So for the menu bar above what should I do to be able to manipulate it while the process is running ? Thanks you
Asked
Active
Viewed 117 times
0
-
That's odd, because when I use Spy++ on Notepad, I see a main application window with two child windows: `Edit` and `msctls_statusbar32`. Have you tried calling [GetMenu](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmenu) on the main application window? – paddy Apr 13 '21 at 03:28
-
@paddy I haven't used GetMenu yet? Why is GetMenu needed? Can you explain? – Anh Hào Trần Apr 13 '21 at 03:31
-
1I think it would be a good idea for you to learn how to write your own application containing a menu before you tackle the task of accessing and modifying another processes menus via hooks. – paddy Apr 13 '21 at 03:57
-
A window's menu bar is part of the window's non-client area. It's not a window class itself. It is attached in a call to [CreateWindowExW](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexw) through the `hMenu` parameter (for a non-child window). While you can call `GetMenu` on the associated window to get a handle to the menu, you cannot modify it from a thread other than the thread that owns the window. @pad The status bar is the control at the bottom that displays line and column information among others. It's unrelated to the menu. – IInspectable Apr 13 '21 at 04:29
-
I know. I did not claim that the status bar is related to the menu. My point was to refute the claim that notepad only contains one window, which is false. I then directed them to read up how to access any menu on the _application window_ which is basically what you're talking about. Regarding modifying the menu on the correct thread, that would appear to be no problem since the question is tagged as related to window hooks. – paddy Apr 13 '21 at 04:34
-
@IInspectable I have use Windbg debug notepad and i saw showsavedialogbox when i click "File->Open". and i checked https://learn.microsoft.com/en-us/windows/win32/dlgbox/open-and-save-as-dialog-boxes i think i find a problem, and now i just need find tech hook. – Anh Hào Trần Apr 13 '21 at 04:46
-
You can't operate its menu from outside the thread that owns the window. You only need to use spy++ to observe which messages will be triggered by clicking the menu, which may be what you need. – Zeus Apr 13 '21 at 05:36
-
@SongZhu-MSFT when i click menu i dont see anything.But with Windbg i saw that with CreateFileW. – Anh Hào Trần Apr 13 '21 at 05:47
-
Do you mean spy++ can't get the message? Maybe you can refer to: [Why do some windows not receive Windows messages](https://stackoverflow.com/questions/28789969/why-do-some-windows-not-receive-windows-messages) – Zeus Apr 13 '21 at 05:53
-
Sorry i cant get the message by Spy++(32 and 64 bit).i had checked (Notepad dont use hande menu). – Anh Hào Trần Apr 13 '21 at 06:08
-
Define what you mean by "manipulate". What are you trying to do? – David Heffernan Apr 13 '21 at 06:31
-
*"i think i find a problem"* - That's unreasonable. Notepad is an application that has seen more testing than virtually any other application. What specific problem do you think needs fixing? – IInspectable Apr 13 '21 at 07:02