Exemplo n.º 1
0
 def Subclass(self, pWindowProc):
     if self._base_pOldWndProc:
         raise RuntimeError, "window is alreaddy subclassed"
     self._base_pOldWndProc = user32.SetWindowLongA(self.hwnd, -4,
                                                    pWindowProc)
     if not self._base_pOldWndProc:
         raise RuntimeError, "could not subclass window"
Exemplo n.º 2
0
 def _client_Callback(self, hwnd, msg, lp):
     if msg == PSCB_INITIALIZED:
         self.Hwnd = hwnd
         # subclass the propsheet
         self._client_pOldDlgProc = user32.SetWindowLongA(
             hwnd, -4, self._client_pDlgProc)
         self.onMSG(hwnd, "initialized", lp, 0)
Exemplo n.º 3
0
    def Close(self):
        if self.IsSubclassed():
            user32.SetWindowLongA(self.Hwnd, -4, self._base_pOldWndProc)

        user32.DestroyWindow(self.Hwnd)
        self.__delattr__('Hwnd')
        gc.collect()  ## not really required (if I done my job well)
Exemplo n.º 4
0
 def SetStyleL(self, offset, style):
     if offset == 'style':
         user32.SetWindowLongA(self.Hwnd, -16, style)  # GWL_STYLE
     elif offset == 'exstyle':
         user32.SetWindowLongA(self.Hwnd, -20, style)  # GWL_EXSTYLE
     elif offset == 'extendedstyle':
         try:
             self.SendMessage(self.Hwnd, self.Msg.MSG_SETEXSTYLE, 0, style)
         except:
             raise AttributeError, "control does not define extended styles"
     elif ofset == 'basestyle':
         self._base_style[0] = style
     elif offset == 'clientstyle':
         self._base_style[1] = style
     else:
         raise ValueError, "invalid style offset: %s" % offset
     self.RedrawFrame(
     )  ## or do some heavy parsing to see if the frame is afected
Exemplo n.º 5
0
 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"
     self._base_pOldWndProc = user32.SetWindowLongA(self.Hwnd, -4,
                                                    self._base_pWndProc)
     if not self._base_pOldWndProc:
         raise RuntimeError, "could not subclass window"
Exemplo n.º 6
0
	def __init__(self, Parent, NameOrClass, title, x, y, w, h, *styles):
			
			
		self._base_subclassable = False
		self._base_registeredMessages = []
		self._base_dragAcceptFiles=False
		self._base_timers= []
		self._base_debugger= None
		self._base_fMsgReflect= 1
		self._base_guid = None
		
		
		# ...all the style parsing
		# default  WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS
		iStyles = self.ParseStyles(styles, 					
								style=1073741824|268435456|33554432|67108864)
		self._base_style = [iStyles[3], iStyles[4]]	# base/clientstyle
		
		# check if debugging is requested and set the windowproc
		self._base_debugger= fw.GetDebugger(iStyles[3], self.Msg)
		self._base_pWndProc= 	WNDPROC(self._base_WndProc)
		self._base_pOldWndProc = 0
		
		# check if we have to register the class
		subclass = iStyles[3] & self.Style.WS_BASE_SUBCLASS 
		if isinstance(NameOrClass, str):
			classname = NameOrClass
			if not subclass:	# systemdefined class the user can subclass
				self._base_subclassable = True
		else:
			NameOrClass.SetWindowProc(self._base_pWndProc)
			try: 
				r=NameOrClass.Register()
				classname= NameOrClass.lpszClassName
			except: raise RuntimeError("invalid class" % NameOrClass)
			subclass=False	# --> ignore style 'subclass'

		# create the control
		self.Hwnd=user32.CreateWindowExA(
							iStyles[1],classname,title,iStyles[0],x,y,w,h,
							Parent.Hwnd,fw.ID.New(),0,0)
		if not self.Hwnd: raise RuntimeError("could not create window")
		
		# subclass the control
		if subclass:
			self._base_pOldWndProc = user32.SetWindowLongA(self.Hwnd, -4, self._base_pWndProc)
			if not self._base_pOldWndProc:
				raise RuntimeError("could not subclass window")

		# set extended comctl styles
		if iStyles[2]: 
			self.SetStyleL('extendedstyle', iStyles[2])
Exemplo n.º 7
0
    def SetStyle(self, *styles):

        style = user32.GetWindowLongA(self.Hwnd, -16)  # GWL_STYLE
        exstyle = user32.GetWindowLongA(self.Hwnd, -20)  # GWL_EXSTYLE
        try:
            extendedstyle = self.SendMessage(self.Hwnd,
                                             self.Msg.MSG_GETEXSTYLE, 0, 0)
            hasExtStyle = True
        except:
            extendedstyle, hasExtStyle = 0, False

        result = self.ParseStyles(styles, style, exstyle, extendedstyle,
                                  self._base_style[0], self._base_style[1])
        if result[0] != style:
            user32.SetWindowLongA(self.Hwnd, -16, result[0])  # GWL_STYLE
        if result[1] != exstyle:
            user32.SetWindowLongA(self.Hwnd, -20, result[1])  # GWL_EXSTYLE
        if hasExtStyle:
            if result[2] != extendedstyle:
                self.SendMessage(self.Hwnd, self.Msg.MSG_SETEXSTYLE, 0,
                                 result[2])
        self._base_style[0] = result[3]
        self._base_style[1] = result[4]
        self.RedrawFrame()
