|
There's only one error in the actual code. The CComPtr is a template class, and should be declared accordingly. Either you have forgotten the < and > signs or the forum is not displaying them. Anyway they should be there.
The linker errors are generated because the GUIDs you define do not explicitly state the precise GUID numbers you wish to use. I couldn't find the IIOConverter interface definition from anywhere, so more than likely you have forgotten to link with the static library that defines these interfaces, or have forgotten to include a necessary header file. Check your settings.
There doesn't seem to be other errors. If you need more help, you need to paste the entire DEFINE_GUID macros, and not just "..." as they might cause the errors as well. Also, you have not defined the IID_IIOConverter properly, thus the error. You can use __uuidof( IIOConverter ) if you don't know the interface's GUID, but know the interface name.
Also remember that in order to use the CComPtr class, include atlcomcli.h. To use CoInitializeEx, include objbase.h and link with ole32.lib. Remember that these are Platform SDK features, so you need to define the correct versioning macros as well. For more information, see MSDN with "Platform SDK, Using the Platform SDK" index word.
Hope this helps
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi Dear,
I've added MS Chart Control ActiveX by Project=>Add to Project=>Companent & selected register control. That added lot of classes in my project.
Now I want to remove that ActiveX & their classes. How to do this?
Thanks
---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
Remove the Classes. The Classes are not the control itselfe. They just interface it.
Hardy
|
|
|
|
|
Hi ,
I want to fancy window style with 3D Title bar and.
Guide me.Thank You.
|
|
|
|
|
|
Hi everyone,
Can anyone give me the sample source code how to perform serial communication in VC++?
Please guide me.
With thanks
War War....
phoophoo2004@indiatimes.com
|
|
|
|
|
|
|
Hi,
I'm trying to convert a tm structure (which has already been adjusted to GMT) into a time_t.
The mktime function adjusts for timezone but this is not what I want.
libc includes _mkgmtime (doesn't seem to be documented) but msvcrt does not.
Is there any easy way I can do this without copying the _make_time_t function from mktime.c (the common code for mktime and _mkgmtime) with all it's dependent bits.
Thanks.
|
|
|
|
|
I want to emmbed Flash (*.swf) into Visual C++ project but i don't know. Can you help me, please????????
Thank you very much!!!!
my email: quocbaonguyen@gmail.com
|
|
|
|
|
Hello,
If you are using VC6,
at the menu bar:
[Project]
[Add To Project]
[Components And Controls]
An explorer-like window(Components and Controls Gallery) will appear.
At the folder
"Registered ActiveX Controls"
select the
"Shockwave Flash Object" file and then press [Insert]
When you go back to Resource View, the activeX control for Macromedia Flash is already added to the controls tool bar.
goodluck.
|
|
|
|
|
I use code which downloaded at "http://codeguru.com/Cpp/I-N/network/networkinformation/article.php/c2441/" for my project but i can't enumerate my network.
Because my entire network (in Explorer) can't view my workgroups. I can find any computer and access any computer by "\\computer's name" in my network.
I want to enumerate my network. Can you help me? Help me, please!!!!!
Thank you very much!!!!!
my email: quocbaonguyen@gmail.com
|
|
|
|
|
Hey Guys,
I am new to the whole world of C++ and have been studying a few samples / examples off the web of C++ coding etc. I made a short code / program called "The Namorizer" which is a console program that asks for your first name, then your last and finally adds them together and displays the result i.e your full name.
What I am trying to accomplish here is to do the same thing but with a windows form. I have designed the form in VS2k3 and now would like to add the code to the various textboxes etc for the events. I am kind of lost at this point of what to do and would like someone with patience and skills in communication just to spend a few minutes explaining where I would put this and also perhaps providing me with links to good sites and tutorials to learn from.
Thank you in advance for any help you can give.
neo.
|
|
|
|
|
Basically, you need to decide how it will all work. The most simple way is to set up two text boxes, call them tbFirst and tbLast ( for example ), then add a button. Double clicking on the button in the designer will create a handler in your code for the button being clicked, although giving it a meaningful name first will mean the function will have a useful name. First create a label, and call it lblName ( for the sake of the example ). Now, from memory, what you need to do in your handler is something like
lblName.SetWindowText(tbFirst.GetWindowText()+ " " + tbLast.GetWindowText());
I'm a long way from C++ land though, let alone MFC, so I could have some of the details wrong.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Good answer to most is read:
SAMS - Teach Yourself Visual C++ In 21 Days.pdf
|
|
|
|
|
I have a Byte buffer that I'm receving data into from an CAsyncSocket call (Receive)
BOOL bRetCode;<br />
DWORD dwBytesToRead;<br />
<br />
bRetCode = m_sConnectSocket.IOCtl(FIONREAD, &dwBytesToRead);<br />
<br />
BYTE* RecvBuffer = new BYTE[(int)dwBytesToRead];<br />
<br />
m_sConnectSocket.Receive(RecvBuffer, sizeof(RecvBuffer));<br />
<br />
onParseData(RecvBuffer, sizeof(RecvBuffer));<br />
In my onParseData function I'm trying to parse out the data. I know that certain parts of the data stream are a fixed length. So I created a structure.
struct ParseData{<br />
BYTE STAP[4]; <br />
BYTE BlockLen;<br />
BYTE HDRLen;<br />
BYTE FunctionCode;<br />
BYTE ValField;<br />
BYTE DataLen;<br />
BYTE MsgStatus;<br />
BYTE Dest;<br />
char* DataPacket;<br />
BYTE STOP[4];<br />
};<br />
ParseData myStuff;<br />
memcpy(&myStuff, dataBuffer, sizeof(myStuff));<br />
My problem is that I feel that this is not going to work and that I get an exception error because of the char* DataPacket; .
And I'd love to make my sturcture like this:
struct ParseData{<br />
BYTE STAP[4]; <br />
int BlockLen;<br />
int HDRLen;<br />
int FunctionCode;<br />
int ValField;<br />
int DataLen;<br />
int MsgStatus;<br />
int Dest;<br />
char* DataPacket;<br />
BYTE STOP[4];<br />
};<br />
I just want some direction in to where I need to go to find out:
1. How do I move this BYTE array into this structure?
2. Is there a simple way to just pull out certain parts of the data stream and plop it into the structure? example...move the first 4 bytes to the STAP the second 4 to the BlockLen...etc.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
The problem is that a char * is the address where an array of char's can be found. In unpacking your data, you need to work out how long the string is, call new on the char * in the struct, and then assign the value. If I were you, I'd put a std::string in the struct instead, that way you don't need to clean up memory.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian
Thanks replying so quickly. So here is the embarassing part. My main programming language is COBOL. So this structure thing is new to me. When you say to put a std::string in the struct.....what do you mean by that?
I do understand what you are saying that the char* needs to be initialized with the length that it needs to be....and the DataLen is the size of this array....but, even if I know this amount......will me doing a memcopy easily convert the data stream to the appropriate typedef? From a BYTE to an int or a char?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
So this structure thing is new to me.
A structure is just a class, under the hood the only difference is that members of a struct are public by default, members of a class, private by default.
Tom Wright wrote:
When you say to put a std::string in the struct.....what do you mean by that?
The problem with allocating a pointer is that you need to clean the memory afterwards. A std::string is probably overkill, a struct (being a class) can have a destructor, which can clean the memory for you. Something like this:
struct MyStruct
{
char * theString;
MyStruct()
{
theString = NULL;
}
~MyStruct()
{
if (theString)
delete [] theString;
}
}
I'm a long way from the last time I used C++, so there may be some syntax problems there.
A std::string is a class offered by the standard C++ library, which allows you to manipulate strings. Overkill in this case, especially if you're building a lot of them. To use it, you would put #include<string> at the top of your .cpp file, and then using std::string; somewhere underneath.
Tom Wright wrote:
will me doing a memcopy easily convert the data stream to the appropriate typedef? From a BYTE to an int or a char?
A byte is a char. So yes, so long as your string is NULL terminated ( ends with a 0 ), you can just call new on the char * to allocate memory, then do a memcpy across to it. If it's not null terminated, just add one to the size of the array you create, call memset on it to null it all, then copy the string in.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
What I did when I faced a similar problem is this:
#pragma pack(1) // This is important, otherwise your compiler might allign things wrong
struct ParseDataStruct{
BYTE STAP[4];
int BlockLen;
int HDRLen;
int FunctionCode;
int ValField;
int DataLen;
int MsgStatus;
int Dest;
char DataPacket[MaxSize+4]; // inlucdes the 4 STOP bytes
};
#pragma pack()
class ParseData {
protected:
ParseDataStruct Data;
public:
ParseData(BYTE * DataIn) { // constructor, pass a pointer to the data
ParseDataStruct *in = (ParseDataStruct *)DataIn; // my compiler is old and doesn't support the new C++ casts well, you should use them instead
memcpy(DataIn,&Data,in->BlockLen); // check the length of this copy
}
enum msgStats { ...}
enum FunctCode { ... }
msgStatus getMsgStatus();
FunctCode getFunctionCode();
char * getDataPacket();
...
}
That is create a class to wrap the whole thing. This class knows who things are represented. It can even pull the STOP bytes out if you need them, even though the data is variable length.
I'm sure there is a different way, and it might even be better. Thats just what I've done.
|
|
|
|
|
I'm trying to let the user change a dialog's font at runtime. It keeps crashing on me in "wingdi.cpp". this is what I have so far:
memset(&m_Font, 0, sizeof(LOGFONT));
CFont* pFont = this->GetFont();
pFont->GetLogFont(&m_Font);
CFontDialog dlg(&m_Font);
dlg.m_cf.Flags |= CF_TTONLY;
if(dlg.DoModal() == IDOK)
{
dlg.GetCurrentFont(&m_Font);
pFont->CreateFont(m_Font.lfHeight,m_Font.lfWidth,m_Font.lfEscapement,m_Font.lfOrientation,m_Font.lfWeight,m_Font.lfItalic,m_Font.lfUnderline,m_Font.lfStrikeOut,m_Font.lfCharSet,m_Font.lfOutPrecision,m_Font.lfClipPrecision,m_Font.lfQuality,m_Font.lfPitchAndFamily,m_Font.lfFaceName);
this->SetFont(pFont);
}
Note: at first I had pFont->CreateFontIndirect(&m_Font) but it crashed in the same place.
[insert witty comment here]
bdiamond
|
|
|
|
|
bdiamond wrote:
CFont* pFont = this->GetFont();
bdiamond wrote:
pFont->CreateFont(
There's the problem. You are trying to create a font on an object that already has a valid font created. You'll have to create a class member of type CFont , delete the font (DeleteObject() ) when you're finished with it, and recreate it with the new font information.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I didn't get my e-mail notification from this thread so I thought nobody had answered it. I've gotten the font to change for the edit control, but now all the other controls on my dialog also change their fonts. Not to the font I selected, but to some ugly bold default system font. It's as if I have no font selected. Instead of initializing the CFontDialog with my control's current font, I used the dialog's just to see what it was. The first time, the right font is selected when I open the dialog. (10pt Tahoma) after I set the controls font once and open it again with the dialog's current font, nothing is selected as if my dialog has no font. this is what I have now:
ZeroMemory(&m_Font,sizeof(LOGFONT));
CFont* pFont = m_LockEdit.GetFont();
pFont->GetLogFont(&m_Font);
CFontDialog dlg(&m_Font);
dlg.m_cf.Flags |= CF_TTONLY;
if(dlg.DoModal() == IDOK)
{
LOGFONT lgfnt;
dlg.GetCurrentFont(&lgfnt);
m_cFont.DeleteObject();
m_cFont.CreateFontIndirect( &lgfnt );
m_LockEdit.SetFont( &m_cFont, TRUE );
pFont->DeleteObject();
}
[insert witty comment here]
bdiamond
|
|
|
|
|
bdiamond wrote:
pFont->DeleteObject();
You shouldn't delete the font that is still selected as the dialog box font, otherwise it will look like there's no font selected (and use the default system font). When you used GetFont() , you got a pointer to the current font, not a copy of the font, so if you delete it, you delete the font that the dialog box is still using. Other than this line, your code should work properly.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi there,
How do I add a help (?) button to the title bar of a child MDI window? Also, how can I remove the minimize and maximize buttons leaving only the help and close button just like in a dialog box.
Thanks!
|
|
|
|
|