pywintypes.error: (1407, 'CreateWindowEx'..)
pywintypes.error: (1407, 'CreateWindowEx'..)
我尝试用 python 开始编写 MS 应用程序,但从一开始就失败了。
我的具体问题是关于这个错误:
pywintypes.error: (1407, 'CreateWindowEx', 'Windowclass wasn't found.')
使用此代码:
import ctypes
import win32api
import win32con as con
import win32gui as gui
class Window(object):
def __init__(self):
self.hwnd = gui.CreateWindowEx(0,
"Root",
"Python Window",
con.WS_OVERLAPPEDWINDOW,
con.CW_USEDEFAULT,
con.CW_USEDEFAULT,
con.CW_USEDEFAULT,
con.CW_USEDEFAULT,
0,
0,
0,
None)
gui.ShowWindow(self.hwnd, con.SW_SHOWDEFAULT)
Window()
昨天我读到一些关于注册 window 的内容,但我再也找不到了。我认为有问题。有人可以帮我吗?
另外,如果有人读到这个问题并能给我一些一般性的提示,我会很高兴。
为了描述我目前的情况,我尝试遵循这个 documentation of MS and try to get an idea of translating C code with python by this example. But Im unable to follow, since the best documentation of ctypes 我发现不会帮助我像示例中那样仅使用 ctypes。
该错误表明 window class 名称字符串未注册。 "Root"
必须是已注册 window class 的名称。请参阅 CreateWindowsEx 文档:
lpClassName
Type: LPCTSTR
A null-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero. If lpClassName is a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, provided that the module that registers the class is also the module that creates the window. The class name can also be any of the predefined system class names.
我尝试用 python 开始编写 MS 应用程序,但从一开始就失败了。
我的具体问题是关于这个错误:
pywintypes.error: (1407, 'CreateWindowEx', 'Windowclass wasn't found.')
使用此代码:
import ctypes
import win32api
import win32con as con
import win32gui as gui
class Window(object):
def __init__(self):
self.hwnd = gui.CreateWindowEx(0,
"Root",
"Python Window",
con.WS_OVERLAPPEDWINDOW,
con.CW_USEDEFAULT,
con.CW_USEDEFAULT,
con.CW_USEDEFAULT,
con.CW_USEDEFAULT,
0,
0,
0,
None)
gui.ShowWindow(self.hwnd, con.SW_SHOWDEFAULT)
Window()
昨天我读到一些关于注册 window 的内容,但我再也找不到了。我认为有问题。有人可以帮我吗?
另外,如果有人读到这个问题并能给我一些一般性的提示,我会很高兴。 为了描述我目前的情况,我尝试遵循这个 documentation of MS and try to get an idea of translating C code with python by this example. But Im unable to follow, since the best documentation of ctypes 我发现不会帮助我像示例中那样仅使用 ctypes。
该错误表明 window class 名称字符串未注册。 "Root"
必须是已注册 window class 的名称。请参阅 CreateWindowsEx 文档:
lpClassName
Type: LPCTSTR
A null-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero. If lpClassName is a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, provided that the module that registers the class is also the module that creates the window. The class name can also be any of the predefined system class names.