473,657 Members | 2,556 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Pausing" an MFC application while Word doc is opened.

79 New Member
I have an MFC application that opens up a Word document for editing using automation. Is there a way to pause or freeze the MFC application while the Word doc is being edited? After the editing is done and Word is closed, I want the MFC application to regain control and continue with doing something else. It's kind of like having it take a break until Microsoft Word is closed.

How can this be implemented?
Jul 18 '07 #1
2 1845
weaknessforcats
9,208 Recognized Expert Moderator Expert
Edit your Word document on a separate thread by calling CreateThread().

Use the HANDLE returned by CreaateThread() as an argument to WaitForSingleOb ject().

When WaitForSingleOb ject() returns, the thread is gone meaning your edit is complete.
Jul 18 '07 #2
ahammad
79 New Member
I've never heard of this before...could you please show me an example of how to implement that with my code which uses Automation?

Expand|Select|Wrap|Line Numbers
  1. _Application wordAppLib;
  2.     CString id("Word.Application");
  3.     BOOL status = wordAppLib.CreateDispatch(id);
  4.  
  5.     _Document myDoc;
  6.     COleVariant covTrue((short)TRUE);
  7.     COleVariant covFalse((short)FALSE);
  8.     COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
  9.     Documents docs = wordAppLib.GetDocuments();
  10.     CString ReportFileName(_T("C:\\Documents and Settings\\Sleep\\Desktop\\CPFTool Project\\CPFTool\\CPFTool\\Library.doc"));
  11.     myDoc = docs.Open(COleVariant(ReportFileName),
  12.         covOptional,
  13.         covFalse,  // ReadOnly
  14.         covOptional,
  15.         covOptional,
  16.         covOptional,
  17.         covOptional,
  18.         covOptional,
  19.         covOptional,
  20.         covOptional,
  21.         covOptional,
  22.         covOptional);
  23.  
  24.  
  25.     wordAppLib.Resize((GetSystemMetrics(SM_CXSCREEN) * 0.375), GetSystemMetrics(SM_CYSCREEN));
  26.     wordAppLib.Move(dtRect.left, dtRect.top);
  27.     wordAppLib.SetVisible(TRUE);
  28.     wordAppLib.Activate();
  29.  
  30.  
  31.     _Application wordAppBlank;
  32.     CString idBlank("Word.Application");
  33.     BOOL statusBlank = wordAppBlank.CreateDispatch(idBlank);
  34.  
  35.     _Document myDocBlank;
  36.  
  37.     Documents docsBlank = wordAppBlank.GetDocuments();
  38.     myDocBlank = docsBlank.Add(covOptional,covOptional,covOptional,covOptional);
  39.  
  40.     wordAppBlank.Resize((GetSystemMetrics(SM_CXSCREEN) * 0.375), GetSystemMetrics(SM_CYSCREEN));
  41.     wordAppBlank.Move(((GetSystemMetrics(SM_CXSCREEN) * 0.375) + 1), 0);
  42.     wordAppBlank.SetVisible(TRUE);
  43.     wordAppBlank.Activate();
Jul 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
11241
by: Henry | last post by:
I am writing a Windows forms VB.Net/MS SQL application via VS 2003 that utilizes Crystal Reports. I want to be able to dynamically set the report data source at run time. I'm trying to change the the reports "integrated security" from TRUE to FALSE via the "Set Location" dialog in the report designer with no success. It is not intuitive (at least not to me.) I get the following error:
11
3569
by: Jon Davis | last post by:
Can a solution built in C# utilize MSMQ and/or MTS? If so, does this make the training material I already have on MSMQ and MTS in the context of VB6 an appropriate prerequisite foundation before learning how to build C# solutions on MSMQ / MTS, if I already know VB6 as well as C#? Jon
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.