def PostMessage(hwnd, msg, wparam, lparam): if not isinstance(wparam, WPARAM): wparam = WPARAM(wparam) if not isinstance(lparam, LPARAM): lparam = LPARAM(lparam) return _PostMessage(hwnd, msg, wparam, lparam)
def py_drop_func(hwnd, msg, wp, lp): global files, SetWindowLong if msg == WM_DROPFILES: pwint = WPARAM(wp) count = ctypes.windll.shell32.DragQueryFile(pwint, -1, None, None) szFile = ctypes.c_buffer(1024) files = [] for i in range(count): ctypes.windll.shell32.DragQueryFile(pwint, i, szFile, ctypes.sizeof(szFile)) dropname = szFile.value files.append(dropname) #print(dropname) func(files) ctypes.windll.shell32.DragFinish(pwint) oldfunc = globals()[old] return CallWindowProcW(LPCVOID(oldfunc), hwnd, msg, WPARAM(wp), LPARAM(lp))
def set_placeholder(self, value): # This solution is based on https://stackoverflow.com/questions/4902565/watermark-textbox-in-winforms if self.interface.placeholder: # Message Code for setting Cue Banner (Placeholder) EM_SETCUEBANNER = c_uint(0x1501) # value 0 means placeholder is hidden as soon the input gets focus # value 1 means placeholder is hidden only after something is typed into input show_placeholder_on_focus = WPARAM(1) window_handle = HWND(self.native.Handle.ToInt32()) user32.SendMessageW(window_handle, EM_SETCUEBANNER, show_placeholder_on_focus, self.interface.placeholder)