BeforeClose Event

Y

Yazeed

Hi All,

There is no BeforeClose event in Powerpoint 2007 like Excel and word, I'm
using Microsoft.Office.Interop.Powerpoint V.12.

Is there a way to disable Application closing using .Net??
 
Y

Yazeed

Thank you chirag for your reply, i thought there is another way to do it,
however i tried to do it but its not working, here is some explanation:

Application powerPointApplication =new Application();
PowerPointApplication.Visible =MsoTriState.msoTrue;
PowerPointWindow window = new PowerPointWindow();
window.AssignHandle(new IntPtr(PowerPointApplication.HWND));

Here is the code for PowerPointWindow:

public class PowerPointWindow : NativeWindow
{
private const int WM_CLOSE = 0x10;

protected override void WndProc(ref Message m)
{
if (m.Msg != WM_CLOSE)
base.WndProc(ref m);
}
}

Now, the problem in this code that WndProc is never called, i tried to use
another approach by importing SetWindowLong from User32.dll but i'm getting
an error when trying use it (retrun value is 0 and GetLastError returned
this):

"An attempt was made to reference a token that does not exist"

please let me know if you want the code for SetWindowLong.

i know the subclassing should be within the same process like an add-in, so
Is it possible to subclass the powerpoint from another application like the
approach im following??

Thanks again
 
C

Chirag

AssignHandle() works only for the windows owned by its process. You cannot
assign it a handle of a different process. To get messages posted to another
process, you would need to use windows hooks. Look for SetWindowsHookEx()
API on MSDN.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top