def _CreateMainWindow(self, prev, settings, browser, rect):
# Creates a parent window that hosts the view window. This window
# gets the control notifications etc sent from the child.
style = win32con.WS_CHILD | win32con.WS_VISIBLE #
wclass_name = "ShellViewDemo_DefView"
# Register the Window class.
wc = win32gui.WNDCLASS()
wc.hInstance = win32gui.dllhandle
wc.lpszClassName = wclass_name
wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
try:
win32gui.RegisterClass(wc)
except win32gui.error as details:
# Should only happen when this module is reloaded
if details[0] != winerror.ERROR_CLASS_ALREADY_EXISTS:
raise
message_map = {
win32con.WM_DESTROY: self.OnDestroy,
win32con.WM_COMMAND: self.OnCommand,
win32con.WM_NOTIFY: self.OnNotify,
win32con.WM_CONTEXTMENU: self.OnContextMenu,
win32con.WM_SIZE: self.OnSize,
}
self.hwnd = win32gui.CreateWindow( wclass_name, "", style, \
rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1],
self.hwnd_parent, 0, win32gui.dllhandle, None)
win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)
print("View 's hwnd is", self.hwnd)
return self.hwnd
评论列表
文章目录