Click here to Skip to main content
15,886,963 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Permanent popup menu (aka list control) c++, MFC Pin
arthur89kim7-Aug-10 21:36
arthur89kim7-Aug-10 21:36 
GeneralRe: Permanent popup menu (aka list control) c++, MFC Pin
Richard MacCutchan8-Aug-10 0:54
mveRichard MacCutchan8-Aug-10 0:54 
GeneralRe: Permanent popup menu (aka list control) c++, MFC Pin
arthur89kim8-Aug-10 15:25
arthur89kim8-Aug-10 15:25 
Questionhow to get rid of MSB8012 warning in VS2010 Pin
Chesnokov Yuriy5-Aug-10 22:03
professionalChesnokov Yuriy5-Aug-10 22:03 
QuestionMultiple excel server problem Pin
trioum5-Aug-10 21:12
trioum5-Aug-10 21:12 
AnswerRe: Multiple excel server problem Pin
Cool_Dev5-Aug-10 22:48
Cool_Dev5-Aug-10 22:48 
GeneralRe: Multiple excel server problem Pin
trioum5-Aug-10 23:54
trioum5-Aug-10 23:54 
GeneralRe: Multiple excel server problem Pin
Cool_Dev6-Aug-10 1:08
Cool_Dev6-Aug-10 1:08 
eventhough multple instances of excel are running, only the first instance would have an entry in ROT. But all the instances registers the documents opened in them in ROT. Its the key to bind to that instance of excel.
say, u have more than one instances of excel apps, and want to get the instance in which "MyExcel.xls" file is opened..

void GetMyExcelInstance()
{
	CApplication oExcelApp; //class wizard generated class for excel app

	CoInitialize(NULL);
	HRESULT hr;

	//Setup ROT
	IBindCtx *piBindCtx = 0; 
	hr = CreateBindCtx( 0, &piBindCtx ); 

	IRunningObjectTable *piROT = 0;
	hr = piBindCtx->GetRunningObjectTable(&piROT);

	//Enumerate registered objects
	IEnumMoniker *piEnum = 0;
	hr = piROT->EnumRunning(&piEnum);

	piEnum->Reset();

	ULONG nFetched;
	IMoniker *piMoniker = 0;

	bool bGot = false;
	while(piEnum->Next(1, &piMoniker, &nFetched) == S_OK && !bGot) 
	{
		// Get Display name, in our case can be the workbook (excel doc) name
		LPOLESTR strName;
		hr = piMoniker->GetDisplayName(piBindCtx, NULL, &strName);
		CString csName(strName);
		CoTaskMemFree(strName);

		if(csName.Find(L"MyExcel.xls") != -1) //or you may compare against full path of MyExcel.xls file
		{
			//Bind to the object. In this case object is excel workbook.
			IDispatch *piDispObj = 0;
			hr = piMoniker->BindToObject(piBindCtx, NULL, IID_IDispatch, (void**)&piDispObj);

			CWorkbook oWorkBook(piDispObj); //class for excel workbook object
			oExcelApp = oWorkBook.get_Application();
			
			bGot = true;

		}
		piMoniker->Release();
	}

	piEnum->Release();
	piROT->Release();
	piBindCtx->Release();

	if(bGot)
	{
		//do here with oExcelApp 

	}
}


do proper error checking.. Thumbs Up | :thumbsup:
GeneralRe: Multiple excel server problem Pin
trioum6-Aug-10 19:12
trioum6-Aug-10 19:12 
GeneralRe: Multiple excel server problem Pin
Cool_Dev8-Aug-10 0:22
Cool_Dev8-Aug-10 0:22 
Questionomp parallel for reduction (+: sum) computation discrepancies? Pin
Chesnokov Yuriy5-Aug-10 20:22
professionalChesnokov Yuriy5-Aug-10 20:22 
AnswerRe: omp parallel for reduction (+: sum) computation discrepancies? Pin
Peter_in_27805-Aug-10 21:08
professionalPeter_in_27805-Aug-10 21:08 
GeneralRe: omp parallel for reduction (+: sum) computation discrepancies? Pin
Chesnokov Yuriy5-Aug-10 21:59
professionalChesnokov Yuriy5-Aug-10 21:59 
QuestionHow to change audio output/input devices? Pin
odyaho5-Aug-10 17:29
odyaho5-Aug-10 17:29 
AnswerRe: How to change audio output/input devices? Pin
odyaho6-Aug-10 0:34
odyaho6-Aug-10 0:34 
QuestionIAccessible and tools like AccExplorer / Inspect Objects Pin
Member 38216205-Aug-10 14:53
Member 38216205-Aug-10 14:53 
QuestionWin32 Scheduled jobs Pin
Jach Mullan5-Aug-10 11:52
Jach Mullan5-Aug-10 11:52 
AnswerRe: Win32 Scheduled jobs Pin
Yusuf5-Aug-10 12:15
Yusuf5-Aug-10 12:15 
Questionwinsock connect() and how to reduce intial timeout value from, 3 seconds to 1 second or less Pin
Alan Kurlansky5-Aug-10 10:29
Alan Kurlansky5-Aug-10 10:29 
AnswerRe: winsock connect() and how to reduce intial timeout value from, 3 seconds to 1 second or less Pin
Moak5-Aug-10 12:50
Moak5-Aug-10 12:50 
Questioninput message injection on windows logon desktop Pin
linuwin5-Aug-10 3:47
linuwin5-Aug-10 3:47 
QuestionOpenMP concurrency issues Pin
Chesnokov Yuriy5-Aug-10 0:53
professionalChesnokov Yuriy5-Aug-10 0:53 
AnswerRe: OpenMP concurrency issues Pin
Aescleal5-Aug-10 2:21
Aescleal5-Aug-10 2:21 
QuestionOpenMP performance inconsistency on i7 Pin
Chesnokov Yuriy5-Aug-10 0:48
professionalChesnokov Yuriy5-Aug-10 0:48 
AnswerRe: OpenMP performance inconsistency on i7 Pin
Sauro Viti5-Aug-10 0:58
professionalSauro Viti5-Aug-10 0:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.