def _progress_complete(self, message): """Convenience function to tell the dialog that progress is complete, passing a message along which will be displayed in the progress box """ _message = buffer(marshal.dumps(message)) address, length = win32gui.PyGetBufferAddressAndLen(_message) PostMessage(self.hwnd, self.WM_PROGRESS_COMPLETE, length, address)
def Drop(self, data_object, key_state, point, effect): child_point = wrapped(win32gui.ScreenToClient, self.hwnd, point) child_hwnd = wrapped(win32gui.ChildWindowFromPoint, self.hwnd, child_point) data = data_object.GetData(self._data_format) n_files = shell.DragQueryFileW(data.data_handle, -1) if n_files: files_string = shell.DragQueryFileW(data.data_handle, 0) print(type(files_string), files_string) address, _ = win32gui.PyGetBufferAddressAndLen( files_string.encode("mbcs")) #~ pointer_to_string = utils.string_as_pointer(files_string) SendMessage( child_hwnd, win32con.WM_SETTEXT, None, win32gui.PyGetBufferAddressAndLen( memoryview(files_string.encode("mbcs")))[0])
def string_as_pointer(string): """Convert a Python string to a LPSTR for the WinAPI NB the 'string' must support the buffer interface, typically this means it must be bytes rather than unicode. Since its memory is being returned directly, it can't be temporarily converted within this function """ address, length = win32gui.PyGetBufferAddressAndLen(string) return address
def string_as_pointer (string): """Convert a Python string to a LPSTR for the WinAPI""" address, length = win32gui.PyGetBufferAddressAndLen (buffer (string)) return address
def _progress_message(self, message): """Convenience function to send progress messages to the dialog """ _message = buffer(marshal.dumps(message)) address, length = win32gui.PyGetBufferAddressAndLen(_message) SendMessage(self.hwnd, self.WM_PROGRESS_MESSAGE, length, address)