Modifying the system menu
Tim Golden
mail at timgolden.me.uk
Wed Sep 17 04:17:30 EDT 2008
raj.indian.08 at gmail.com wrote:
> For (2) I wrote the following code for basic testing:
> hwnd = win32gui.GetForegroundWindow()
> hw = win32gui.GetSystemMenu(hwnd, False)
> if hw != None:
> win32gui.AppendMenu(hw,win32con.MF_SEPARATOR,0,'-');
>
> and it shows the following error: pywintypes.error: (1401,
> 'AppendMenu', 'Invalid menu handle.')
Works for me. The following adds a separator and the
string "Hello" to my (Console) window's system menu
<code>
import win32con
import win32gui
hwnd = win32gui.GetForegroundWindow ()
hmenu = win32gui.GetSystemMenu (hwnd, False)
win32gui.AppendMenu (hmenu, win32con.MF_SEPARATOR, 0, '')
win32gui.AppendMenu (hmenu, win32con.MF_STRING, 100, 'Hello')
</code>
TJG
More information about the Python-list
mailing list