Reputation: 8072
I try to start coding a MS apllication with python and failed from the start.
My specific question is about this error:
pywintypes.error: (1407, 'CreateWindowEx', 'Windowclass wasn't found.')
with this code:
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()
Yesterday I readed something about register the window but I cant find it anymore. I think there is the problem. Can someone help me out?
Also if someone reads this question and can give me some general hints, I would be glad. To descripe my current situation I try to follow this 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 I found wont help me to use ctypes only like in the example.
Upvotes: 1
Views: 277
Reputation: 178389
The error indicates the window class name string is not registered. "Root"
must be the name of a registered window class. See the CreateWindowsEx documentation:
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.
Upvotes: 1