|
I'm writing a program which uses a derived classe of CSocket to handle incoming data. I have overloaded OnReceive to catch the new data. My question is this.
In my OnReceive function, I read the data and possibly do something with it. The doing something can take a little time. I'm wondering if OnReceive can be called while I'm still processing a previous OnReceive and thus interrupting my processing.
If it can, what kind of protections can I setup to protect the data I access in the function?
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
u are just one thread right?? Or multithreading?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Currently the application is single threaded. My question was, si there a possibility that MFC events or whatever they are called, can they overlap. Or will only one be called at any given time
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
nope the cant, cos ur single threaded.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
How in the world can i get this to work
if i use IXMLDOMNode in the idl it compiles
if i use the using namespace in the c++ code i'm still good
however the headers created from the idl result in the following:
error C2872: 'IXMLDOMNode' : ambiguous symbol
Help!
|
|
|
|
|
In your idl file,
#include "msxml2.idl";
This will help MIDL solving type, while not including this idl in the type-library.
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Tried that and all i get from midl is
error MIDL2025 : syntax error : expecting an interface name or DispatchInterfaceName or CoclassName or ModuleName or LibraryName or a type specification near
idl = [id(1), helpstring("method TestXml")] HRESULT TestXml(IXMLDOMNode *pIXMLDOMNode);
atl class method = STDMETHOD(TestXml)(IXMLDOMNode *pIXMLDOMNode);
|
|
|
|
|
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");
}
|
|
|
|