Good day,
I've been looking at the pywin32 coding, but feel stuck at implementing
correct approach on basics of window.
So far the basic is from an example that I found on internet.
The question is on how to start using WM_CREATE to define the basic layout
of window, for example splitter, buttons, boxes etc?
Any tips on how to strip C/C++ examples to more pywin32 like structures?
import win32gui
import win32con
class Window:
def window_proc(self, hwnd, msg, wparam, lparam):
match msg:
case win32con.WM_CREATE:
pass
case win32con.WM_CLOSE:
win32gui.DestroyWindow(hwnd)
case win32con.WM_DESTROY:
win32gui.PostQuitMessage(0)
return win32gui.DefWindowProc(hwnd, msg, wparam, lparam)
def create_window(self):
wc = win32gui.WNDCLASS()
wc.lpfnWndProc = self.window_proc
wc.lpszClassName = "PythonWindowClass"
wc.hbrBackground = win32gui.GetStockObject(win32con.WHITE_BRUSH)
wc.hCursor = win32gui.LoadCursor(None, win32con.IDC_ARROW)
class_atom = win32gui.RegisterClass(wc)
style = win32con.WS_OVERLAPPEDWINDOW | win32con.WS_CLIPCHILDREN
hwnd = win32gui.CreateWindow(
class_atom,
"Python Window",
style,
100, 100, 500, 400,
0, 0, 0, None
)
win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)
win32gui.UpdateWindow(hwnd)
message = win32gui.GetMessage(None, 0, 0)
while message[0]:
win32gui.TranslateMessage(message[1])
win32gui.DispatchMessage(message[1])
message = win32gui.GetMessage(None, 0, 0)
if __name__ == "__main__":
app = Window()
app.create_window()
With best regards,
JP
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32