|
Thanks. I has solved this problem.
|
|
|
|
|
My CLR project have many Split Containers, one Container has a customed user control.
I want to Render a cylinder with DirectX9 on the user control.
Could somebody tell how to get windows handle of user control or render with DirectX?
|
|
|
|
|
reference: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/71bfe0b7-7609-4c8b-b106-f901e8f379b1[^]
It depends on how your "customized user control" is implemented. However, it comes down to using the windows handle (HWND) and passing that to your DirectX device.
If you're using MFC, everything derives from CWnd. You'll want to use CWnd::m_hWnd.
If you're using Windows Forms with C++/CLI, everything will derive from Control, and you can use Control.Handle.
--------------------------------------------------------------------------------
Reed Copsey, Jr. - http://reedcopsey.com
|
|
|
|
|
That is my partial source code:
public ref class PreviewView : public System::Windows::Forms::UserControl
{
LPDIRECT3DDEVICE9 d3ddev;
private: void initD3D(HWND hHandle)
{
d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
ZeroMemory(pd3dpp, sizeof(*pd3dpp)); // clear out the struct for use
pd3dpp->Windowed = true; // program windowed, not fullscreen
pd3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
pd3dpp->hDeviceWindow = hHandle; // set the window to be used by Direct3D
LPDIRECT3DDEVICE9 d3ddevTmp;
// create a device class using this information and information from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hHandle,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
pd3dpp,
&d3ddevTmp);
d3ddev=d3ddevTmp;
}
When I create device, I must use another variable d3ddevTmp to return the D3DDevice and then set to d3ddev member variable. If I use d3ddev to create device, it will appear the error message as below:
Error 1 error C2664: 'IDirect3D9::CreateDevice' : cannot convert parameter 6 from 'cli::interior_ptr<Type>' to 'IDirect3DDevice9 **' d:\svn\......\PreviewView.h 121
Could somebody tell me how to solve this problem?
|
|
|
|
|
You have to "pin" d3ddev which is currently controlled by the GC. That is, assign it to a pin_ptr<D3DDevice>.
Greetings - Jacek
|
|
|
|
|
Thanks. I has solved this problem.
|
|
|
|
|
I have developed an application(managed + unmanaged) in VC++ using Visual Studio 2005. It can switch to either Console or to windows form depending upon the no of parameters passed to the application on command prompt console. Its basically a windows application but console has been implemented with the help of Attachconsole(), allocconsole() & freeconsole().
Now if i run a batch file, using command prompt console, all the output messages of the application can be seen on the console as shown below.
c:\test> testapp -f filename -l operationname -t otherparams
filename selected..
operation in progress..
operation completed successfully!!
But if i redirect the output of the console to a text file, i dont see any messages in the text file once the operation is complete.
for eg:
c:\test> testapp -f filename -l operationname -t otherparams >> logfile.txt
Clarifications i need are
1. am i missing something to log it in a text file?
2. Can output messages from the console be logged in such a fashion. if yes, how?
Thanks in advance for help/suggestions on the same.
|
|
|
|
|
This looks correct to me. What happens when you type a simple command (e.g. dir ) instead of your application command line?
|
|
|
|
|
If i type in "Dir" command, normal dir contents are displayed.
you mean to say the console that is opened in my application is not a standard console to redirect the output/input using ">>" or ">"? If yes, then how do i redirect teh input & output to a file?
Thanks
|
|
|
|
|
santoshkaif wrote: you mean to say the console that is opened in my application is not a standard console to redirect the output/input using ">>" or ">"? If yes, then how do i redirect teh input & output to a file?
I'm not sure I understand what you are saying here. If you run an application in a command window then you should be able to redirect the output to a file. Are you saying that you are doing something different?
|
|
|
|
|
Hello,
I need some help with the following:
I created a form with textfields there are 2 buttons on the form to save or to cancel.
I also added a leave event on some text fields because I need a test to control if the field is filled in.
When I'm on a field that needs to be filled and I push the cancel button without putting some value in the field the leave event still is executed then I get the message that field has to be filled in!
How can I solve this? How can I test if the cancel button is pushed in the leave of that text field?
Thanks for the help!
|
|
|
|
|
why do you want to validate inputs on Control.Leave? just do it when the "Save" Button is pressed.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
I thought of that too but the save button closes also the form (Form is called from another form with a datagridview on it. This form is the contents of a record). And If I push the save button, I get the message but I cannot put focus back into the textfield because of the form that's closing?
Any other suggestion?
modified on Thursday, November 5, 2009 8:18 AM
|
|
|
|
|
The "Save" Button will do what you tell it to do, most likely "validate, and if OK, then close".
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
You're right but if I do that how does the main program (calling program) knows that buttonOK is pushed?
form2 is made with UI!
Form^ form2 = gcnew Form;
form2->buttonSave->DialogResult = ::DialogResult::OK;
form2->buttonCancel->DialogResult = ::DialogResult::CANCEL;
form2->ShowDialog();
if ( form2->DialogResult == ::DialogResult::OK )
{
...
DataAdapter->Update(myDataSet, "DATA");
}
modified on Thursday, November 5, 2009 8:26 AM
|
|
|
|
|
Hi,
IMO you should remove the form2->buttonSave->DialogResult = ::DialogResult::OK; line, and provide a real click handler for that button, wherein you
1) validate
2) if OK, set DialogResult::OK and close the dialog.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
This is my event for the save button
System::Void buttonSave_Click(System::Object^ sender, System::EventArgs^ e)
{
if (this->textBox1->Text == "")
{
MessageBox::Show("Field is obligated");
this->textBox1->Focus();
}
else
{
this->DialogResult == ::DialogResult::OK;
this->Close();
}
}
In main program it doesn't work! DialogResult is not OK
I probably do something wrong, any other suggestions?
|
|
|
|
|
Any other/further suggestions on this issue?
|
|
|
|
|
Hi all, this is my first post. Normally I am able to figure out the problems I encounter either by searching this board or others like it on the web but not this time. I've been fighting with this for weeks now and am finally turning to you guys. Any and all help is appreciated.
I've got a CORBA Event channel feeding multiple applications data. If you are unfamiliar with CORBA it's okay, you don't need to know much aside from that the code generated for CORBA related functions in UNMANAGED. The data is pushed at a 1Hz interval and the applications register as a consumer to receive the data. My task is to create a common DLL for all Managed applications that are being built going forward that makes the registering and consumption of data easy and localized.
I've had little problem getting this to work with primitive data types but the final piece of my puzzle is to receive a sequence of data that is in a CORBA defined structure.
Here is what I am dealing: a Managed C++ DLL (built with CLR support) that contains Managed and Unmanaged(CORBA) classes, and a C# Application that references the DLL.
The MDA (Managed Debugging Assistant) Gives this description:An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.
Attempting to call into managed code without transitioning out first. Do not attempt to run managed code inside low-level native extensibility points, such as the vectored exception handler, since doing so can cause corruption and data loss.
After hitting continue I get an ExecutionEngineException:
An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.
**The following code snippets are in the Managed C++ DLL**
ManagedWrapper.h
public delegate void BasicCallbackDelegate(short cmd);
public delegate void NonBasicCallbackDelegate(array<EPClass^>^ epList);
[StructLayoutAttribute(Sequential, CharSet = Ansi )]
public ref struct ManagedBasicDelegateWrapper
{
[MarshalAsAttribute(UnmanagedType::FunctionPtr)]
BasicCallbackDelegate^ _Delegate;
};
[StructLayoutAttribute(Sequential, CharSet = Ansi )]
public ref struct ManagedNonBasicDelegateWrapper
{
[MarshalAsAttribute(UnmanagedType::FunctionPtr)]
NonBasicCallbackDelegate^ _nDelegate;
};
public ref class ManagedWrapperClass
{
public:
ManagedWrapperClass(ManagedBasiceDelegateWrapper^ cbd);
ManagedWrapperClass(ManagedNonBasicDelegateWrapper^ cbd);
};
ManagedWrapper.cpp
extern class BasicPushConsumer *BasicPushConsumerObject;
extern class NonBasicPushConsumer *NonBasicPushConsumerObject;
ManagedWrapperClass::ManagedWrapperClass(ManagedBasicDelegateWrapper^ cbd)
{
gt_Callback callback;
Marshal::StructureToPtr(cbd, safe_cast<System::IntPtr>(&callback), false);
BasicPushConsumerObject->SetCallbackInUnmanaged(callback);
}
ManagedWrapperClass::ManagedWrapperClass(ManagedNonBasicDelegateWrapper^ cbd)
{
ep_Callback callback;
Marshal::StructureToPtr(cbd, safe_cast<System::IntPtr>(&callback), false);
NonBasicPushConsumer->SetCallbackInUnmanaged(callback);
}
*pruned* NonBasicPushConsumer.cpp
typedef void (*gt_Callback) (short cmd);
typedef void (*ep_Callback) (array<EPClass^>^ epList);
void NonBasicPushConsumer::SetCallbackInUnmanaged(ep_Callback ptr2f)
{
scallback = ptr2f;
}
void NonBasicPushConsumer::ManagedMethodToCall(array<EPClass^>^ epList)
{
scallback(epList);
}
**The following code is part of the C# Application**
*pruned* Form1.cs
ManagedNonBasicDelegateWrapper mcf = new ManagedNonBasicDelegateWrapper();
mcf._epDelegate = new EntityPositionCallbackDelegate(CallbackFunction);
ManagedWrapperClass mwc = new ManagedWrapperClass(mcf);
public static void CallbackFunction(System.Array epList)
{
Console.WriteLine("CALLBACK!");
}
modified on Wednesday, November 4, 2009 6:44 PM
|
|
|
|
|
'System.Array' is pretty useless - more often used for COM interop - try changing the C# declaration to use a 'proper' C# array:
public static void CallbackFunction(EPList[] epList)
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|
|
Unfortunately this did not remedy the issue, I have the same error. Anyone have any other suggestions?
|
|
|
|
|
Hi Expert,
I want to run command from my application and get the returned result.
ex: in the cmd i put "set MyVariableName" the string return is value of the Environment Variable.
I want to do it from my code and i want the returned value.
Is it possible or not and How?
Thanks.
|
|
|
|
|
Hi,
Am deleoping application using VC++ on VS2005. My application needs to switch to console application if the commandline parameters are mentioned on the command prompt console else to windows form dialog. for eg:
test.exe --help
on command prompt should display on command console(black backgrnd console window) and if cmd is
test.exe
window form should be opened.
This has been accomplished by creating the project of the type window form and then project properties->system->subsystem to Console (/SUBSYSTEM:CONSOLE)
But now the issue what i am facing are
1> when window form is opened with ex cmd test.exe, black color console window is also opened.
2> when console is closed, window form also closes
solutions i need correspondingly are
1> how to hide/close the console window when windows form is open?
2> can the Can console and window form controls be made independent? if yes how?
Searched and tried lots of solutions provided over net, but of less help.
Help on this will be appreciated.
Thanks,
Santosh
|
|
|
|
|
There is no way to hide the console programically.
A dirty way to achieve what you need is: Create two executables. First executable will be console and second will be windows. Second executable is your applications executable. Always invoke the first executable and if its is invoked using command line parameters, write the necessary details to the console. If no command line parameters are specified, start your main exe and exit this one.
Let me know if you find a better approach.
Best wishes,
Navaneeth
|
|
|
|
|
Agree but I need to deliver a single exe.
|
|
|
|