I'm writing a plug-in for an app; the plug-in is to display a modal dialog. It displays just fine, but when I move it, it leaves a trail on the screen, i.e. the window below doesn't redraw. Some parts of it do redraw (all standard Windows controls, e.g. toolbar or scrollbar), but the rest of the client area does not.
I'm using DialogBoxIndirectParam
; the hWnd
is the top window of the app, the template I construct on the fly and the dialog flags are WS_POPUP | WS_CAPTION | DS_MODALFRAME | DS_SETFONT | WS_SYSMENU
, plus the function sets some flags itself, e.g. WS_CLIPSIBLINGS
. The dialog class is standard (CS+DBLCLKS,CS_SAVEBITS) The dialog procedure is very basic, it only handles the WM_CLOSE
message at the moment.
I tried Google but didn't manage find anything directly relevant. I tried to compare my dialog class with other dialogs of the same app and also checked the messages logs, but I didn't see any drastic differences.
Why doesn't the parent/owner redraw and how do I fix it?
Update. Here's the relevant calls.
Calling the dialog:
class Dialog(object):
def run(self):
t = cast(c_char_p(self.template()), LPCDLGTEMPLATE)
p = GetActiveWindow()
r = DialogBoxIndirectParamW(0, t, p, dialog_proc_2, py_object(self))
Window procedure:
def dialog_proc(window, message, wparam, lparam):
if message == WM_CLOSE:
EndDialog(window, IDCANCEL);
return 1
return 0
This is Python code :) it's embedded Python working via ctypes
. The plug-in runs in the main thread; the host application makes a synchronous call, i.e it waits for the called function to return. self.template()
returns DLGTEMPLATEEX
data I prepare on the fly; I believe I do this correctly, because the dialog displays and when I check it with Spy all flags seems to be set (except that there's a few more). I don't use the instance handle, because I don't load anything from resources. I believe I correctly wrapped all functions and constants, but I can post the definitions too. GetActiveWindow
(or GetForegroundWindow
) returns the pointer to the app's main window; it's a MDI app and it repaints everything except the client area of a MDI window:
Here I moved the window over all the visible windows (toolbars, buttons, etc.) and the only part that doesn't repaint is the client area of the MDI doc.