|
Although I don't know exactly what you are trying to accomplish, I would think you would just want to overload the function with different parameters.
For Example:
<br />
void MyFunction(strHeader tStruct)<br />
{<br />
}<br />
void MyFunction(dataStruct tStruct)<br />
{<br />
}<br />
Dustin
|
|
|
|
|
hi... thanks for the replies!
the idea in having the structs header and data is because the receiving end of the pipe have no idea how many data structs will be sent... thus the header contains the count of data structs. it will be written on the pipe together (header and data) and will be read by the other end of the pipe... the problem i have is how to code it efficiently...
i figured maybe i can just call readfile twice... read the header first and then the data.. since the header will also contain the size of the data struct sent..
for any better ideas pls do reply!
thanks again!
newbie
|
|
|
|
|
ginjikun wrote: i figured maybe i can just call readfile twice... read the header first and then the data.. since the header will also contain the size of the data struct sent..
Often, that's the only way to do it with pipes, sockets, etc. and a protocol that supports
variable length data.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all:
First ,I declare three variables:
IXMLDOMDocumentPtr pXMLDoc;
IXMLDOMNodePtr pNode=NULL;
HRESULT hr;
hr=pXMLDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60));
hr=pXMLDoc->loadXML(_bstr_t(sPath+"MAPDOMAIN.xml"));
The variable of hr shows that the pXMLDoc has been loaded successfully,and pXMLDoc is not NULL.But,I use pXMLDoc ::selectSingleNode:
pNode=pXMLDoc->selectSingleNode(_bstr_t("MAPDOMAIN"));//MAPDOMAIN is RootNode
The strange thing is that the pNode is NULL ,how can that happen?
My XML file is like this:
?xml version="1.0" encoding="gb2312"?>
<!--njnu-->
<MAPDOMAIN>
<DEVELOPMENTZONEDOMAIN>
<XMIN>135400</XMIN>
<YMIN>155900</YMIN>
<XMAX>141600</XMAX>
<YMAX>161600</YMAX>
</DEVELOPMENTZONEDOMAIN>
<AINDEXINFOFIELDNAME>
<OWNID></OWNID>
<MAPLEFT></MAPLEFT>
<MAPUPPER></MAPUPPER>
<MAPRIGHT></MAPRIGHT>
<MAPLOWER></MAPLOWER>
<UPPERLEFT></UPPERLEFT>
<UPPERRIGHT></UPPERRIGHT>
<LOWERLEFT></LOWERLEFT>
<LOWERRIGHT></LOWERRIGHT>
<INSERTFLAG></INSERTFLAG>
</AINDEXINFOFIELDNAME>
</MAPDOMAIN>
-- modified at 21:23 Saturday 14th April, 2007
|
|
|
|
|
You are assuming the XML document starts at the Document Element. Your XPath should be "/MAPDOMAIN".
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Sorry,I didn't understand very well,do you think the the code
pNode=pXMLDoc->selectSingleNode(_bstr_t("MAPDOMAIN"));
shoud be replaced by
pNode=pXMLDoc->selectSingleNode(_bstr_t("/MAPDOMAIN")); ?
Thanks!
|
|
|
|
|
Yes. The "/" is the actual root and "MAPDOMAIN" is a child of the root or the Document Element in this case.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I'v tried what you said,but the value of pNode is still NULL.
|
|
|
|
|
I'v tried what you said,but the value of pNode is still NULL.
and Could you tell me the difference between Load and LoadXML?
When I use LoadXML,it's successful,but the Load is failed,why?
Thanks a lot!
|
|
|
|
|
"LoadXML" loads the XML document from a string and "Load" from a file. I wrote some code to load from a file:
#ifdef _DEBUG
#pragma comment(lib, "comsuppwd.lib")
#else
#pragma comment(lib, "comsuppw.lib")
#endif
#include <stdio.h>
#include <tchar.h>
#import <msxml6.dll>
using namespace MSXML2;
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
HRESULT hr;
IXMLDOMDocumentPtr pXMLDom;
hr = pXMLDom.CreateInstance(__uuidof(DOMDocument60));
if (FAILED(hr))
{
printf("Failed to instantiate DOMDocument80 class\n");
return -1;
}
pXMLDom->async = VARIANT_FALSE;
if(pXMLDom->load(L"MapDomain.xml") != VARIANT_TRUE)
{
printf("Failed load xml data from file.\n%s\n",
(LPCSTR)pXMLDom->parseError->Getreason());
return -1;
}
IXMLDOMNodePtr pNode = pXMLDom->selectSingleNode(L"/MAPDOMAIN");
if (pNode == NULL)
{
printf("Invalid node fetched.\n%s\n",
(LPCSTR)pXMLDom->parseError->Getreason());
}
else
{
printf("Result from selectSingleNode:\nNode - <%s>:\n",
(LPCSTR)pNode->nodeName);
}
pNode.Release();
pXMLDom.Release();
CoUninitialize();
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-- modified at 23:52 Saturday 14th April, 2007
|
|
|
|
|
Thank you very much!The problem is solved!!!
Thanks!
|
|
|
|
|
Also, make sure the pathname to your xml document is correct. An incorrect pathname could cause it to fail.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
In a Win32 app I am able to set global keyboard hooks, but not a local hook. I've coded the call as required for a local hook but it complains that GetCurrentThreadID can't be found. But I see that winbase.h (invoked by windows.h) contains the following declaration of GetCurrentThreadId:
WINBASEAPI
DWORD
WINAPI
GetCurrentThreadId(
VOID
);
The following call setting a global hook works fine:
HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc,
hinstExe,
0);
The identical pgm with the following call setting a LOCAL hook fails:
HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc,
NULL,
GetCurrentThreadID());
The error it gives is:
error C3861: 'GetCurrentThreadID': identifier not found, even with argument-dependent lookup
I've seen docs saying that GetCurrentThreadID is deprecated, but there's no alternative given. Surely there must be some way a thread can find out its own thread id, but I haven't been able to find out how. I'm using VS 2003 tools.
Any ideas anyone?
Many thanks in advance!
glyfyx
|
|
|
|
|
Try changing ID to Id.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
glyfyx wrote: I've seen docs saying that GetCurrentThreadID is deprecated
As of Platform SDK R2, it's not marked deprecated.
And, it's GetCurrentThreadId
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks Mark - very much!!
That's what I get for spending the last several years doing VB!
I won't do that again - even once is too often!
Thanks again..
glyfyx
|
|
|
|
|
glyfyx wrote: I won't do that again
I wish I could say the same. That's my #1 typo! It'll always be ID to me, apparently.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
For the sake of closure on this thread, if you exactly follow Microsoft's rules to set a LOCAL low-level keyboard hook don't expect it to run because Microsoft forbids its execution.
According to Microsoft the following will result in a setting a LOCAL hook:
HHOOK hhkLowLevelKybd = SetWindowsHookEx( WH_KEYBOARD_LL,
HookProc, NULL, GetCurrentThreadId());
However, it fails execution, returning NULL.
I took the trouble to rerun it in order to get extended error information and got this surprising formatted error message in a MessageBox:
"SetWindowsHookEx failed with error 1429: This hook procedure can only be set globally."
Do I laugh or cry?
|
|
|
|
|
glyfyx wrote: "SetWindowsHookEx failed with error 1429: This hook procedure can only be set globally."
That is documented under SetWindowsHookEx in the SDK. Low-level keyboard hooks key events before
they are dispatched to a given thread message queue so it makes sense.
glyfyx wrote: Do I laugh or cry?
I try to cry first, then laugh. If it happens the other way around I'm in trouble
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I have a form (in PDF) that I want to print. Its
a small form, only a quarter of a sheet of paper.
I can make lines match with the form but when I
print text, there the font look the same size, but
the fonts on the original form are more spaced out
and a sentence will look longer.
Any ideas on how I can print a form precisely so
that it will look absolutely identical? I can convert
it to a bitmap and print text on top of the bitmap
but that prints slowly. If I go into the PDF file, I
can see what font was used and what the spacing was.
I just dont know how to mimic that programmatically
in my own program.
Any ideas any one has will be greatly appreeciated.
Sincerely,
Danielle Brina
|
|
|
|
|
Danielle,
Printer drivers and/or printers have to translate the PDF code (which I believe is based on postscript) to approximate what you see on the display. Very seldom, there is a one-to-one relationship with the fonts stored on the printer (an ink jet printer won't have stored fonts and depends on the printer driver to renderings) with those used in the PDF or with the capabilities of the printer. So, if you managed to get that "perfect" output on one printer, you may not be able to duplicate it on another printer or duplicate the same result on the same printer after making modifications to the PDF.
George
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
DanYELL wrote: If I go into the PDF file, I
can see what font was used and what the spacing was.
I just dont know how to mimic that programmatically
in my own program.
Any ideas any one has will be greatly appreeciated.
I have found that when programmatically converting my GDI calls to specific PDF postscript commands, that utilizing GDI+ for some metric calculations allows for the closest approximations. By mixing GDI and GDI+, I can render the drawing primitives on screen, to the printer, and translate those commands to PDF postscript with a fair level of accuracy. GDI+ really comes in handy for glyph/font rendering/calculations/placement and handling the various image formats and converting the bits to PDF image streams.
However, you appear to want to consume a PDF, modify it, and then write it back to the binary stream to print it. Creating PDF's is no easy task. Parsing a PDF binary stream (correctly) is a task not for the faint hearted. Take a look at the PDF Reference Version 1.7[^] and you'll see what I mean.
Adobe employs some very talented, but I must add, very unique and interesting characters in their company. When struggling with the PDF Reference, I get the feeling that the individuals are some of the most hardcore academic types and mathematical purists you will find outside of the 3D programming community. The reference severely lacks a practical side (There are hardly any examples in the book) and the PDF is a binary/indexed file so examples can't just be typed into notepad and viewed making those first steps completely unbearable.
George L. Jackson provided a friendly warning about fonts and I would have to agree 100%. When dealing with PDF postscript, you get forced to get very intimate with glyphs, glyph spacing, font files, font metrics, glyph terminology, GDI font functions from the bowels of Windows, font embedding, font embedding licensing issues, multiline vertical text placement (you have to draw each line of text individually), font substitution (Not all fonts you use will be installed on every machine your PDF will be viewed on), synthesizing strikeout and underlining (There is no such concept in glyph design. You have to synthesize these effects. GDI always provided this so we tend to take it for granted), etc...
I'm not trying to discourage your quest. I am just providing a friendly word of caution to let you know of the perils that lie ahead should you choose to accept your mission. I have found that most people who have already gone down the road of writing PDF writers/converters/readers are not very willing to share their experiences or insights. Usually, they'll recommend you use one of their libraries instead. PlanetPDF is a good example of a site where novice PDF programmers' questions are not answered, but merely used as an opportunity to promote the well established PDF library writers products.
Just for a reference, it took me about 6 long months to get a GDI to PDF writer completed. I still had to skip things like digital signing, annotations, various redundant encoding schemes, and a long list of available items I did not need to use during PDF creation but things I would most definitely need if I were to attempt to consume/read any arbitrary PDF that was already written.
Sorry about the long post. I hope it helps somehow.
|
|
|
|
|
Hello,
I need to write a MFC application to access a camera attached to a USB port.
I am completely new to VC++ and MFC applications.
Could anyone please give me a correct direction to start in?
Thank you.
|
|
|
|
|
I would start with an activeX control - You may have one installed on your computer that will work or you may be able to find one.. get it working with the control to get an idea of whats involved.. On my computer I have an ActiveX control for FTI Device Digital USB Control and snapshot Viewer Control and yahoo! web cam viewer -
just start with a dialog box - in visual c++ 6.0 you can right click it and choose insert activeX..
If you don't have any camera activex - you may be able to download one..
-- modified at 23:46 Saturday 14th April, 2007
Check this page for USB help-
http://www.codeproject.com/system/HwDetect.asp[^]
|
|
|
|
|