|
Ok, I have found the issue. The version of msxml.idl shipping with VC++6 and VS.NET is MSXML2. And the idl provided does not include the declaration of IXMLDOMNode.
You need MSXML3, and higher. Download the SDK here[^].
I just did a test, it went fine with import "msxml2.idl"; . I had also to make sure this file msxml2.idl supersedes msxml.idl from the included header directories.
PS : I would suggest you don't marshall IXMLDOMNode* at all, just a void* instead. And then you do a proper QI or cast in the implementation code.
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Hello:
I'm having problems trying to add a serie to a chart. This piece of code illustrates my problem:
_ChartPtr pChart= pCharts->Item["G1"]; // Get an existing chart (OK)
_WorksheetPtr pWorksheet= pWorksheets->Item["S1"]; // Get an existing worksheet (OK)
SeriesCollectionPtr pSeries= pChart->SeriesCollection(); // Get its series collection (OK)
RangePtr pRangeSector1= pWorksheet->Range["$C$5:$C$8"]; // Get a worksheet range (OK)
// I am only trying one of these lines
// Line 1
SeriesPtr pSerie1= pSeries->Add((IDispatch *)pRangeSector1, Excel::xlColumns); // Try to add a serie (exception launched)
// Line 2
SeriesPtr pSerie2= pSeries->Add("C5:C8", Excel::xlColumns); // Try to add a serie (exception launched)
Where is the mistake?
Thanks in advance.
|
|
|
|
|
I have a class say, CClass thats inherts from two abstract interface definition classes, say IInterface1 and IInterface2. I have a vector of IInterface1 pointers and a vector of IInterface2 pointers. If the pointer of CClass is added to both these vectors, is there a smart pointer inplemenataion that would delete CClass, only when pointers in both vectors are deleted?
I am not very familiar with smart pointers, but was curious to know whether smart pointers would work in this case. I am looking for a generic C++ solution, not a COM or MFC based solution.
I looked at shared_ptr in boost.org, but could not make a judgement about this from the docs and examples.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
I have a map of int, int.
Someone told me that this statement below will create the element of index n1 and fill it with n2:
n2 = myMap[n1];
instead of the othe way around which works as well. THe benefit of the above method is that if that element already exists in the map, then in one shot we either accessed it (pree-exist) or created it (wasnt there). Seems so counterintuitive. Is it ccorrect? Didnt see anything like it in my books...
Appreciate your help,
ns
|
|
|
|
|
myMap[n1] = n2; SHOULD work, ie create an entry if it does not already exit
n2 = myMap[n1]; SHOULD NOT work, it should create an entry if it does not exist and give n2 its value.
|
|
|
|
|
Okay.But if myMap[n1] just got created its empty right? So n2 = 0.
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
Someone told me that this statement below will create the element of index n1 and fill it with n2
it's not true, and you can prove it with the code below.
map<int, int> myMap;
int t = 50;
t = myMap[10];
map<int, int>::iterator it;
for (it=myMap.begin(); it!=myMap.end(); it++)
{
printf("%d, %d\n", (*it).first, (*it).second);
}
the output is 10, 0; not 10, 50.
it will create the element, but the value part of it is the default value for the object (for an int, i guess the default is 0, in debug mode anyway).
if you want to set the value, you have to use : myMap[10] = 50;
-c
All you have to do is tell the people they are being attacked, and denounce the opposition for lack of patriotism and exposing the country to danger.
-- Herman Goering, on how to control the public
|
|
|
|
|
Many thanks. Clear now.,
Appreciate your help,
ns
|
|
|
|
|
Hi all.
I have a application writen in VC++. I need to execute a script file on a server in it. Did any one know how to do it?
Thanks for any clue.
Tida
|
|
|
|
|
What kind of script file... like an NT command script, or ??
If all you need to do is execute a cmd script remotely, you can do that without any code. Look at soon.exe in the NT reskit, which will let you execute cmd scripts on remote servers.
Otherwise, via C++ you can launch a cmd script like this:
ShellExecute( NULL, "open", "c:\\my_script.cmd", NULL, "c:\\", SW_SHOWNORMAL );
Take a look at MSDN for descriptions of the parameters to ShellExecute.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Does anybody have a sample or idea about how to get image in coordinates of the mouse pointer ?
thank you !
|
|
|
|
|
Hi, I've got a VC6.0 project, and I exported a MAK file for it using VStudio. I want to MAKE the project using the MINGW (Minimalist GNU for Win32) package. Is it possible to use the MAK file that VStudio creates and pass it on to mingw32-make.exe somehow?
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
You can import the .dsp to create an MINGW project. I haven't got MINGW at work so I can't tell you exactly what the menu are, but it's under File - Import(maybe)
NB! If you're using MFC then you're out of luck!
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
Is there a maxsize limit I can specify on a STL queue container? I seem to remember that some of the other container objects had a maxsize attribute or function to set the size.
I've done some searching on the web and couldn't find anything relevant.
A second question. If there is a maxsize limit, when I do a push() onto the queue, what kind of error will it generate to let me know that it is already full?
Ok, people may be wondering why I need a maxsize limit. I have an object that displays data onscreen that will update with new data on a timer event. The data will be put into a queue. I am also recording the data (rcvd from network) to disk - high priority, and displaying statistics (lower priority) and displaying the data (lower priority). If the data to be displayed gets too old (e.g. the queue is full), I want to display a status message.
|
|
|
|
|
There isn't a max_size limit. There is a max_size() function in the vector and list containers, but they are merely measurements of how many actual elements you can store; it's not something you can purposefully set.
My suggestion would be to check the current size (via the size() method) of the queue before doing a push. If it's already at your maximum size, do your error code there and skip the push.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Yeah, that's what I figured. I guess I could subclass queue and override the push method.
BTW, I thought the max_size function was not the amt of items currently stored, I thought it was size() that returned that and max_size returned the max limit of what you could store.
|
|
|
|
|
Correct; max_size() is the number of elements that can be stored, and never changes regardless of insertions or deletions. size() is the number of elements currently stored, and of course changes with every insert and delete.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Greetings,
I need to get an HWND but all I have is an HINSTANCE. There must be some simple way to make the conversion but my brain is blocked. This can't be that difficult!
What I am doing is using ShellExecuteEx() to open up a PDF file. I then want to send keyboard messages to this new process to make it go to Page XXX.
(Yes, I know that if I had the full Acrobat I could do this with OLE or even DDE. But I don't. And the alleged pdf ActiveX control is only intended to work within a browser. Sigh...)
I need to be able to take the hProcess field from the SHELLEXECUTEINFO, as filled in by ShellExecuteEx(), and use it to wait for the new process to stabilize and then send the appropriate WM_KEYDOWN and WM_CHAR messages.
Failing that, I would like to be able to enumerate all the windows and find the one corresponding to the one I spawned. I am looking for a general solution rather than looking for a window containing "Acrobat Reader" in its title bar.
Can anybody give me a clue?
Thanks a lot!
void CIOGuidesView::OnButton1()
{
CString filename("PDF Files\\751018a.pdf");
HANDLE hProcess = NULL;
SHELLEXECUTEINFO shellInfo;
::ZeroMemory(&shellInfo, sizeof(shellInfo));
shellInfo.cbSize = sizeof(shellInfo);
shellInfo.lpVerb = "open";
shellInfo.lpFile = filename;
shellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
if(::ShellExecuteEx(&shellInfo))
{
hProcess = shellInfo.hProcess;
}
else
{
ShowLastError("ShellExecuteEx Failed");
return;
}
int reason = WaitForInputIdle(hProcess,INFINITE);
switch(reason)
{
case 0:
MessageBox("subprocess now accepting user input");
break;
case WAIT_TIMEOUT:
MessageBox("Wait timeout");
break;
case 0xFFFFFFFF:
ShowLastError("WaitForInputIdle Failure");
break;
}
char title[1000];
::GetWindowText((HWND)hProcess,title,sizeof(title));
MessageBox(title,"Subprocess Window Title");
}
|
|
|
|
|
Casting hProcess to an HWND will certainly not do what you want.
You may need to EnumWindows and examine each one somehow to see if it's the one you want. I can't think of a way to get a process handle or a process id from a window handle but there must be a way. Then for each window handle EnumWindows gives you you could just see if it belongs to the process you just started. Simple!
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
GetWindowThreadProcessId will give you the process ID/thread ID of the process/thread that created the window handle.
Chris Richardson
|
|
|
|
|
Chris,
Well, I tried enumerating all the windows and using GetWindowThreadProcessId() and it doesn't seem to give me the same process id as obtained from the SHELLEXECUTEINFO structure (updated by ShellExecuteEx()):
The enumeration callback:
class WININFO
{
public:
CWnd *hWnd;
HINSTANCE hInst;
CString title;
WININFO(CWnd *wnd = NULL, HINSTANCE inst = NULL) {hWnd = wnd; hInst = inst; title = "";}
};
typedef CArray<WININFO,WININFO> CArrayWinInfo;
BOOL CALLBACK CIOGuidesView::enumwndfn(HWND hWnd, LPARAM lParam)
{
CIOGuidesView *me = (CIOGuidesView *)lParam;
return me->enumwndfn(CWnd::FromHandle(hWnd));
}
BOOL CIOGuidesView::enumwndfn(CWnd * wnd)
{
WININFO wininfo(wnd);
wnd->GetWindowText(wininfo.title);
DWORD ProcessId;
GetWindowThreadProcessId (wnd->GetSafeHwnd(), &ProcessId );
wininfo.hInst = (HINSTANCE)ProcessId;
m_WinInfoArray.Add(wininfo);
return TRUE;
}
The ShellExecuteEx() call:
void CIOGuidesView::OnButton1()
{
CString filename("PDF Files\\751018a.pdf");
HANDLE hProcess = NULL;
SHELLEXECUTEINFO shellInfo;
::ZeroMemory(&shellInfo, sizeof(shellInfo));
shellInfo.cbSize = sizeof(shellInfo);
shellInfo.lpVerb = "open";
shellInfo.lpFile = filename;
shellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
if(::ShellExecuteEx(&shellInfo))
{
hProcess = shellInfo.hProcess;
}
else
{
ShowLastError("ShellExecuteEx Failed");
return;
}
int reason = WaitForInputIdle(hProcess,INFINITE);
And then I dumped all the windows whose title began with "Acro" OR those whose hInst matched my hProcess:
hProcess=0x01D8 hInst=0x045C title='Acrobat Reader'
If I understand this, the hProcess and hInst values should have been identical.
Ideas?
|
|
|
|
|
The HINSTANCE is not the same as the ID of the process. What you need to do, is use the ID of the process to get a handle to the process, which can be compared directly to the hProcess member of SHELLEXECUTEEX. Something like this:
BOOL CIOGuidesView::enumwndfn(CWnd * wnd)
{
WININFO wininfo(wnd);
wnd->GetWindowText(wininfo.title);
DWORD ProcessId;
GetWindowThreadProcessId (wnd->GetSafeHwnd(), &ProcessId );
HANDLE a_hProcess = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, ProcessID );
wininfo.hInst = (HINSTANCE)a_hProcess;
m_WinInfoArray.Add(wininfo);
return TRUE;
}
Chris Richardson
|
|
|
|
|
Chris Richardson wrote:
Why not close it immediately? Once you got the handle all you need it its value to use for comparison, you don't need to do anything else with it.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Whoops. I guess I had a momentary lapse of brain activity .
Chris Richardson
|
|
|
|
|
Chris,
I suspected I was mixing apples and oranges. But it still doesn't seem to work.
BOOL CIOGuidesView::enumwndfn(CWnd * wnd)
{
WININFO wininfo(wnd);
wnd->GetWindowText(wininfo.title);
DWORD ProcessId;
GetWindowThreadProcessId (wnd->GetSafeHwnd(), &ProcessId );
HANDLE a_hProcess = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, ProcessId );
wininfo.hInst = (HINSTANCE)a_hProcess;
CloseHandle(a_hProcess);
m_WinInfoArray.Add(wininfo);
return TRUE;
}
This still yields no exact matches on hProcess (from ShellExecuteEx) and a_hProcess (from OpenProcess).
I am beginning to wonder if AcroRd32.exe does something especially weird. I'll try something with another type of file...
I appreciate you looking at this. It has me bamboozled!
|
|
|
|