473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

79
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 1832
weaknessforcats
9,208 Expert Mod 8TB
Edit your Word document on a separate thread by calling CreateThread().

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

When WaitForSingleObject() returns, the thread is gone meaning your edit is complete.
Jul 18 '07 #2
ahammad
79
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
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...
11
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.