[Wnd-commit] wnd/wnd/controls/base control.py,1.3,1.4 dialog.py,1.1.1.1,1.2 methods.py,1.3,1.4 windo
Status: Alpha
Brought to you by:
jurner
|
From: jürgen u. <cer...@us...> - 2005-07-23 22:10:16
|
Update of /cvsroot/wnd/wnd/wnd/controls/base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26713/wnd/controls/base Modified Files: control.py dialog.py methods.py window.py Log Message: bit of this and a bit of that Index: control.py =================================================================== RCS file: /cvsroot/wnd/wnd/wnd/controls/base/control.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** control.py 2 Jul 2005 09:53:42 -0000 1.3 --- control.py 23 Jul 2005 22:10:05 -0000 1.4 *************** *** 9,13 **** NMHDR, UINT, ! DLGCODES,) from wnd import fwtypes as fw #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- 9,15 ---- NMHDR, UINT, ! DLGCODES, ! LOWORD, ! HIWORD) from wnd import fwtypes as fw #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *************** *** 26,30 **** self._base_debugger= None self._base_fMsgReflect= 1 ! # ...all the style parsing --- 28,33 ---- self._base_debugger= None self._base_fMsgReflect= 1 ! self._base_guid = None ! # ...all the style parsing *************** *** 94,100 **** result = self.onMESSAGE(hwnd, msg, wp, lp) if result !=None: return result ! #--------------------------------------------------- --- 97,128 ---- + result = self.onMESSAGE(hwnd, msg, wp, lp) + + # have to process here, coos default retval is 0 from childwindow handlers + if msg==fw.WND_WM_NOTIFY: + if wp== fw.WND_NM_GETGUID: + guid= self.GetGUID() + if guid: + fw.CopyData(self.Hwnd, lp, fw.WND_CD_GUID, guid, 1) + return 1 + return 0 + if result !=None: return result ! ! ! ! # copydata ------------------------------------------------------- ! ! elif msg== self.Msg.WM_COPYDATA: ! ! result = fw.HandleCopyData(hwnd, msg, wp, lp) ! if result == None: ! return 0 ! if HIWORD(result[0]): # reserved for framework, must be mislead ! return 0 ! if self.onMSG(hwnd, "copydata", wp, (result[0], result[1]))== False: ! return 0 ! return 1 #--------------------------------------------------- *************** *** 135,138 **** --- 163,172 ---- + + + + + + elif msg==self.Msg.WM_DROPFILES: pt=POINT() *************** *** 163,166 **** --- 197,207 ---- elif msg==self.Msg.WM_DESTROY: + + ID= user32.GetWindowLongA(self.Hwnd, -12) # GWL_ID + if ID: + try: + fw.ID.Recycle(ID) + except: pass + if self._base_dragAcceptFiles: shell32.DragAcceptFiles(self.Hwnd, 0) *************** *** 179,183 **** # default return self.DefWindowProc(hwnd, msg, wp, lp) ! --- 220,224 ---- # default return self.DefWindowProc(hwnd, msg, wp, lp) ! *************** *** 223,227 **** raise "invalid flag: %s" % i - self.Hwnd=hwnd self._base_style = [0, 0] # base/clientstyle --- 264,267 ---- *************** *** 233,242 **** self._base_debugger= None self._base_fMsgReflect= 1 ! ! # set the windowproc ! self._base_pWndProc= WNDPROC(self._base_WndProc) self._base_pOldWndProc = 0 ! if not 'nosubclass' in styles: # check if debugging is requested and set the windowproc dbglevel= 0 --- 273,288 ---- self._base_debugger= None self._base_fMsgReflect= 1 ! self._base_guid = None ! # set the windowproc ! self._base_pWndProc= 0 self._base_pOldWndProc = 0 ! if 'nosubclass' in styles: ! self._base_subclassable = False ! ! else: ! ## leaks for MDI childwindows if setup with 'nosubclass' ?? ! self._base_pWndProc= WNDPROC(self._base_WndProc) ! # check if debugging is requested and set the windowproc dbglevel= 0 *************** *** 245,249 **** self._base_debugger= fw.GetDebugger(dbglevel, self.Msg) - if 'subclass' in styles: self.Subclass() --- 291,294 ---- *************** *** 278,282 **** #WS_SYSMENU = 524288 #WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU ! control_styles.__dict__.update(fw.wnd_window_styles.__dict__) --- 323,327 ---- #WS_SYSMENU = 524288 #WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU ! control_styles.__dict__.update(fw.wnd_control_styles.__dict__) *************** *** 309,312 **** --- 354,358 ---- WM_WINDOWPOSCHANGING = 70 WM_WINDOWPOSCHANGED = 71 + WM_COPYDATA = 74 WM_NOTIFY = 78 WM_CONTEXTMENU = 123 Index: window.py =================================================================== RCS file: /cvsroot/wnd/wnd/wnd/controls/base/window.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** window.py 2 Jul 2005 09:53:42 -0000 1.3 --- window.py 23 Jul 2005 22:10:05 -0000 1.4 *************** *** 3,10 **** --- 3,12 ---- from wnd.wintypes import (user32, shell32, + kernel32, c_short, byref, addressof, pointer, + GetLastError, POINT, create_string_buffer, *************** *** 15,19 **** UINT, NMHDR, ! MINMAXINFO,) from wnd import fwtypes as fw --- 17,23 ---- UINT, NMHDR, ! MINMAXINFO, ! LOWORD, ! HIWORD) from wnd import fwtypes as fw *************** *** 74,77 **** --- 78,85 ---- + if fw.WND_GUIMAIN: + raise RuntimeError, "a GUI can only have one main window" + fw.WND_GUIMAIN = True + #self.Data= Data() *************** *** 82,89 **** self._base_dragAcceptFiles=False self._base_timers= [] self._base_fIsopen= False # WM_SIZE needs this, not notify the user # unless the gui is open self._base_debugger= None ! # styles iStyles = self.ParseStyles(styles) --- 90,101 ---- self._base_dragAcceptFiles=False self._base_timers= [] + self._base_hwndDlgMsg= 0 ## hwnd for wich 'IsDialogMsg' dispatches + self._base_fIsopen= False # WM_SIZE needs this, not notify the user # unless the gui is open self._base_debugger= None ! self._base_guid = None ! self._base_mutext_singleinst = None ! # styles iStyles = self.ParseStyles(styles) *************** *** 118,130 **** --- 130,152 ---- #ExitHandler._RegisterGuiExitFunc(user32.DestroyWindow, self.Hwnd) + self._base_hwndDlgMsg= self.Hwnd + + + #-------------------------------------------------------------------- def _base_WndProc(self, hwnd, msg, wp, lp): try: + #if msg==fw.WND_WM_NOTIFY: + # print 1 + # return 0 + if self._base_debugger: result= self._base_debugger.HandleMessage(hwnd, msg, wp, lp) if result: self.onMSG(hwnd, "debug", *result) + + result= fw.IsReflectMessage(hwnd, msg, wp, lp) if result != None: return result *************** *** 134,137 **** --- 156,161 ---- + + #------------------------------------------------------------------- if msg==43: # WM_DRAWITEM *************** *** 160,163 **** --- 184,189 ---- if self._base_dragAcceptFiles: shell32.DragAcceptFiles(self.Hwnd, 0) + if self._base_mutext_singleinst: + kernel32.CloseHandle(self._base_mutext_singleinst) return 0 *************** *** 314,320 **** ! #-------------------------------------------------------- ! # framework messages elif msg==fw.WND_WM_NOTIFY: if wp==fw.WND_NM_MENU: mnu= fw.WND_MENU.from_address(lp) --- 340,361 ---- ! # copydata ------------------------------------------------------- ! ! elif msg== self.Msg.WM_COPYDATA: ! ! result = fw.HandleCopyData(hwnd, msg, wp, lp) ! if result == None: ! return 0 ! if HIWORD(result[0]): # reserved for framework, must be mislead ! return 0 ! if self.onMSG(hwnd, "copydata", wp, (result[0], result[1]))== False: ! return 0 ! return 1 ! ! ! # framework messages ------------------------------------------------------- ! elif msg==fw.WND_WM_NOTIFY: + if wp==fw.WND_NM_MENU: mnu= fw.WND_MENU.from_address(lp) *************** *** 336,339 **** --- 377,400 ---- return 0 + elif wp== fw.WND_NM_DLGDISPATCH: + if lp: self._base_hwndDlgMsg = lp + else: self._base_hwndDlgMsg = self.Hwnd + + elif wp== fw.WND_NM_GETGUID: + guid= self.GetGUID() + if guid: + fw.CopyData(self.Hwnd, lp, fw.WND_CD_GUID, guid, 1) + return 1 + return 0 + + + elif wp== fw.WND_NM_ISMAINWINDOW: + return fw.WND_MSGRESULT_TRUE + + elif wp== fw.WND_NM_ISFWWINDOW: + return fw.WND_MSGRESULT_TRUE + + + elif wp==fw.WND_NM_EXCEPTION: nexc= fw.WND_EXCEPTION.from_address(lp) *************** *** 422,425 **** --- 483,487 ---- user32.TranslateAcceleratorA) msg = MSG() + pMsg = pointer(msg) if self.GetStyleL('basestyle') & self.Style.WS_BASE_DIALOGLIKE: *************** *** 435,439 **** _exit.Unregister(self.Hwnd) while GM( pMsg, 0, 0, 0) > 0: ! if not IsDialogMessage(self.Hwnd, pMsg): if self._base_hAccelerator: if not TACC(self.Hwnd, self._base_hAccelerator, pMsg): --- 497,501 ---- _exit.Unregister(self.Hwnd) while GM( pMsg, 0, 0, 0) > 0: ! if not IsDialogMessage(self._base_hwndDlgMsg, pMsg): if self._base_hAccelerator: if not TACC(self.Hwnd, self._base_hAccelerator, pMsg): *************** *** 442,445 **** --- 504,509 ---- TM(pMsg) DM(pMsg) + + else: self.onMSG(self.Hwnd, "open", 0, 0) Index: methods.py =================================================================== RCS file: /cvsroot/wnd/wnd/wnd/controls/base/methods.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** methods.py 2 Jul 2005 09:53:42 -0000 1.3 --- methods.py 23 Jul 2005 22:10:05 -0000 1.4 *************** *** 1,4 **** - import gc from wnd import fwtypes as fw --- 1,3 ---- *************** *** 6,9 **** --- 5,9 ---- gdi32, shell32, + kernel32, addressof, byref, *************** *** 17,20 **** --- 17,21 ---- INT, c_long, + c_ulong, c_ushort, HANDLE, *************** *** 39,42 **** --- 40,97 ---- + """***************************************************************************** + Creates a name postfixed with either the curent desktop name + the current sesion id or the current user domain + + This applies to NT systems only. For win9x systems the name is returned + unchanged. If something goes wrong the name is returnd unchanged. + + flag can be: 'desktop', 'session' or 'trustee' + + + code is adopted from: + http://www.flounder.com/nomultiples.htm + + *****************************************************************************""" + def CreateExclusionName(name, flag): + from wnd.api import winos + if winos.IsNT(): + + if flag=='desktop': + ## create a name exclusive to the current desktop + #UOI_NAME = 2 + hDesk= user32.GetThreadDesktop(kernel32.GetCurrentThreadId()) + + dwLen= c_ulong() + user32.GetUserObjectInformationA(hDesk, 2, None, 0, byref(dwLen)) + p = create_string_buffer('', size=dwLen.value) + if user32.GetUserObjectInformationA(hDesk, 2, p, dwLen.value, byref(dwLen)): + name = '%s-%s' % (name, p.value) + user32.CloseDesktop(hDesk) + return name + + elif flag== 'session': + ## create a name exclusive to the current session + from wnd.api import privleges + try: + st= privleges.GetTokenStats(None) + name = '%s-%s' % (name, st.AuthenticationId) + except: pass + return name + + elif flag == 'trustee': + ## create a name exclusive to the current, well trustee that is. + import os + domain= os.getenv('USERDOMAIN') + if domain: + return '%s-%s' % (name, domain) + + # default + return name + + + #*********************************************************************************** + #*********************************************************************************** + ENUMWINDOWSPROC = WINFUNCTYPE(INT, HANDLE, LPARAM) *************** *** 104,110 **** # #******************************************************************* ! def ChildWindows(self, flag=None): ! return _EnumWindows.ChildWindows(self.Hwnd) def WalkGui(self, hwnd=None, topdown=True): --- 159,175 ---- # #******************************************************************* ! ! ! def GetGUID(self): ! return self._base_guid ! ! def SetGUID(self, guid): ! self._base_guid= guid ! ! def ThreadWindows(self, flag=None): ! return _EnumWindows.ThreadWindows(self.Hwnd, flag) ! def ChildWindows(self, flag=None): ! return _EnumWindows.ChildWindows(self.Hwnd) def WalkGui(self, hwnd=None, topdown=True): *************** *** 615,618 **** --- 680,684 ---- def Subclass(self): + if not self._base_pWndProc: raise RuntimeError, "can not subclass control" if self._base_pOldWndProc: raise RuntimeError, "control is alreaddy subclassed" if not self._base_subclassable: raise RuntimeError, "custom classes should not be subclassed" *************** *** 624,627 **** --- 690,694 ---- if self.IsSubclassed(): user32.SetWindowLongA(self.Hwnd, -4, self._base_pOldWndProc) + user32.DestroyWindow(self.Hwnd) self.__delattr__('Hwnd') *************** *** 636,639 **** --- 703,750 ---- class WindowMethods(_CommonMethods): + def ForceSingleInstance(self, Bool, restore=True, flag=None): + + if Bool: + if self.GetGUID(): + ERROR_ACCESS_DENIED = 5 + ERROR_ALREADY_EXISTS = 183 + + fRunning= False + if self._base_mutext_singleinst: + fRunning= True + else: + if flag: + if flag in ('desktop', 'session', 'trustee'): + self._base_mutext_singleinst= kernel32.CreateMutexA(None, 0, CreateExclusionName(self._base_guid, flag)) + else: raise ValueError, "invalid flag: %s" % flag + else: + self._base_mutext_singleinst= kernel32.CreateMutexA(None, 0, self._base_guid) + if GetLastError() in (ERROR_ALREADY_EXISTS, ERROR_ACCESS_DENIED): + kernel32.CloseHandle(self._base_mutext_singleinst) + self._base_mutext_singleinst= None + fRunning= True + + if fRunning: + if restore: + ## take advantage of copydata FindGUID method here + from wnd.api import copydata + cd= copydata.CopyData() + hwnd= cd.FindGUID(self.Hwnd, self.GetGUID()) + + if hwnd: + user32.SetForegroundWindow(hwnd) + if user32.IsIconic(hwnd): + user32.ShowWindow(hwnd, 9) # SW_RESTORE + + self.Close() + raise RuntimeError, "single instance enforced" + else: + raise RuntimeError, "GUID is required" + else: + if self._base_mutext_singleinst: + kernel32.CloseHandle(self._base_mutext_singleinst) + self._base_mutext_singleinst= None + + def SetBkColor(self, Brush): oldbrush = user32.SetClassLongA(self.Hwnd, -10, Brush.handle) # GCL_HBRBACKGROUND *************** *** 757,763 **** ! ! ! def Close(self): user32.DestroyWindow(self.Hwnd) --- 868,875 ---- ! def Close(self): ! if self.Hwnd: ! user32.DestroyWindow(self.Hwnd) ! self.hwnd= 0 Index: dialog.py =================================================================== RCS file: /cvsroot/wnd/wnd/wnd/controls/base/dialog.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** dialog.py 29 Apr 2005 15:23:33 -0000 1.1.1.1 --- dialog.py 23 Jul 2005 22:10:05 -0000 1.2 *************** *** 1,3 **** --- 1,12 ---- + """ + TODO + - disallow multiple creation of the same dialog + propsheets bypass the Run method-- how to stop them ?? + + - 'dialoglike' keyboard handling for standalone dialogs (modeless) + have to run a dispatch loop for this + + """ from wnd.wintypes import (user32, *************** *** 9,13 **** NMHDR, WORD, - UINT, POINT, byref, --- 18,21 ---- *************** *** 18,22 **** --- 26,35 ---- #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + PSM_QUERYSIBLINGS = 1024 + 108 # WM_USER # propertysheets + + #******************************************************************************** + #******************************************************************************** + class BaseDialog(object): *************** *** 25,28 **** --- 38,43 ---- def __init__(self, title, x, y, w, h, *styles): + + self.Hwnd= 0 self.Msg = dialog_msgs self.Style = dialog_styles *************** *** 31,38 **** self._base_registeredMessages = [] self._base_dragAcceptFiles=False ! self._base_dialogMode=None self._base_timers= [] self._base_debugger= None ! # styles iStyles = self.ParseStyles(styles) --- 46,57 ---- self._base_registeredMessages = [] self._base_dragAcceptFiles=False ! self._base_dialogMode='modeless' ## in respect to property sheets ! ## ! self._base_timers= [] self._base_debugger= None ! self._base_guid = None ! ! # styles iStyles = self.ParseStyles(styles) *************** *** 56,87 **** self._base_dlgTemplate = buffer((WORD * len(p))(*p))[:] #--------------------------------------------------------------------- # for uniformity reasons def DefWindowProc(self, Hwnd, msg, wp, lp): ! return self.DefDlgProc def _base_WndProc(self, hwnd, msg, wp, lp): try: ! if self._base_debugger: result= self._base_debugger.HandleMessage(hwnd, msg, wp, lp) if result: self.onMSG(hwnd, "debug", *result) ! result= fw.IsDialogReflectMessage(hwnd, msg, wp, lp) ! if result != None: return result ! result=self.onMESSAGE(hwnd, msg, wp, lp) if result != None: return result - if msg == self.Msg.WM_INITDIALOG: - self.Hwnd = hwnd - self.onINITDIALOG(hwnd, msg, wp, lp) - return 0 # ?? #--------------------------------------------------------------------------- elif msg==self.Msg.WM_SYSCOLORCHANGE: ## forward to all child windows --- 75,154 ---- self._base_dlgTemplate = buffer((WORD * len(p))(*p))[:] + + + + #--------------------------------------------------------------------- # for uniformity reasons def DefWindowProc(self, Hwnd, msg, wp, lp): ! return self.DefDlgProc(Hwnd, msg, wp, lp) def _base_WndProc(self, hwnd, msg, wp, lp): + try: ! if self._base_debugger: result= self._base_debugger.HandleMessage(hwnd, msg, wp, lp) if result: self.onMSG(hwnd, "debug", *result) ! result= fw.IsDialogReflectMessage(hwnd, msg, wp, lp, self._base_dialogMode) ! if result != None: return result ! ! ! if msg == self.Msg.WM_INITDIALOG: ! self.Hwnd= hwnd ! result= self.onINITDIALOG(hwnd, msg, wp, lp) ! if result != None: return result ! return 0 ! result=self.onMESSAGE(hwnd, msg, wp, lp) if result != None: return result + #--------------------------------------------------------------------------- + elif msg==self.Msg.WM_ACTIVATE: + #WA_INACTIVE = 0 + #WA_ACTIVE = 1 + #WA_CLICKACTIVE = 2 + + if self.GetStyleL('basestyle') & self.Style.WS_BASE_DIALOGLIKE: + ## tell the mainwindow to dispatch/clear IsDialogMessage + + hwndMain= self.GetMainWindow() + if hwndMain: + if LOWORD(wp) & 3: # activated + + self.SendMessage(hwndMain, fw.WND_WM_NOTIFY, fw.WND_NM_DLGDISPATCH, self.Hwnd) + else: + self.SendMessage(hwndMain, fw.WND_WM_NOTIFY, fw.WND_NM_DLGDISPATCH, 0) # clear + + + + # copydata ------------------------------------------------------- + + elif msg== self.Msg.WM_COPYDATA: + result = fw.HandleCopyData(hwnd, msg, wp, lp) + if result == None: + return 0 + if HIWORD(result[0]): # reserved for framework, must be mislead + return 0 + if self.onMSG(hwnd, "copydata", wp, (result[0], result[1]))== False: + return 0 + return 1 + + + + ## property sheets + elif msg==PSM_QUERYSIBLINGS: + result= self.onMSG(hwnd, "prop_querysiblings", wp, lp) + if result: return result + return 0 + + elif msg==self.Msg.WM_SYSCOLORCHANGE: ## forward to all child windows *************** *** 103,109 **** elif msg==self.Msg.WM_COMMAND: - ## filter out default IDS for 'modal' dialog boxes if self._base_dialogMode=='modal': ! # we can not set ID of the def button to IDOK # so we have to explicitely test for it --- 170,175 ---- elif msg==self.Msg.WM_COMMAND: if self._base_dialogMode=='modal': ! ## filter out default IDS for 'modal' dialog boxes # we can not set ID of the def button to IDOK # so we have to explicitely test for it *************** *** 124,134 **** else: self.Close() return 0 ! else: ! if HIWORD(wp): # accelerator message ! self.onMSG(hwnd, "menu choice", user32.GetMenu(self.Hwnd), (LOWORD(wp), True)) ! else: # menu message self.onMSG(hwnd, "menu choice", user32.GetMenu(self.Hwnd), (LOWORD(wp), False)) ! elif msg==fw.WND_WM_TRAY: --- 190,205 ---- else: self.Close() return 0 + + #if lp: + # WM_COMMAND from non framework controls or controls wich + # have disabled the message reflect flag, so let them splip ! if not lp: ! code= HIWORD(wp) ! if code==0: # menu message self.onMSG(hwnd, "menu choice", user32.GetMenu(self.Hwnd), (LOWORD(wp), False)) ! elif code==1: # accelerator message ! self.onMSG(hwnd, "menu choice", user32.GetMenu(self.Hwnd), (LOWORD(wp), True)) ! elif msg==fw.WND_WM_TRAY: *************** *** 190,194 **** # drag window by its client area --------------------------------------------------- ! ## does not work for dialogs ## #elif msg==132: # WM_NCHITTEST --- 261,265 ---- # drag window by its client area --------------------------------------------------- ! ## does not work for dialogs ?? ## #elif msg==132: # WM_NCHITTEST *************** *** 211,216 **** if self._base_dragAcceptFiles: shell32.DragAcceptFiles(self.Hwnd, 0) self.onMSG(hwnd, "destroy", 0, 0) ! self.__delattr__('Hwnd') --- 282,290 ---- if self._base_dragAcceptFiles: shell32.DragAcceptFiles(self.Hwnd, 0) + self._base_dragAcceptFiles=False + + self.Hwnd= 0 self.onMSG(hwnd, "destroy", 0, 0) ! *************** *** 229,232 **** --- 303,307 ---- raise RuntimeError, "could not redraw menu bar" return 1 + elif nmu.type==fw.MNUT_ACCEL: # remove accelerator table *************** *** 235,238 **** --- 310,320 ---- return 1 return 0 + + elif wp== fw.WND_NM_GETGUID: + guid= self.GetGUID() + if guid: + fw.CopyData(self.Hwnd, lp, fw.WND_CD_GUID, guid, 1) + return 1 + return 0 elif wp==fw.WND_NM_EXCEPTION: *************** *** 291,301 **** elif self._base_dialogMode=='modeless': user32.DestroyWindow(self.Hwnd) ! #self.__delattr__('Hwnd') def RunModal(self, parent=None, lp=0): ! if hasattr(self, 'Hwnd'): raise RuntimeError("Dialog allreaddy running") if not parent: parent= 0 else: parent= parent.Hwnd self._base_dialogMode = 'modal' result = user32.DialogBoxIndirectParamA( --- 373,384 ---- elif self._base_dialogMode=='modeless': user32.DestroyWindow(self.Hwnd) ! def RunModal(self, parent=None, lp=0): ! if self.Hwnd: raise RuntimeError("Dialog allreaddy running") if not parent: parent= 0 else: parent= parent.Hwnd + self._base_dialogMode = 'modal' result = user32.DialogBoxIndirectParamA( *************** *** 306,310 **** def RunModeless(self, parent=None, lp=0): ! if hasattr(self, 'Hwnd'): raise RuntimeError("Dialog allreaddy running") if not parent: parent= 0 --- 389,393 ---- def RunModeless(self, parent=None, lp=0): ! if self.Hwnd: raise RuntimeError("Dialog allreaddy running") if not parent: parent= 0 *************** *** 314,320 **** 0, self._base_dlgTemplate, parent, self._base_pWndProc , lp) ! ## when to collect here ?? ! gc.collect() ! def onINITDIALOG(self, hwnd, msg, wp, lp): --- 397,402 ---- 0, self._base_dlgTemplate, parent, self._base_pWndProc , lp) ! ! def onINITDIALOG(self, hwnd, msg, wp, lp): *************** *** 329,332 **** --- 411,415 ---- """User handler. Overwrite in derrived classes""" pass + def onMSG(self, hwnd, msg, wp, lp): """User handler. Overwrite in derrived classes""" *************** *** 334,337 **** --- 417,434 ---- + def GetTemplate(self): + return self._base_dlgTemplate + + def GetDlgProc(self): + return self._base_pWndProc + + def GetMainWindow(self): + hwndMain= None + for i in self.ThreadWindows(): + result= self.SendMessage(i, fw.WND_WM_NOTIFY, fw.WND_NM_ISMAINWINDOW, 0) + if result == fw.WND_MSGRESULT_TRUE: + hwndMain= i + break + return hwndMain #*********************************************************************** *************** *** 340,343 **** --- 437,442 ---- class BaseDialogFromTemplate(BaseDialog): def __init__(self, template, *styles): + + self.Msg = dialog_msgs self.Style = dialog_styles *************** *** 348,353 **** self._base_debugger= None self._base_dialogMode=None ! self._base_style = [0, 0] # base/clientstyle ! valid_flags=('debug', 'debugall') for i in styles: --- 447,453 ---- self._base_debugger= None self._base_dialogMode=None ! self._base_style = [0, 0] # base/clientstyle ! self._base_guid = None ! valid_flags=('debug', 'debugall') for i in styles: *************** *** 365,369 **** self._base_pOldWndProc = 0 ! #************************************************************************ # base class for common-dialogs --- 465,469 ---- self._base_pOldWndProc = 0 ! #************************************************************************ # base class for common-dialogs *************** *** 387,398 **** self.Hwnd = 0 self._base_registeredMessages = [] self._base_dragAcceptFiles=False self._base_timers= [] # styles self._base_dialogMode=mode self._base_style = [0, 0] # base/clientstyle ! # check if debugging is requested and set the windowproc dbglevel= 0 --- 487,504 ---- self.Hwnd = 0 + self._base_registeredMessages = [] self._base_dragAcceptFiles=False self._base_timers= [] + self._base_guid = None # styles self._base_dialogMode=mode self._base_style = [0, 0] # base/clientstyle ! ## enables keyboard handling for 'modeless' common dialogs ! if self._base_dialogMode== 'modeless': ! self._base_style[0] |= self.Style.WS_BASE_DIALOGLIKE ! ! # check if debugging is requested and set the windowproc dbglevel= 0 *************** *** 404,409 **** ! def GetDlgProc(self): ! return self._base_pWndProc def Close(self): --- 510,516 ---- ! def GetTemplate(self): ! return None ! def Close(self): |