|
Hi Nishant and thanks.
I already read 'A first look at C++/CLI' (forgot to vote then) and gave a 5 now (after 2 years!)
As a newbie I should say your articles are great alone, but together, well I need a more essential starter! Some thing to start with .net basics and it's usages for a c++ developers, benefits and how to impelements, all together. I think I need to read a book.
And, It's funny, you wrote most of the articles in C++/CLI. Author Nishant Sivakumar and I'm still scrolling ...
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
Hamed Mosavi wrote: well I need a more essential starter!
I am writing a book on C++/CLI now for Manning Publications. See my sig for more info. It'll be another 4 months before the book will become available though.
Regards,
Nish
|
|
|
|
|
|
Hamed Mosavi wrote: However I'll probably can't buy that:
Don't you have banks in Iran that issue credit cards? Even in India, we've had them for decades now.
Regards,
Nish
|
|
|
|
|
Hamed Mosavi wrote: From your signature, I found that out already and added a comment there;)
Yep, saw that.
Regards,
Nish
|
|
|
|
|
I have a .NET Control which I want to host in a CDialog. It's quite easy by including afxwinforms.h and having a member variable like this:
CWinFormsControl<mycontrol::controlclass> m_myControl
But the problem is that if I do something like this I have to include afxwinforms.h in my header file. I am including this header file in other classes and I dont want to enable clr for those classes.
Is there any workaround to this. I have tried something like having a CWnd* as a member variable and casting it to CWinFormsControl in .cpp but type-casting for CWinFormsControl doesnt work.
<font color="blue" size="1">
"Writing specifications is like writing a novel. Writing code is like writing poetry."
</font>
</mycontrol::controlclass>
|
|
|
|
|
Aamir Butt wrote: I have a .NET Control which I want to host in a CDialog. It's quite easy by including afxwinforms.h and having a member variable like this:
CWinFormsControl<mycontrol::controlclass> m_myControl
But the problem is that if I do something like this I have to include afxwinforms.h in my header file. I am including this header file in other classes and I dont want to enable clr for those classes.
Is there any workaround to this. I have tried something like having a CWnd* as a member variable and casting it to CWinFormsControl in .cpp but type-casting for CWinFormsControl doesnt work.
You could try a #ifdef _MANAGED block to declare the CWinFormsControl member.
Regards,
Nish
|
|
|
|
|
Wouldn't that change the class layout depending on who's including it?
For example, if I include the header in a .cpp that is compiled native, the class layout does not contain the managed memeber.
If I include the header in a .cpp that is compiled /clr, the class layout contains the managed memeber...
This means they are essentially two different classes with the same name...
The linker should emit an error in that scenario and not allow it... I haven't tried it though, so I might be wrong.
gmileka
|
|
|
|
|
georgeraafat wrote: Wouldn't that change the class layout depending on who's including it?
Yes, it would. A workaround would be to use a CWinFormsControl* member if it's managed compilation, and a dummy void* if it's unmanaged compilation. Thus the class layout is unchanged.
Regards,
Nish
|
|
|
|
|
Yes, this one looks good. Let me try it and then I will let you know if it works or not. Thanks for the reply.
"Writing specifications is like writing a novel. Writing code is like writing poetry."
|
|
|
|
|
Hi,
I couldnt use System namespace inside the MFC ActiveX control page. It says name space with this name doesnt exist. What should i do to use all the class like Convert etc...
|
|
|
|
|
sivaprakashshanmugam wrote: Hi,
I couldnt use System namespace inside the MFC ActiveX control page. It says name space with this name doesnt exist. What should i do to use all the class like Convert etc...
Please ask this in the Visual C++ forum. Sorry my bad! Didn't read your post properly.
To use the namespace and its classes, you need a reference to the containing assembly.
Regards,
Nish
Last modified: Thursday, May 25, 2006 2:32:19 PM --
|
|
|
|
|
I am trying to implement a simple smtp client server model to send and recieve messages to users on a lan where the users information and their message is stored in the sql database where this information is vaalidated once a request is sent by the client
i need to implement this in socket programming.Any experts please suggest
|
|
|
|
|
vaninathan wrote: I am trying to implement a simple smtp client server model to send and recieve messages to users on a lan where the users information and their message is stored in the sql database where this information is vaalidated once a request is sent by the client
i need to implement this in socket programming.Any experts please suggest
Please ask this in the Visual C++ forum.
Regards,
Nish
|
|
|
|
|
Hi,
I am using Visual Studio 2005 to develop an MDI application in C++/CLI. The application contains both child windows and non-child tool windows.
The child window(s) has a menu that integrates with the main application menu. The problem is that when a non-child tool window is active then I must click the menu (in the main application window) twice to activate it; once to activate the application (parent) window and a second time to activate the menu. If a child window is active then the menu operates with just one click. In the old version of my progam, which was developed in managed C++ under Visual Studio 2003, only one click was required to activate the main menu when a tool window was active.
This behaviour of my application is annoying and unprofessional. I was wondering if anybody had any ideas on how to fix this or what is causing it? Thanks!
zenzero
|
|
|
|
|
I guess that nobody has any ideas? Is this a bug in .net 2.0 or am I just being dumb?
May be I should try posting on the C# forum?
Any advice would be greatly appreciated.
|
|
|
|
|
Hi,
I've written a managed class that makes use of stl vectors of a few unmanaged structs for data handling/manipulation, but I'm getting a few very strange errors. I get an "Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object" occasionally when adding a new element to a vector. By occasionally I mean that the exact same code works fine most of the time, throwing the error around 1% of the time. Based on sample data that I'm feeding the program, the errors occur on the exact same data every execution, but I don't see anything wrong with the offending data or the code. Can someone help? Even if you only have a vague idea of something I can look into, please let me know.
Here's the relevant code snippet:
// if a headline occurs after a normal paragraph, split the block there
for (int i = thisDoc->blocks.size() - 1; i >= 0; i--)
{
block* curBlock = &thisDoc->blocks[i];
if (curBlock->type == blockType::text)
{
// search through all the paragraphs (from end to start)
bool lastWasHeadline = false;
for (int j = curBlock->paragraphs.size() - 1; j >= 0; j--)
{
// is this paragraph a headline?
if (curBlock->paragraphs[j].type == paragraphType::headline)
lastWasHeadline = true;
else
{
// did we just leave a headline?
if (lastWasHeadline)
{
// split the remainder of the block into a new block
block newBlock;
newBlock.type = blockType::text;
for (int k = curBlock->paragraphs.size() - 1; k > j; k--)
{
newBlock.paragraphs.insert(newBlock.paragraphs.begin(), curBlock->paragraphs[k]);
curBlock->removeParagraph(k);
}
//!!!!!!!!!!!!!!!!!!ERROR!!!!!!!!!!!!!!!!!!
//Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
thisDoc->addBlock(newBlock);
//!!!!!!!!!!!!!!!!!!ERROR!!!!!!!!!!!!!!!!!!
}
lastWasHeadline = false;
}
}
}
}
From the class header (to show you what my struct declarations look like):
__nogc struct block
{
rectangle bounds;
rectangle adjacent;
rectangle gutterDist;
int type;
vector<paragraph> paragraphs;
block()
{
bounds.left = bounds.right = bounds.top = bounds.bottom = 0;
adjacent.left = adjacent.right = adjacent.top = adjacent.bottom = -1;
gutterDist.left = gutterDist.right = gutterDist.top = gutterDist.bottom = 2147483647;
type = blockType::undecided;
paragraphs.clear();
}
~block() {paragraphs.clear();}
void addParagraph(paragraph newParagraph)
{
// if this is the first line to be added to the paragraph
if (paragraphs.size() == 0)
{
bounds.left = newParagraph.bounds.left;
bounds.right = newParagraph.bounds.right;
bounds.top = newParagraph.bounds.top;
bounds.bottom = newParagraph.bounds.bottom;
}
else
{
if (newParagraph.bounds.left < bounds.left)
bounds.left = newParagraph.bounds.left;
if (newParagraph.bounds.right > bounds.right)
bounds.right = newParagraph.bounds.right;
if (newParagraph.bounds.top < bounds.top)
bounds.top = newParagraph.bounds.top;
if (newParagraph.bounds.bottom > bounds.bottom)
bounds.bottom = newParagraph.bounds.bottom;
}
paragraphs.push_back(newParagraph);
}
void removeParagraph(int index)
{
paragraphs.erase(paragraphs.begin() + index);
}
};
__nogc struct page
{
int width, height, resolution;
vector<block> blocks;
double avgLineHeight; // calculated in reFormat(...)
page()
{
width = height = resolution = 0;
blocks.clear();
}
~page() {blocks.clear();}
void addBlock(block newBlock) {blocks.push_back(newBlock);}
void removeBlock(int index)
{
blocks.erase(blocks.begin() + index);
}
};
// all necessary internal variables
page __nogc* thisDoc;
|
|
|
|
|
Hi,
I am trying to access some methods from user defined class it doesnt allow me to do, it says SetValue() is not a member of Class1
Here is the code
Class1 *obj = new Class1 () ;
obj->SetValue ();
Do I need to set any properties specifically to access this method.
|
|
|
|
|
Are you using pure native C++ ? If yes, your question is in the wrong forum (this forum is for managed C++).
For your problem, did you check if this method was in the class and if you didn't misspelled it ?
Post the header of the class, it can be usefull.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hi,
when using Clipboard.SetDataObject()in my source code, I got the error 'Clipboard': undeclared identifier.
If I add the lines below,
using namespace System::Reflection;
Clipboard = new Clipboard();
Clipboard.SetDataObject(...);
I got 'System is not a class or namespace name' and other errors.
Any advise???
Thank you in advance
|
|
|
|
|
You need to reference System.Windows.Forms.dll and "using namespace System::Windows::Forms". Also, make sure you have a "using namespace System" in your code.
-- modified at 15:35 Tuesday 23rd May, 2006
|
|
|
|
|
Hi Jackson,
Thank you for your answer.
Actually I was compiling my src code using .Net 2003. When I added the lines-
using namespace System::Windows::Forms;
using namespace System;
I got other compiling errors C2653, which says 'System is not a class or namespace name.
To reference System.Windows.Forms.dll, I just need to specify its path correctly, right?
Robert
|
|
|
|
|
Unless your GAC is messed up, you can have the following place before any actual code:
#using <mscorlib.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
Geo
-- modified at 9:15 Wednesday 24th May, 2006
|
|
|
|
|
I am writing a game using Visual C++ (Windows Forms Applications). But I find some difficulty in playing music while the game is started.
Could anybody answer me which function should I use and how to ??
|
|
|
|
|
Whats wrong with the following, actually my VC++.Net application is not calling MFC ActiveX method it says "Object Reference Error", i can able to compile successfully.
System::Byte abData[] = new System::Byte[nLength];
brFileContent->Read (abData,0,2); //brFileContent is Binary Reader
Byte *pbManagedData = &(abData[0]); // Get starting point of Array (I can able to see Data and address here
axSimpleAdditionAtx1 ->FinalBy (pbManagedData); // Calling Activex
+++++++++++++++++++++++
Method signature in ActiveX which is not getting called..
void VRMControl::FinalBy (BYTE* ByteValue, LONG Length) // Prototype
{
}
|
|
|
|