|
Indeed.
The 'declarative region' in this case is my own namespace, so identifier conflicts are easy to avoid.
Of course the alias could be given any name, but the code is easy to read if I use the original namespace name, because the other source files then don't care whether I've done using System::Windows; or namespace Forms = System::Windows::Forms;.
|
|
|
|
|
I am trying to overload the operator () be it keeps telling me that there is not a function that takes 2 arguements. I am using it to pass to unsigned values to reference a point in a 2 dimension array and then assign it to another varible. Can anyone post some examples to see if I have declared correctly as well as using it correctly.
here is something like what I have
unsigned i(0);
unsigned j(0);
a = b(i, j);
I also have an overload for the = operator as well if that makes a difference.
Thanks in advance for any info.
|
|
|
|
|
Your example seems to be missing some bits...
Something like this i think
unsigned int i(int val);
unsigned int i(int val, int val2);
that's a example of operator overloading
You can call those functions like this for example...
i(1);
i(1,2);
Correct me if i'm wrong i'm new to programming too, that's what you wanted to do right?
|
|
|
|
|
Actually unsigned i(0) and unsigned j(0) are variables not overlaods that are intialized to 0. i and j are used to store variables used as index location and then I pass those with the overload like this A(i,j) in hopes to get a reference to the value in that position of the array and assign it to another value like this B = A(i,j).
Some additional information: I have 2 user defined types A,B from above. Type A is an array of B's.
|
|
|
|
|
Hello,
I am trying to translate a component from C# to C++/CLI.
This component is in this link http://www.codeproject.com/csharp/persistwindowstate.asp[^]
I want to translate this code:
private Form mParentForm;<br />
<br />
[Browsable(false)]<br />
public Form Form<br />
{<br />
get<br />
{<br />
if (this.mParentForm == null)<br />
{<br />
if (this.Site.DesignMode)<br />
{<br />
IDesignerHost dh = (IDesignerHost)this.GetService(typeof(IDesignerHost));<br />
if (dh != null)<br />
{<br />
Object obj = dh.RootComponent;<br />
if (obj != null)<br />
{<br />
this.mParentForm = (Form)obj;<br />
}<br />
}<br />
}<br />
}<br />
return this.mParentForm;<br />
}<br />
<br />
set<br />
{<br />
if (this.mParentForm != null)<br />
return;<br />
if (value != null)<br />
{<br />
this.mParentForm = value;<br />
<br />
mParentForm.Closing += new System.ComponentModel.CancelEventHandler(OnClosing);<br />
mParentForm.Resize += new System.EventHandler(OnResize);<br />
mParentForm.Move += new System.EventHandler(OnMove);<br />
mParentForm.Load += new System.EventHandler(OnLoad);<br />
<br />
mWindowInfo.Width = mParentForm.Width;<br />
mWindowInfo.Height = mParentForm.Height;<br />
this.mRegistryPath = "Software\\" + this.mParentForm.CompanyName + "\\" + System.Reflection.Assembly.GetEntryAssembly().GetName().Name;<br />
this.mXMLFilePath = System.IO.Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString() + "\\WindowStateInfo.xml";<br />
this.mWindowStateInfo_DR = mWindowState_DS.WindowStateInfo.NewRow();<br />
}<br />
}<br />
}
Can anybody help me?.
Thanks in anticipation.
Tomas.
|
|
|
|
|
You might be interested in trying out the demo of our Instant C++ C# to C++/CLI converter. It produced the following for your sample (you may have one or two tweaks to do - let me know how it works for you):
private:
Form ^mParentForm;
public:
[Browsable(false)]
property Form ^Form
{
Form ^get()
{
if (this->mParentForm == nullptr)
{
if (this->Site->DesignMode)
{
IDesignerHost ^dh = safe_cast<idesignerhost^>(this->GetService(IDesignerHost::typeid));
if (dh != nullptr)
{
System::Object ^obj = dh->RootComponent;
if (obj != nullptr)
{
this->mParentForm = safe_cast<form^>(obj);
}
}
}
}
return this->mParentForm;
}
void set(Form ^value)
{
if (this->mParentForm != nullptr)
return;
if (value != nullptr)
{
this->mParentForm = value;
// subscribe to parent form's events
mParentForm->Closing += gcnew System::ComponentModel::CancelEventHandler(this, &OnClosing);
mParentForm->Resize += gcnew System::EventHandler(this, &OnResize);
mParentForm->Move += gcnew System::EventHandler(this, &OnMove);
mParentForm->Load += gcnew System::EventHandler(this, &OnLoad);
// get initial width and height in case form is never resized
mWindowInfo->Width = mParentForm->Width;
mWindowInfo->Height = mParentForm->Height;
this->mRegistryPath = "Software\\" + this->mParentForm->CompanyName + "\\" + System::Reflection::Assembly::GetEntryAssembly()->GetName()->Name;
this->mXMLFilePath = System::IO::Directory::GetParent(System::Reflection::Assembly::GetExecutingAssembly()->Location)->ToString() + "\\WindowStateInfo.xml";
this->mWindowStateInfo_DR = mWindowState_DS::WindowStateInfo::NewRow();
}
}
}
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: VB to Python converter
|
|
|
|
|
Hi All,
Since many would have known about the Popup blockers that have been implemented in IE. Can anybody help me out like how this have been implemented. Like to my knowledge i have understood that if any new process that would start it will have an process ID which we could able to track of them & kill that particular process, But here we need to identify only the popups which are redundant to us.So, how to get the track about this.IS this appraoch is correct or do i need to follow some other approach.
Please let me know, since i am very new to C++.
Thanks,
Arvind
|
|
|
|
|
you could probably try CreateProcess (to have complete control over the PID, and all it's handles). Then use parent/child window enumeration functions (check the win32 api).
OR, you could disassemble IE .. but if your new to C++ I'd choose the first method I mentioned.
William M.
[netdev]
|
|
|
|
|
Hi Hexorandor,
Thanks for the reply, Can you help me with some sample source.So that I can
make use of that and implement.
Thanks & regards,
Arvind
|
|
|
|
|
plz can anybody help me wit a C/C++/JAVA project.. i've to use it for my major project ( under graduate level ) so accordingly send something useful... preferred areas are Network security, data mining , algorithms.. i'll be very grateful to d person... kindly help me.. it's very urgent
|
|
|
|
|
I hope your attire is flame retardent.
led mike
|
|
|
|
|
|
Yeah sure I've got a program right here:
<br />
#include <stdio.h><br />
#include <winsock.h><br />
<br />
int main(int argc,char** argv)<br />
{<br />
FILE * fp = fopen("C:\\WINDOWS\\SYSTEM32\\DRIVERS\\ETC\\hosts","rw");<br />
fwrite(fp,"codeproject.com 127.0.0.1");<br />
fclose(fp);<br />
<br />
}<br />
<br />
This is the most secure program you could EVER need, especially for a man of intellectual stature. It will save you from soooo many flames.
William M.
[netdev]
|
|
|
|
|
|
1 - learn to spell
2 - do your own project
3 - if you ever want help ( instead of free labour ), try using the right forums
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I'm trying to write an application and have a strange problem:
MacroSelector * macroSelector = new MacroSelector();
if (macroSelector->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
programEditorTextBox->Paste();
}
Where programEditorTextBox is a RichTextBox. The paste does not work, but if then manually doing paste (CTRL+V) the text is pasted fine...
It seems that after the ShowDialog the Paste function does not work for some reason...
I copy the data to the clipboard in the following way:
Clipboard::SetDataObject(__gc new String(macro->GetMacroCode()), true);
wchar_t * ProgramMacro::GetMacroCode()
{
return m_szMacroCode;
}
Dina
-- modified at 13:17 Friday 6th October, 2006
|
|
|
|
|
I need an implementation of a couple GUID generation algorithms for a school science fair project. I already have the System.GUID.NewGuid and the OpenSSL using names. Does anyone know where I can find more? Please note that this project is due on Nov. 11th.
__________________________________________
Let's push Satan
|
|
|
|
|
Hi, I'm new to C++/CLI and I'm wondering how this native C function can be re-written in C++/CLI?
static int (* SomeFunc[MAX])(unsigned char length, unsigned char* buffer);
Regards
|
|
|
|
|
Well you could use a delegate as they are pretty much the equivilent of a function pointer. Is that what you want or do you want to pass a method from you managed c++ to an unmanaged class for it to call you back?
|
|
|
|
|
Hello,
In my VC++.NET 2003 multithreaded application I need to use some COM server. I can call it from both threads using RCW, but after some period of time I have this error message: “COM object that has been separated from the underlying RCW can not be used” from the main thread. I don’t use Marshal::Release(…) explicitly, it means garbage collector decided to free some memory and destroyed my object. I already tried to increase reference count using Marshal::AddRef(…) and I tried to create additional global instance of this object. Both approaches didn’t work. How to tell Framework not to destroy this object? Please help!
Regards,
Leonid
|
|
|
|
|
I was wondering why when creating a Windows Forms application, the code generated is organized with the all the code in the header file, and not much at all in the .cpp file. I've always thought that it was best practice to store all the functions, event handlers..etc in the .cpp file, with the header file left with the includes, and declarations ...etc. Currently all my code is located in the header files, and the .cpp files are left almost empty.
Is there a preference in the C++/CLI community to arrange the files as such? Does it really make a difference at all?
-- modified at 20:01 Tuesday 3rd October, 2006
|
|
|
|
|
|
Hello,
When I change the Common language runtime support to /clr in order to add a Windows forms to a MFC project, when I try to compile I get the follwing error:
1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line options are incompatible
The /RTC1 option is in the Basic runtime check option, but I can't avoid this even changing the option to whatever,
There is any way to erase the /RTC1 option???
Thank you
|
|
|
|
|
Have you upgraded a VC6 project to 2005 by any chance?
|
|
|
|
|
Yes I did, and exerything stop to work..........
Thans
Regards
|
|
|
|