|
I have a C++/CLI Win Forms app. I am forced to provide an unmanaged
Dialog. I assume I need to write a CDialog as part of my CLR solution.
I need a little hand holding. My MFC is RUSTY! Can someone tell me
how to create a CDialog (unmanaged DLL) to be called from my WinForms
Load event.
(I have been reading, searching and trying; but no cigar. Need some help.)
WedgeSoft
|
|
|
|
|
|
It is been quite a while. I have a task to identify a calling Windows' batch script's name and its location. Basically, the batch script calls/spawns my C++ executable as a parent process and I failed to identify the parent. I can identify a number of different calling processes using NtQueryInformationProcess(), but failed to do so to the batch script. The main reason is that the batch process is shown as cmd.exe not a real script name.
Thanks a lot for the help.
|
|
|
|
|
Hi Dear,
I need to make the report view of the list control non sortable( Disable Sorting) at run time. But i could not find out any API. Can Any body help me
|
|
|
|
|
Hi!
CListCtrl sounds like MFC (i.e. unmanaged), so I guess you've asked this question in the wrong forum. Try here: Visual C++ / MFC[^]
But wait... try if this answers your question:
CListCtrl yourListCtrl;
...
CHeaderCtrl* pHeader = yourListCtrl.GetHeaderCtrl();
if(pHeader)
{
pHeader->ModifyStyle(0, HDS_BUTTONS);
pHeader->ModifyStyle(HDS_BUTTONS, 0);
}
cheers,
mykel
OMM: "Let us be thankful we have an occupation to fill. Work hard, increase production, prevent accidents and be happy."
|
|
|
|
|
Hello,
I have a few warnings in c++/ cli that I don't know how to resolve:
1)
Warning 1 warning C4835: 'startupDirectory' : the initializer for exported data will not be run until managed code is first executed in the host assembly FileUtils.cpp 76
okay in this there is a unmanaged class (#pragma managed(push,off)) with a static variable
<br />
class CFileUtils{<br />
std::wstring startupDirectory(L"");<br />
}<br />
and in the c++ file
<br />
std::wstring CFileUtils::startupDirectory(L"");<br />
2)
Warning 6 warning C4965: implicit box of integer 0; use nullptr or explicit cast AlarmViewerControl.h 594
in this case I have the following code. I have tested already all casts that I know...
<br />
DataRow ^dr = dt->NewRow();<br />
<br />
dr["clmId"] = 0;<br />
Best regards and thanks for any hint!
Hansjörg
|
|
|
|
|
First issue: If native code executes before managed code, your application may have problems with loader lock: http://msdn2.microsoft.com/en-us/library/ms172219(vs.80).aspx[^]
Second Issue: If the dr["clmId"] is an object, for example a String^ , the compiler believes you are trying to set the object to NULL with zero which is not permitted.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
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++
|
|
|
|