Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Screen flashes when windows form is unloaded?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TCook - 19 May 2006 18:23 GMT
Hey All,

I have a VS2003, C# addin for MS Word 2003.  When the windows form unloads,
the screen flashes.  I've never seen this behavior before.  Usually, the
unloading of a form is very smooth.

I was wondering if anyone else has experienced this and, if so, if you were
able to resolve it.

Thanks & Regards,

TC
TCook - 19 May 2006 23:42 GMT
Hey Folks,

Some more info on the behavior.

I have used the Win32 API in attempt to set Word as the windows form's
parent.  I have also tried creating an IWin32Window class as well.

Win32 Method:

public static void SetParentAsTopWindow(WordReferences wordReferences)

{

try

{

IntPtr HwndWindow=new IntPtr(0);

bool Result=new bool();

Win32.EnableWindow((IntPtr)wordReferences.Handle, true);

HwndWindow=FindWindow(WordReferences.WordClassName, null);

if (HwndWindow!=IntPtr.Zero)

{

Result=Win32.SetForegroundWindow(HwndWindow);

}

}

catch(System.Exception ex)

{

ExceptionHandler.HandleException(ex);

}

}

The class:

public class WordHWND : IWin32Window

{

public const string WordWindowSuffix = " - Microsoft Word";

string _windowName;

public WordHWND(string windowName)

{

_windowName = windowName + WordHWND.WordWindowSuffix;

}

public IntPtr Handle

{

// Note: "OpusApp" is the class name for Word

get { return Win32.FindWindow(WordReferences.WordClassName, _windowName);}

}

}

What appears to be happening is the form is taking the window behind Word as
the parent.  When it unloads, it briefly displays another window for a split
second and then one is back in Word.  However, Word's title bar is grayed.
Even though you can work in the Word window, the title bar remains grayed.
Not until the window is resized via Minimize, Maximize or Normal does it
become un-grayed.

I have also tried turning off screenupdating as well as the Win32 API
"LockWindowUpdate" but the flashing and graying out continue.

Has anyone else experienced this using C# in VS2003 with an MSWord addin?

I am using Word 2003.

Any assistance would be greatly appreciated.

Regards,

TC

> Hey All,
>
[quoted text clipped - 8 lines]
>
> TC
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.