Ejemplo n.º 1
0
    def Run(self, show='normal'):

        try:
            show = ['hidden', 'normal', 'minimized', 'maximized'].index(show)
        except:
            try:
                range(4)[show]
            except:
                raise "invalid flag: %s" % show

        # run the messageloop
        self._base_fIsopen = True
        self.onMSG(self.Hwnd, "create", 0, 0)
        user32.ShowWindow(self.Hwnd, show)
        user32.UpdateWindow(self.Hwnd)
        GM, TM, DM, TACC, TMDIA = (user32.GetMessageA, user32.TranslateMessage,
                                   user32.DispatchMessageA,
                                   user32.TranslateAcceleratorA,
                                   user32.TranslateMDISysAccel)
        msg = MSG()
        pMsg = byref(msg)
        if self.GetStyleL('basestyle') & self.Style.WS_BASE_DIALOGLIKE:
            IsDialogMessage = user32.IsDialogMessageA
            self.onMSG(self.Hwnd, "open", 0, 0)
            window._exit.Unregister(self.Hwnd)
            #ExitHandler._UnregisterGuiExitFunc()
            while GM(pMsg, 0, 0, 0) > 0:

                if self._client_MDIClient:
                    if not TMDIA(self._client_MDIClient.Hwnd, pMsg):
                        if not IsDialogMessage(self.Hwnd, pMsg):
                            if self._base_hAccelerator:
                                if not TACC(self.Hwnd, self._base_hAccelerator,
                                            pMsg):
                                    TM(pMsg)
                                    DM(pMsg)
                                    continue
                TM(pMsg)
                DM(pMsg)

        else:
            self.onMSG(self.Hwnd, "open", 0, 0)
            window._exit.Unregister(self.Hwnd)
            #ExitHandler._UnregisterGuiExitFunc()
            while GM(pMsg, 0, 0, 0) > 0:

                if self._client_MDIClient:
                    if not TMDIA(self._client_MDIClient.Hwnd, pMsg):
                        if self._base_hAccelerator:
                            if not TACC(self.Hwnd, self._base_hAccelerator,
                                        pMsg):
                                TM(pMsg)
                                DM(pMsg)
                                continue
                TM(pMsg)
                DM(pMsg)
Ejemplo n.º 2
0
	def Run(self, show='normal'):
		try: show=['hidden','normal', 'minimized','maximized'].index(show)
		except:
			try: range(4)[show]
			except:	raise ValueError, "invalid flag: %s" % show			
		
		# run the messageloop
		self._base_fIsopen= True
		self.onMSG(self.Hwnd, "create", 0, 0)	# looks like take it out
		user32.ShowWindow(self.Hwnd, show)
		user32.UpdateWindow(self.Hwnd)
		GM, TM, DM, TACC=(user32.GetMessageA,
									user32.TranslateMessage,
									user32.DispatchMessageA,
									user32.TranslateAcceleratorA) 
		msg = MSG()
				
		pMsg = pointer(msg)
		if self.GetStyleL('basestyle') & self.Style.WS_BASE_DIALOGLIKE:
			IsDialogMessage=user32.IsDialogMessageA
			#
			# TODO
			#
			# would be better to call when all childwindows have been created
			# but thats a thing we don't know
			# needs some heavier testing, we'll see
			#
			self.onMSG(self.Hwnd, "open", 0, 0)
			_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):
							TM(pMsg)
					else:
						TM(pMsg)
					DM(pMsg)
		
				
		else:
			self.onMSG(self.Hwnd, "open", 0, 0)
			_exit.Unregister(self.Hwnd)
			while GM( pMsg, 0, 0, 0) > 0:
				if self._base_hAccelerator:
					if not TACC(self.Hwnd, self._base_hAccelerator, pMsg):
						TM(pMsg)
				else:
					TM(pMsg)
				DM(pMsg)
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
 def Minimize(self):
     user32.ShowWindow(self.Hwnd, 6)  # SW_MINIMIZE
Ejemplo n.º 5
0
 def Restore(self):
     user32.ShowWindow(self.Hwnd, 9)  # SW_RESTORE
Ejemplo n.º 6
0
 def Maximize(self):
     user32.ShowWindow(self.Hwnd, 3)  # SW_MAXIMIZE
Ejemplo n.º 7
0
 def Show(self):
     user32.ShowWindow(self.Hwnd, 1)
Ejemplo n.º 8
0
 def Hide(self):
     user32.ShowWindow(self.Hwnd, 0)
Ejemplo n.º 9
0
	def Minimize(self, hwnd): user32.ShowWindow(hwnd, 6)		# SW_MINIMIZE
	
	def IsMinimized(self, hwnd):