|
What about the copy/paste issue that I mentioned in the post to Luc?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
You mean with CPsyntax and the line numbers? I'm not using that so it works fine.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Now all of the sudden I see links view plainshow original copy to clipboard print ? And it works fine when using the copy to clip board. I wonder why I see it on my desktop, but not the laptop? Cool, I got something to research around on this morning
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Mark, I agree!
If you use the forum editor, you can write the following:
<pre><code>
x += 2;
y += 3;
</code></pre>
The editor converts it to this:
<pre><code>
<br>x += 2;<br>
<br>y += 3;<br><br>
</code></pre>
Thus, when you copy the code, the HTML tags get stripped out and you have just one line of code.
Geo
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I've been browsing the HTML code as well...
I forgot one other wish - within a block of code that keeps its spacing and newlines and allows
me to bold or color specific text, I'd also like HTML tags turned off so when I post code I don't
have to go through and manually change the angle brackets (I always miss some too).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Luc,
I think the problem, in part, is Visual Studio. I have copied some sample code from code project into Microsoft Word, and it retained the format. I, then, copied the code from Word into Visual Studio, and everything looked as expected. I only used a small sample however.
Geo
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
BuckBrown wrote: but I cant figure out the correct way to define the arrays named nIndex and nByte.
You need to create them at some point. Wherever is appropriate - CCoordinate class constructor
maybe?
Create them the same way you create the OriginalData array?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I can't get it to work. I added the constructor for the value CCoordinate class and got the compiler error message "value types cannot contain user-defined special member functions". So I changed the class definition to "ref class CCordinate" and this allowed me to create the constructor and add the array definitions in the CCoordinate constructor. But this broke another part. I had to change...
array[CCoordinate, 2]^ OriginalData; To the following line...
array[CCoordinate^, 2]^ OriginalData; to keep from getting the "need an upper level ^" error.
This all compiled but I can't access any of the variables. Most of CLI is pretty cool but the way they put together the arrays is for the birds. I cna't seem to wrap my head around anything other than a one dimensional array of a basic type (such as int). I can create an array of handles (such as int^) but then I can't below System::Array. Native arrays make so much more sense but CLI won't let me use a native type.
Buck
|
|
|
|
|
Can you repost the classes in question with the "Ignore HTML tags in this message (good for code
snippets)" checkbox checked on your reply?
That will make it easier to see what's going on
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I will attempt to make this bare bones.
ref class CWafer()
{
public:
CWafer(void);
value struct MyStruct
{
int AnIntegerValue;
array<int>^ AnArrayOfIntegers; // How do I define this to be an integer array of 10 ints.
Init()
{
AnArrayOfIntegers = gcnew array<int>(10) // I have tried this and it does not work.
}
};
array<MyStruct, 2>^ TwoDimensionalArray;
MyStruct newStruct;
}
CWafer::CWafer()
{
TwoDimensionalArray = gcnew array<MyStruct, 2>(1000, 1000);
newStruct = MyStruct.Init();
}
This is it! My application uses an x coordinate and a y coordinate, hence a two dimensional array is perfect because for each (x, y) location there are several integer values and integer arrays that need to be accessed. The above code snippet allows me to write "TwoDimensionalArray.AnIntegerValue = 1;" and I would like to be able to do something like write "TwoDimensionalArray.AnArrayOfIntegers[n] = 2;" but the array is undefined. It seems that the managed heap is being gabage collected before I can use it but I don't see anything wrong with the scope.
|
|
|
|
|
I'm not sure what value (pun intended) you're getting out of using a value struct here, since
you're not creating heap objects and they need to be initialized.
Beyond that, compare the following with your code. Most of the changes were regular C++
related...
ref class CWafer
{
public:
CWafer();
value struct MyStruct
{
int AnIntegerValue;
array<Int32>^ AnArrayOfIntegers;
void Init()
{
AnArrayOfIntegers = gcnew array<Int32>(10);
}
};
array<MyStruct, 2>^ TwoDimensionalArray;
MyStruct newStruct;
};
CWafer::CWafer()
{
TwoDimensionalArray = gcnew array<MyStruct, 2>(1000, 1000);
for (int i = 0; i < 1000; ++i)
{
for (int j = 0; j < 1000; ++j)
{
TwoDimensionalArray[i,j].Init();
}
}
newStruct.Init();
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Okay, getting closer. This has to be a scope issue. Just as before, the two dimensional array was initialized, then the one dimensional array was initialized (inside the CWafer constructor). Then several functions are called from within the constructor, one of those accesses these arrays. When the function is called the arrays become undefined. I suppose I might be able to pass them as arguments but there is some confusion on how gcnew works. In C++ MFC I would declare types in the header file and then create them with "new" in the constructor. Then if I called a series of functions from the constructor I could "see" within the functions the type as I had defined it in the constructor. If I use "gcnew" then call a function from the constructor the definition is immeadiately lost. I saw this same behavior with another class where my CWafer class had to instantiate a CLtx class (contains some parameters that my CWafer class uses). In the CWafer constructor I instantiated a "CLtx^ LtxFile = gcnew CLtx^;" because I wanted all kinds of CWafer functions to use LtxFile. Unfortunately I had to instantiate the LtxFile inside of each function as it was called. This basic difference in scope is huge and causing me all kinds of problems (current one included). I understand that the garbage collected heap will release the memory when it is no longer needed but why is it reclaiming memory just because I have called a function from within the CWafer constructor?
Buck
|
|
|
|
|
The same scoping rules apply as with unmanaged C++.
BuckBrown wrote: Then several functions are called from within the constructor, one of those accesses these arrays. When the function is called the arrays become undefined.
How is this function accessing the arrays if it's not a member function? You must be passing
something, because just like unmanaged C++, you need to have an object to access non-static class
members.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Okay, I slept on it and figured out what was happening, and yes, it is my bad big time. What was happening with the scope was that at some point in time (probably in order to correect a compiler error) I edited the constructor to re-declare the arrays. So when I called a function from within the constructor and had my arrays seem to go undefined was really the debugger referencing the arrays declared in the header file, NOT the arrays re-declared in the constructor. Anyway, I have now got the declarations, definitions, and initializations of these arrays working, but I still think the way CLI does multi-dimensional arrays is for the birds.
Thanks for all your help. Glad to see this started a onversation between you all on that format issue.
Buck
|
|
|
|
|
Actually, the more I look at it, the value struct is fine. I'll drop that topic
And you can change those Int32s back to ints
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am using Visual c++ NET 2005
Who can I set focus to a control in the same form ?
|
|
|
|
|
RTFM
|
|
|
|
|
When in a native c++ class, in a /clr project, stepping through is getting out of sync of where it should be.
i.e.
1 if(fileSpec.GetLength()==0)
2 {
3 printf("You must specify a filename!\n");
4 return 1;
5 }
I put a breakpoint on line 1. Then F11 to step into. The if statement returns false and so it should step to 5 or beyond. Instead it stops on 4.
Any ideas why?
|
|
|
|
|
Hello,
Have you tried deleting all .ncb and .suo garbage, and rebuilding all?
|
|
|
|
|
Hi,
When I am trying to automate MS Word (32 bit) from a NT Service (32 bit). The word runs as a 64 bit application (as evident from the task manager).
But if the same code is run as a thread from a Windows application word runs as 32 bit.
How can I automate word to run as 32 bit from the NT sevice??
Thanks,
Indra
|
|
|
|
|
You;re trying to automate Word using C++ and .NET ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: You;re trying to automate Word using C++ and .NET ?
No, using C++ and COM.
Code I am using:
VARIANT root[64] = {0}; // Generic IDispatchs
VARIANT parm[64] = {0}; // Generic Parameters
VARIANT rVal = {0}; // Temporary result holder
int level=0; // Current index into root[]
// Initialize the OLE Library...
OleInitialize(NULL);
// Line 1: Set oWord = CreateObject Word.Application
CLSID clsid;
CLSIDFromProgID(L"Word.Application", &clsid);
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER, IID_IDispatch, (void **)&rVal.pdispVal);
rVal.vt = VT_DISPATCH;
VARIANT oWord = {0};
VariantCopy(&oWord, &rVal);
VariantClear(&rVal);
// Line 2: oWord . Visible = 1
rVal.vt = VT_I4;
rVal.lVal = 0;
VariantCopy(&root[++level], &oWord);
hr = AutoWrap(DISPATCH_PROPERTYPUT, NULL, root[level].pdispVal, L"Visible", 1, rVal);
VariantClear(&root[level--]);
VariantClear(&rVal);
// Line 3: oWord . Documents . Open C:\\Test.doc
VariantCopy(&root[++level], &oWord);
hr = AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"Documents", 0);
The purpose of the AutoWrap function in this sample is to wrap the calls for GetIDsOfNames and Invoke to facilitate automation with straight C++.
|
|
|
|
|
indra20 wrote: No, using C++ and COM.
OK, then you're in the wrong forum. Try the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I have a C++ (Borland 5.02 - I know is old stuff...anyway) I have function where I can print reports. Now what I need to to modify this function to instead of printing to a printer I need to save that as MDI or PDF file, but I want to bypass the Save As dialog box because I have several hundreds of reports to print. How can I do that? Please help!!!
Flavio
|
|
|
|
|
Borland does not support .NET, therefore you're in the wrong forum. Even in hte right forum, I'm not sure how many people can offer Borland specific help.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|