[python-win32] Focus lost when switching windows
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Mar 6 10:35:40 CET 2009
The following program creates a FrameWnd with an
Edit control in it.
If I select some text in the control, then switch
to another window and back again, the Edit control
has lost the keyboard focus.
Normal Windows applications don't behave that way.
What do I have to do to get my controls to stay
focused?
#--------------------------------------------------------------
import os, win32con as wc, win32ui as ui, win32gui as gui
class Test(object):
def __init__(self):
frame = ui.CreateFrame()
self.frame = frame
frame.CreateWindow(None, "Test Focus",
wc.WS_CAPTION | wc.WS_SYSMENU, (100, 100, 300, 200))
frame.AttachObject(self)
edit = ui.CreateEdit()
edit.CreateWindow(wc.WS_VISIBLE, (10, 10, 90, 30),
frame, 1)
frame.ShowWindow()
def OnClose(self):
gui.PostQuitMessage(0)
test = Test()
app = ui.GetApp()
app.Run()
#--------------------------------------------------------------
--
Greg
More information about the python-win32
mailing list