Exemplo n.º 8
0
	def _BffCallBack(self, hwnd, msg, wp, lp):
		
		if msg==BFFM_INITIALIZED:
			self.Hwnd = hwnd
			if self._dlgs_fHook:
				self._dlgs_pOldProc = user32.SetWindowLongA(hwnd, -4, self.GetDlgProc())
			self.onINIT(hwnd, msg, wp, lp)
					
		elif msg==BFFM_SELCHANGED:
			pIdl= pointer(ITEMIDLIST.from_address(wp))	## passes IDL in wp
			try:
				self.onMSG(hwnd, "bff_selchanged", pIdl, 0)
			finally:
				Malloc.Free(pIdl)
		
		elif msg==BFFM_VALIDATEFAILEDA:
			result=self.onMSG(hwnd, "bff_validatefailed", c_char_p(wp).value, 0)
			if result==False: return 1
			return 0
		return 0
Exemplo n.º 9
0
 def RestoreOldProc(self):
     if not self._base_pOldWndProc:
         raise RuntimeError, "window is not subclassed"
     result = user32.SetWindowLongA(self.hwnd, -4, self._base_pOldWndProc)
     self._base_pOldWndProc = None
     return result
Exemplo n.º 10
0
    def _client_DlgProc(self, hwnd, msg, wp, lp):

        if msg == 2:  ## WM_DESTROY
            ## reset
            try:
                self.onMSG(hwnd, "destroy", 0, 0)
            finally:
                self.Hwnd = 0
                self._client_fReboot = None

        if msg == fw.WND_WM_NOTIFY:
            if wp == fw.WND_NM_MSGREFLECT:
                msgr = fw.WND_MSGREFLECT.from_address(lp)
                msgr.fReturn = 1

                if msgr.msg == WM_NOTIFY:
                    nm = NMHDR.from_address(msgr.lParam)

                    if nm.code == PSN_APPLY:
                        result = self.onMSG(hwnd, "apply", msgr.hwndFrom, 0)
                        user32.SetWindowLongA(
                            hwnd, DWL_MSGRESULT,
                            result == False and PSNRET_INVALID_NOCHANGEPAGE
                            or PSNRET_NOERROR)
                        if result != False:
                            if self._client_mode == 'modeless':
                                user32.DestroyWindow(self.Hwnd)

                    elif nm.code == PSN_HELP:
                        self.onMSG(hwnd, "help", msgr.hwndFrom, 0)

                    elif nm.code == PSN_KILLACTIVE:
                        result = self.onMSG(hwnd, "killactive", msgr.hwndFrom,
                                            0)
                        user32.SetWindowLongA(hwnd, DWL_MSGRESULT,
                                              result == False and 1 or 0)

                    elif nm.code == PSN_QUERYCANCEL:
                        result = self.onMSG(hwnd, "querycancel", msgr.hwndFrom,
                                            0)
                        user32.SetWindowLongA(hwnd, DWL_MSGRESULT,
                                              result == False and 1 or 0)
                        if result != False:
                            if self._client_mode == 'modeless':
                                user32.DestroyWindow(self.Hwnd)

                    elif nm.code == PSN_RESET:
                        psn = PSHNOTIFY.from_address(lp)
                        result = self.onMSG(hwnd, "reset", msgr.hwndFrom,
                                            psn.lParam and 'cancel' or 'close')

                    elif nm.code == PSN_SETACTIVE:
                        self.onMSG(hwnd, "setactive", msgr.hwndFrom, 0)

                    elif nm.code == PSN_WIZBACK:
                        result = self.onMSG(hwnd, "wizback", msgr.hwndFrom, 0)
                        user32.SetWindowLongA(hwnd, DWL_MSGRESULT,
                                              result == False and -1 or 0)

                    elif nm.code == PSN_WIZNEXT:
                        result = self.onMSG(hwnd, "wiznext", msgr.hwndFrom, 0)
                        user32.SetWindowLongA(hwnd, DWL_MSGRESULT,
                                              result == False and -1 or 0)

                    elif nm.code == PSN_WIZFINISH:
                        result = self.onMSG(hwnd, "wizfinish", msgr.hwndFrom,
                                            0)
                        user32.SetWindowLongA(hwnd, DWL_MSGRESULT,
                                              result == False and 1 or 0)
                        if result != False:
                            if self._client_mode == 'modeless':
                                user32.DestroyWindow(self.Hwnd)

                    return 1
            return 0

        return user32.CallWindowProcA(self._client_pOldDlgProc, hwnd, msg, wp,
                                      lp)