Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
dlgappcore.py76 linesDownload Raw Back to framework
1# dlgappcore.2#3# base classes for dialog based apps.4 5 6import win32api7import win32con8import win32ui9from pywin.mfc import dialog10 11from . import app12 13error = "Dialog Application Error"14 15 16class AppDialog(dialog.Dialog):17    "The dialog box for the application"18 19    def __init__(self, id, dll=None):20        self.iconId = win32ui.IDR_MAINFRAME21        dialog.Dialog.__init__(self, id, dll)22 23    def OnInitDialog(self):24        return dialog.Dialog.OnInitDialog(self)25 26    # Provide support for a dlg app using an icon27    def OnPaint(self):28        if not self.IsIconic():29            return self._obj_.OnPaint()30        self.DefWindowProc(win32con.WM_ICONERASEBKGND, dc.GetHandleOutput(), 0)31        left, top, right, bottom = self.GetClientRect()32        left = (right - win32api.GetSystemMetrics(win32con.SM_CXICON)) >> 133        top = (bottom - win32api.GetSystemMetrics(win32con.SM_CYICON)) >> 134        hIcon = win32ui.GetApp().LoadIcon(self.iconId)35        self.GetDC().DrawIcon((left, top), hIcon)36 37    # Only needed to provide a minimized icon (and this seems38    # less important under win95/NT439    def OnEraseBkgnd(self, dc):40        if self.IsIconic():41            return 142        else:43            return self._obj_.OnEraseBkgnd(dc)44 45    def OnQueryDragIcon(self):46        return win32ui.GetApp().LoadIcon(self.iconId)47 48    def PreDoModal(self):49        pass50 51 52class DialogApp(app.CApp):53    "An application class, for an app with main dialog box"54 55    def InitInstance(self):56        # 		win32ui.SetProfileFileName('dlgapp.ini')57        win32ui.LoadStdProfileSettings()58        win32ui.EnableControlContainer()59        win32ui.Enable3dControls()60        self.dlg = self.frame = self.CreateDialog()61 62        if self.frame is None:63            raise error("No dialog was created by CreateDialog()")64            return65 66        self._obj_.InitDlgInstance(self.dlg)67        self.PreDoModal()68        self.dlg.PreDoModal()69        self.dlg.DoModal()70 71    def CreateDialog(self):72        pass73 74    def PreDoModal(self):75        pass76 
codekingpro/portable-devtools · Team Ai