Hi, Michael. You wrote:
WM_FM_CLOSE = (WM_FM_FORMBASE + 12);
// This message is sent twice to extensions, once with "wParam" set to 1
// to indicate that an attempt has been made to close the extension's
// Window. In this case, the extension can return a non-zero value to stop
// the window from being closed. If "wParam" is 0, then the window is being
// closed, and the extension should take any steps necessary to tidy itself
// up. The "wParam==0" case is sent during the WM_DESTROY processing for
// the enclosing window, before any windows are destroyed, so the extension
// can assume that any windows it has created are still valid.
Thanks for that. But it doesn't appear to work exactly like that. It seems wParam is always 1. But that doesn't seem to matter and it's not the point of my post.
I have a plugin that makes PM hard to close and doesn't crash, but I still have questions. In fact, it makes PM too hard to close (explanation below). Here's my plugin's message process:
LRESULT WINAPI MessageProc (HWND hWnd, WORD wMsg, WPARAM wParam, LPARAM lParam)
{
if ( wMsg == WM_FM_INIT )
{
hWndPmail = (HWND) SendMessage(hWndParent, WM_F_GETWINDOW, 0, 0);
OldWndProc = SetWindowLong(hWndPmail, GWL_WNDPROC, (LONG) MyWindowProc);
if ( START_MINIMIZED )
PostMessage(hWndPmail, WM_SYSCOMMAND, SC_MINIMIZE, 0);
}
else if ( wMsg == WM_FM_CLOSE && OldWndProc != NULL )
{
SetWindowLong(hWndPmail, GWL_WNDPROC, (LONG) OldWndProc);
OldWndProc = NULL;
return 1; // returning 0 will cause a crash!
}
return 0;
}
What happens is this: "X" and "Close" don't work; PM is minimized instead (that's the point of the plugin). If I "File\Exit", I get WM_FM_CLOSE with wParam == 1. The old window process is restored and because I return 1, PM makes no further efforts to close (really, it keeps running ... is that expected?). Now, if I "X", "Close", or "File\Exit" (old windpw process in place) I get WM_FM_CLOSE with wParam == 1 again. I return 0. PM continues its shutdown processing and I finally get another WM_FM_CLOSE with wParam == 1 just before PM terminates.
The fact that I must try twice to terminate PM is OK with me personally but not exactly as desired.
A crash will occur if I return 0 immediately after restoring the old window process. I'd like to know why, and also if it's expected that PM give up trying to close when a plugin returns 1 in response to WM_FM_CLOSE.
Thanks.
- Vince
<p>Hi, Michael.&nbsp; You wrote:</p><p>WM_FM_CLOSE = (WM_FM_FORMBASE + 12);
&nbsp; // This message is sent twice to extensions, once with "wParam" set to 1
&nbsp; // to indicate that an attempt has been made to close the extension's
&nbsp; // Window. In this case, the extension can return a non-zero value to stop
&nbsp; // the window from being closed. If "wParam" is 0, then the window is being
&nbsp; // closed, and the extension should take any steps necessary to tidy itself
&nbsp; // up. The "wParam==0" case is sent during the WM_DESTROY processing for
&nbsp; // the enclosing window, before any windows are destroyed, so the extension
&nbsp; // can assume that any windows it has created are still valid. </p><p>Thanks for that.&nbsp; But it doesn't appear to work exactly like that.&nbsp; It seems wParam is always 1.&nbsp; But that doesn't seem to matter and it's&nbsp; not the point of my post.
</p><p>I have a plugin that makes PM hard to close and doesn't crash, but I still have questions.&nbsp; In fact, it makes PM too hard to close (explanation below).&nbsp; Here's my plugin's message process:</p><p>LRESULT WINAPI MessageProc (HWND hWnd, WORD wMsg, WPARAM wParam, LPARAM lParam)
{
&nbsp;&nbsp;&nbsp; if ( wMsg == WM_FM_INIT )
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; hWndPmail = (HWND) SendMessage(hWndParent, WM_F_GETWINDOW, 0, 0);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; OldWndProc = SetWindowLong(hWndPmail, GWL_WNDPROC, (LONG) MyWindowProc);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( START_MINIMIZED )
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; PostMessage(hWndPmail, WM_SYSCOMMAND, SC_MINIMIZE, 0);
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; else if ( wMsg == WM_FM_CLOSE &amp;&amp; OldWndProc != NULL )
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetWindowLong(hWndPmail, GWL_WNDPROC, (LONG) OldWndProc);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; OldWndProc = NULL;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 1;&nbsp; // returning 0 will cause a crash!
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; return 0;
}</p><p>What happens is this:&nbsp; "X" and "Close" don't work; PM is minimized instead (that's the point of the plugin).&nbsp; If I "File\Exit", I get WM_FM_CLOSE with wParam == 1.&nbsp; The old window process is restored and because I return 1, PM makes no further efforts to close (really, it keeps running ... is that expected?). &nbsp; Now, if I "X",&nbsp; "Close", or "File\Exit" (old windpw process in place) I get&nbsp; WM_FM_CLOSE with wParam == 1 again.&nbsp; I return 0.&nbsp; PM continues its shutdown processing and I finally get another WM_FM_CLOSE with wParam == 1 just before PM terminates.</p><p>The fact that I must try twice to terminate PM is OK with me personally but not exactly as desired.</p><p>A crash will occur if I return 0 immediately after restoring the old window process.&nbsp; I'd like to know why, and also if it's expected that PM give up trying to close when a plugin returns 1 in response to WM_FM_CLOSE.</p><p>Thanks.</p><p>&nbsp;- Vince
</p>