|
*sigh* I need to create a standard disclaimer to post in this forum. 99% of the questions posted here have nothing to do with managed C++, and this is no exception.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I meet some problem when I compiled this code:
double x1=
float x=float(6426.81125084);
TRACE("\n%f",x);
The result was: 6426.811035, was it incorrect???????
But when I used:
float x=float(6.81125084);
TRACE("\n%f",x);
The result was: 6.811251, was it correct??????Thanks.
|
|
|
|
|
Where is the float being turned into a double ?
Sorry dude, floating point math is not exact. Fixed point is, but you need to impliment that yourself.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
How do I send a keyboard event to my application?
I want to control the cursor position in a
numericUpDown (or domainUpDown) control. (I
have thought to do so with a keyboard event.
Perhaps there is a better way.)
WedgeSoft
|
|
|
|
|
|
Well! Thank you.
I will go check that site out. My knowledge
of MC++, thus far, comes from three sources:
A book I read (Managed C++ .Net Development"),
the VS .NET 2003 Documents, and CodeProject.
Now, I'll add another. Sorry you think the
question somewhat stupid. But glad you
chose to answer, and yes, it does
seem more questions are asked than answered.
PS:
Checked it out: Same doc as I have on disk.
I just could not find it. Sometimes hard to
search for what you don't know, and I did not
think of "SendKey" -- I did try a lot of other
things like "key" "keyboard" "key event" and
such.
Thanks again.
WedgeSoft
|
|
|
|
|
For some reason, when in any sort of Managed C++ class library I use the new keyword on any non-GC object, it gives me an error during linking:
error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@$$FYAPAXI@Z)
Strangely though, I don't get the same error in a console application.
For example, char* c = new char; gives me the error, but String* string = new String("hi"); doesn't. Same error goes for non-__gc classes -- but only in class library projects.
Anyone have any ideas?
If not, does anyone have a way of a way to get VMR9[^] to interface in C#? I'm currently making a managed wrapper for it, because I can't find its COM dll.
Thanks in advance.
|
|
|
|
|
I have written a simple program for internet communication, but when I try to assign a specific port for the connection, winsock still connects the two programs, but over a different port. When I raise or lower the port number, the actual port number increments by 256. This is really confusing, can anyone help?
Democracy for the USA!
|
|
|
|
|
I have a graphics card which supports two monitors (love it!).
But the driver causes MANY lines of the following to be
displayed in my debug output window (.Net 2003 standard edition).
'DesignFrom.exe': Unloaded 'C:\WINDOWS\system32\nviewimg.dll'
'DesignFrom.exe': Unloaded 'C:\WINDOWS\system32\msimg32.dll'
'DesignFrom.exe': Loaded 'C:\WINDOWS\system32\nviewimg.dll', No symbols loaded.
'DesignFrom.exe': Loaded 'C:\WINDOWS\system32\msimg32.dll', No symbols loaded.
Please, how do I turn these lines off?
WedgeSoft
|
|
|
|
|
I have recalled, how I fixed the above in MFC
// Loaded as an ASSERT so only is loaded in DEBUG
ASSERT( ::LoadLibrary( _T("nviewimg.dll") ) );
ASSERT( ::LoadLibrary( _T("msimg32.dll") ) );
So I tried in MC++ and found that ASSERT does not work.
So I have:
#ifdef _DEBUG
LoadLibrary( _T("nviewimg.dll") );
LoadLibrary( _T("msimg32.dll") );
#endif
And it works!
Is there a BETTER way -- nicer code?
WedgeSoft
|
|
|
|
|
I'm just starting to use VS 2003. I have not found a tutorial on writing user controls, .NET style (I have written some in VB6). Any recomendation on good introductory material?
|
|
|
|
|
Not many books on MC++ (most (as you know) are C#)
I read "Managed C++ and .NET Development" by Stephen
R. G. Fraser. Was helpful (though basic).
WedgeSoft
|
|
|
|
|
I have an unmanaged C++ dll with singeltons implemented as templates
now if i call that dll with MC++ the application hangs
when i call getInstance() of the singleton.
everything else works i can access classes int the unmanged dll.
but when it comes to templates its just hangs.
is there a work around?
|
|
|
|
|
I've got the following problem: I have a DLL written in C++, that exports a function. That function basically puts a very simple CDialog object on the screen (either modal or unmodal).
I have a very simple forms-based C# program that uses this DLL to call the exported function. Everything works OK.
Now, I add a custom control in the CDIalog-derived class, in C++, using an OCX that was developed by another company. When having this OCX, the C# code calls the exported function, but the dialog is not shown.
If needed, I can provide the code.
Any ideas why I have this problem?
|
|
|
|
|
Hi everyone
First it all,I've created a Windows Control Libray (.NET) Control using C++.
second : There is a great library call SDL (simple Direct Layer)
Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. It is used by MPEG playback software, emulators, and many popular games, including the award winning Linux port of "Civilization: Call To Power."
SDL oftently is used for games
SDL supply C methods in order to able to create Windows a interact with them. when SDL starts always create a new Window where anything like show a game o graphics could happen.
SDL needs Initializing methods such as :
/* Initialize SDL */
SDL_Init(SDL_INIT_VIDEO)
/* Set the video mode */
SDL_SetVideoMode(SCREEN_X, SCREEN_Y, 0, SDL_SWSURFACE);
So when SD_SetVideoMode executes a new Wiwdow is created, but I don't want a new
emerging Wiwdow behing I want that the new SDL window created appears completely embedded inside my .NET control.
I Though the solution will would be, change the parent for the SDL Window to
Control, i couldn't do that.
SDL provides methods for getting the HANDLE for the new Window created :
HWND GetWindowHandle()
{
#ifdef WIN32
SDL_SysWMinfo wmi;
SDL_VERSION(&wmi.version);
if(SDL_GetWMInfo(&wmi) == 0)
{
return NULL;
}
else
{
return wmi.window;
}
#else
return NULL;
#endif
}
At this moment i have a component used in a Forms Application that used myControl, but when I exetute this the Windows Forms appears, my component appears too, but the SDL window appear behind.
Here is the code for the .H file
#pragma once
#include "SDL.h"
#include "SDL_syswm.h"
#include "SDL_events.h"
#include <stdio.h>
#include <limits.h>#include <stdlib.h>
//#include <afxwin.h>
#include <windows.h>
#define SCREEN_X 300
#define SCREEN_Y 200
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace cubecontrol
{
///
/// Summary for cubecontrolControl
///
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
public __gc class cubecontrolControl : public System::Windows::Forms::UserControl
{
public:
cubecontrolControl(void)
{
InitializeComponent();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private:
///
/// Required designer variable.
///
System::ComponentModel::Container* components;
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
void InitializeComponent(void)
{
//
// cubecontrolControl
//
this->Name = S"cubecontrolControl";
this->Size = System::Drawing::Size(440, 288);
int done;
SDL_Event event;
/* Initialize SDL */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
//fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
//cout(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
//exit(1);
}
//atexit(SDL_Quit);
/* Set the video mode */
screen = SDL_SetVideoMode(SCREEN_X, SCREEN_Y, 0, SDL_SWSURFACE);
if ( screen == NULL ) {
//fprintf(stderr, "Couldn't set video mode: %s\n",SDL_GetError());
//exit(1);
}
//CWnd window;
//HWND h;
System::Windows::Forms::Control* c ;
System::Windows::Forms::Form* f;
/*window= */ /*CWnd::*///FromHandle(GetWindowHandle())->Parent=this;
c = FromHandle(GetWindowHandle());
}
HWND GetWindowHandle()
{
#ifdef WIN32
SDL_SysWMinfo wmi;
SDL_VERSION(&wmi.version);
if(SDL_GetWMInfo(&wmi) == 0)
{
return NULL;
}
else
{
return wmi.window;
}
#else
return NULL;
#endif
}
static SDL_Surface *screen;
};
}
Thanks in advance for any help someones could give me
|
|
|
|
|
Hi all.
1.
I have a native struct with a pointer member.
typedef struct someStruct SomeStruct;<br />
struct someStruct{<br />
...<br />
SomeStruct *tp_nextp;<br />
};
I'm hosting that struct in a managed class as a field.
Do I need to use the delete keyword on the pointer when the managed object is disposed?
2.
If I put a pointer to a member of that struct, does it need to be deleted?
Thanks,
Yaakov
|
|
|
|
|
What I had seen when I was using MC++ was that if I had a COM object that was used inside of a managed object, the memory and the COM object would be cleaned up but only after the application exited, not when the managed object went away. We had to call a function to delete the COM object when we wanted to when the managed object was disposed. Not sure if it would be the same for you, but you could always turn that unmanaged struct into a class and put some code into the destructor to see when it gets called.
Steve Maier, MCSD MCAD
|
|
|
|
|
I am trying to create a flash movie from within an MFC (MDI) application. The movie must receive information from the program, but not necessarily send anything.
I am aware that I might need to launch IE to run the flash file, so help with that is also appreciated.
Here's what I am looking for:
1. What libraries do I need, and where to get them?
2. Perhaps a code snippet or documentation reference.
3. Code to launch IE (unless there's a way to display a flash movie in a regular MFC view).
Thanks
PS: Sorry if this is the wrong forum.. still learning the ropes.
When the going gets tough... write a computer program to do it for you
|
|
|
|
|
FayezElFar wrote:
PS: Sorry if this is the wrong forum.. still learning the ropes.
yep, it is. This is the managed C++ forum, for questions about C++ that's been made next to useless by the .NET framework. You need to ask in the C++ forum.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
Well, yeah, I do, but I come to this forum regularly to point people who obviously have no idea what MC++ is in the right direction. This forum seems (rightly) to be a ghost town, so I reckon a lot of people who would get answers quickly, don't because they mistakenly post here.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi guys,
I've implementing a simple class that creates a mutex and release it in the destructor (finalize), but everytime the application is closing a ObjectDisposedException is thrown. Source code here:
public __gc class SingleInstance
{
public:
SingleInstance(String *mutexName) {
m_mutex = new Mutex(false, mutexName);
}
virtual ~SingleInstance(void) {
if (m_mutex)
m_mutex->ReleaseMutex(); <--- !exception here!
}
public:
bool IsAnotherInstanceRunning() { return !m_mutex->WaitOne(10,true); }
private:
Mutex *m_mutex;
};
Can anyone of you tellme why this is happening? m_mutex is not supposed to be already disposed! Should I avoid dispose of m_mutex object? How?
Regards and thanx in advance,
Francesco
|
|
|
|
|
The problem I am having deals with wrapping an unmanaged C++ class which uses iostream and sends output to cout and then using the managed class in C#. When I make a method call on this class, I get the following error:
*** Exception! ***
Method: std.basic_ostream<char,std::char_traits<char> >* std.operator<<<struct std::char_traits<char=""> >(std.basic_ostream<char,std::char_traits<char> >*, SByte*)
Message: Object reference not set to an instance of an object.
When I replace the cout call with a call to printf, I do not get an error.
Here is the corresponding code. Thanks for the help or direction where I can get help.
USimple.h
#pragma once
__nogc
class USimple
{
public:
void PrintIt( );
};
USimple.cpp
#include "stdafx.h"
#include <iostream>
//#include <stdio.h>
#include "MSimple.h"
#include "USimple.h"
void USimple::PrintIt()
{
std::cout << "Hello, World" << std::endl;
// printf( "Hello, World\n" );
}
MSimple.h
#pragma once
#include "USimple.h"
using namespace System;
public __gc class MSimple
{
private:
USimple __nogc* m_pUSimp;
public:
MSimple( );
~MSimple();
void PrintIt( );
};
MSimple.h
#include "stdafx.h"
#include "USimple.h"
#include "MSimple.h"
MSimple::MSimple( )
{
m_pUSimp = new USimple( );
}
MSimple::~MSimple()
{
delete m_pUSimp;
}
void MSimple::PrintIt( )
{
m_pUSimp->PrintIt( );
}
Class1.cs
using System;
namespace CsSimple
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
try
{
MSimple simple = new MSimple( );
simple.PrintIt( );
}
catch( Exception e )
{
Console.WriteLine( "\n*** Exception! ***" );
Console.WriteLine( "Method: {0}", e.TargetSite );
Console.WriteLine( "Message: {0}", e.Message );
}
Console.WriteLine( "Press enter to exit" );
Console.Read(); // Wait for enter pressed to end programme
}
}
}
Thanks again,
John Stedman
|
|
|
|
|
hi all there, i want a code that help me to insert any file type in a rtf file, i need to insert by code not drag drop by mouse so plzzzzzzzzzzzzz help me .......
Thanks alot
Metal Man
|
|
|
|
|
Try asking in the C++ forum.
Isn't rtf rich text format ? How can you insert 'any file type' into a text file ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|