|
Okay I understand the problems, but what I can do? How I can have the warnings away (not only with pragma)?
1) I need unmanaged classes and there I have static instances...
2) I understand also this, but in this case the column is a integer...What I have to do?
Best regards
Hansjörg
|
|
|
|
|
I am only seeing small snippets of your code and don't know anything about your programming requirements. So, I can only give you general advice about what I think may be wrong.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello,
advice 2 was really good. It works! The only thing that I don't have tested
for the first point:
I have a mixed c++/cli (for speed reasons) program. And for that I have in a few assemblies classes which are totally unmanaged:
<br />
#pragma managed(push,off)<br />
class Test<br />
{<br />
static std::wstring teststr;<br />
<br />
}<br />
In this class I don't have the possibility to use a managed string class. And the only way (that I know) to initialize the static member is
<br />
std::wstring Test::teststr = L"";<br />
Isn't it?
What do you do in that case?
Best regards
Hansjörg
|
|
|
|
|
I will try to answer your question later on after work. However, why are you writing native code in assemblies compiled by /clr? I know you said for speed reasons. However, are you aware of managed to unmanaged and unmaanaged to managed transitions (thunks) which act like speed bumps in your application. Nevertheless, if it is the only way to write the program, I understand.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thank you very much!
Yes I know about the speed bumps but I'm careful with every transition (mostly from windows forms to unmanaged code)...
Best regards
Hansjörg
|
|
|
|
|
The only way I could get native static objects to work in managed code was to place them inside of static functions or static methods. For example:
#pragma managed(push, off)
using std::wstring;
class Foo
{
public:
static const wchar_t* State(const wchar_t* value = 0)
{
static std::wstring state= L"";
if (value != 0)
state = value;
return state.c_str();
}
};
#pragma managed(pop)
using namespace System;
int main(array<System::String ^> ^args)
{
String^ str1 = gcnew String(Foo::State());
Foo::State(L"Hello!");
String^ str2 = gcnew String(Foo::State());
Console::WriteLine(str1);
Console::WriteLine(str2);
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
|
Issue #2: Have you tried manually boxing the zero?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello!
I have this code:
(...)
static double U[5];
(...)
And, when i compile i see this error:
error C4368: cannot define 'U' as a member of managed 'bojoo::Class1': mixed types are not supported
How i fix it?
Thank´s!
Rapbs
|
|
|
|
|
Rui A Sousa wrote: How i fix it?
I would like to clarify what you are asking for. Do you want someone to tell you how to fix the code or, do you want to understand the issue so that it will never be a problem for you again?
|
|
|
|
|
One feature in Visual Studio I find useful is the pressing the F1 key on error messages I don't
understand
For example - your error shows me:
"You cannot embed a native data member in a CLR type. You can, however, declare a pointer to a native type and control its lifetime in the constructor
and destructor and finalizer of your managed class (see <mshelp:link tabindex="0" keywords="0d09d3f1-13a0-4041-8178-402aad667edd">Destructors and Finalizers in Visual C++
for more information)."
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
2 classes which are dialogues.
On the 1st dialog, I have button that when pressed opens another dialog. I can't work out how to make the second one modal.
I'm calling the second Dialog boxes show() method in the DlgProc method as below.
LRESULT CALLBACK ExodusDisplayOptions::DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){<br />
switch(message)<br />
{<br />
case WM_INITDIALOG:<br />
{<br />
}<br />
break;<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
break;<br />
case WM_COMMAND:<br />
{<br />
switch (LOWORD(wParam))<br />
{<br />
case WM_CLOSE: <br />
return (TRUE);<br />
break;<br />
case IDC_CLOSE:<br />
EndDialog(hDlg, LOWORD(wParam));<br />
return (TRUE);<br />
break;<br />
case IDC_BUTTONDISPLAY:<br />
ExodusHazardDisplayOptions *haz = new ExodusHazardDisplayOptions(m_this, m_opts);<br />
bool i = haz->Show();<br />
break;<br />
<br />
<br />
}<br />
<br />
<br />
} <br />
break;<br />
default:<br />
return DefDlgProc(m_this, message, wParam, lParam);<br />
}<br />
return 0;<br />
}
Any ideas?
|
|
|
|
|
gunner_uk2000 wrote: Any ideas?
You're in the wrong forum
What does "haz->Show()" do? Is it creating a modal dialog? For a modal dialog
you need to call one of the DialogBox___() APIs.
Off topic... the "case WM_CLOSE " in response to WM_COMMAND looks suspicious.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All
I am creating a managed wrapper class for a c++ unmanaged class.While I am calling a function in managed class and passing a short paramater as reference
1.short MCDPTAdminClass::listPrinters() //managed class
2.{
3. m_CDPTAdminClass->listPrinters(&numPrintersFound);
//m_CDPTAdminClass object of unmanaged class and short numPrintersFound
return numPrintersFound;
}
I am getting an error "Can not convert from short __gc* to short*" at line "3"
Can anyone help me to resolve this problem .
thanks in advance
|
|
|
|
|
Thanks for all the fish wrote: Can anyone help me to resolve this problem
I would like to clarify what you are asking for. Do you want someone to tell you how to fix the code or, do you want to understand the issue so that it will never be a problem for you again?
|
|
|
|
|
Thanks for all the fish!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Thanks for all the fish!
Does that have some kind of religious significance?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
George L. Jackson wrote: Does that have some kind of religious significance?
Only in my religious commitment to keeping led mike's fish-filet analogy alive!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
HeHe! I saw the original posts!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Is it possible to call into a .NET class library from a VC60 C++ app? If yes, how?
I wanted to create a middle layer between C++ app and .NET class library - sort of a wrapper for .NET class library. Towards that end, in VS2005, I created a C++ Win32 Dll. I have turned on CLR option from Project->Properties>Configuration. But in this project, I couldn't figure out how do I instantiate ClassLibrary and make calls into it. Can someone please enlighten?
Thanks.
None
|
|
|
|
|
concoran wrote: Can someone please enlighten?
It sounds like this is your initial use of C++/CLI? If so I recommend learning about it first before you approach your project. There are almost endless articles, tutorials and sample/example projects available here and on MSDN to educate you about the power of C++/CLI.
|
|
|
|
|
Hi Led,
Yes, I am new to CLI, but not to C++. I am also new to Codeproject. Can you pls point to where I can find articles on this website?
Thanks in advance.
None
|
|
|
|
|
concoran wrote: Can you pls point to where I can find articles on this website?
On the "Articles" menu (it's between "Hellp" and "Message Boards") click the "Site Directory" link
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. I have been surfing for information on zooming using CLI. The SetWindowsExt() and SetViewportExt() functions do not seem to be available any more. If anyone has a link to an article or can at least point me in the right direction it would really help.
Thanks,
Buck
|
|
|
|
|
Hi Buck,
if you want to modify things you paint yourself (say inside OnPaint),
then you can use the transform methods of the Graphics class; they let
you set translation, rotation, scaling (or an enire matrix), then do
the paint stuff as before.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|