|
Scott Meyers is referring to the "copy constructor" and the "copy assignment operator". If you don't create these yourself, the compiler will create default ones. However, these default methods will only do a memory copy. Thus, you will have pointers pointing to the same dynamic memory allocations.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
hi all. i face a very simple problem.
my app outputs two windows using glut. both windows have the same display function and i want to display different things on each window. therefore, within the display function, i want to switch between the windows and display accordingly...how do i go about doing that?
--
dg
|
|
|
|
|
Do you have two dialogs window?
|
|
|
|
|
no..these are two separate windows that are configured to play apps - they are not dialog boxes
--
dg
|
|
|
|
|
I was wondering does someone know any good place to learn about how to use the xloper structure that in inherently built into Excel.
I am trying to pass some Excel ranges into a C++ DLL to do some calculations. What should I do?
|
|
|
|
|
A7Zulu wrote: I am trying to pass some Excel ranges into a C++ DLL to do some calculations. What should I do?
I would use Excel Automation.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
so i actually need the excel data stored something like this
typedef struct {
unsigned short iRows, iCols;
double dArray[FPARRAY_SIZE];
} FPARRAY;
to pass to this financial package library...
i know excel has internal structures that look like this, i was just wondering how to get this...
|
|
|
|
|
I was wondering I created a dll in C++ and a function is called from Excel
typedef struct {
unsigned short iRows, iCols;
double dArray[FPARRAY_SIZE];
} FPARRAY;
I want to return a pointer to this struct back to Excel, so that I can access that new data created in my dll.
If this is impossible, how do I get data set/created in C++ back into Excel so it can be viewed?
Thanks
|
|
|
|
|
|
Hi,
I would like my VC++ client application to dynamically instantiate a class defined in a DLL knowing only (1) a DLL file name and (2) the name of a class defined in the DLL. Is this possible without using .NET?
Here's what I am currently doing...
An exported function in a DLL returns an instance of the class MyDerivedClass (which is a class derived from MyBaseClass):
extern "C" <br />
{<br />
__declspec(dllexport) MyBaseClass* getMyBaseClass()<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState())<br />
MyBaseClass* answer = (MyBaseClass*)new MyDerivedClass();<br />
return (answer);<br />
}<br />
}
My client application loads the DLL at the appropriate time and calls the known, exported function to retrieve a pointer to a newly instantiated MyBaseClass object:
CString libraryFileName = ...<br />
<br />
HINSTANCE library = ::LoadLibrary(libraryFileName);<br />
<br />
typedef MyBaseClass* (*ExternalFunction)();<br />
ExternalFunction function = (ExternalFunction)::GetProcAddress(library, "getMyBaseClass");<br />
<br />
MyBaseClass* aBaseClass = function();
This approach works fine but I think it would be cleaner for developers of the DLL to only have to define their MyBaseClass-derived class in the DLL and not have to implement the 'C' function to return it.
Any and all help appreciated!
Peter
|
|
|
|
|
Try putting the __declspec(dllexport) on the class definition itself so the entire class is 'exported'
<br />
__declspec(dllexport) class CMyBaseClass<br />
{<br />
};<br />
//Generally what you do is include the header file in both dll and client and use something like this.
MYAPI class CMyBaseClass<br />
{<br />
};<br />
where MYAPI is #define d to __declspec(dllexport) for the Dll and __declspec(dllimport) for the client.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks for your response. Unfortunately, I do not believe that your solution is exactly what I was looking for. Let me clarify a few things...
Although the client knows about MyBaseClass (it includes the MyBaseClass header file), it does not know about the MyBaseClass-derived class defined in the DLL (it does NOT include the MyDerivedClass header file, nor do I want it to).
The client application's configuration file contains a DLL file name and the name of a MyBaseClass-derived class. At runtime, the client application loads the DLL (using the configured file name) and dynamically instantiates the MyBaseClass-derived class (using the configured class name).
I want my developers to be able to develop multiple DLLs, each housing a different MyBaseClass-derived class (e.g., MyDerivedClass1, MyDerivedClass2...). Custom functionality will be implemented simply by overriding the appropriate MyBaseClass methods.
Simply by configuring the client to use a different DLL and class name, the behaviour of the client can be changed without ever changing the client code!
Does anyone know if this is possible without using the .NET reflection classes?
Peter
|
|
|
|
|
I think I understand more clearly now. If you want to instantiate, possibly unknown, classes based on data then It's going to have to be COM or .NET I'm afraid. What you have at the moment is like a mini version of the way COM class factories work. There's an MSDN article in the ether somewhere called "From CPP to COM" which is what cracked COM for me. I'd take a look at that even if you eventually decide to go the .NET route.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
|
|
Hi,
after reading this thread I've maybe found a solution.
I think you could solve it with using templates.
The Base class:
class BaseClass
{
public:
BaseClass() {}
virtual void Show() = 0;
template<class T>
static BaseClass* Create()
{
return dynamic_cast<BaseClass*>(new T());
}
};
The derived class
class DeriveOne : public BaseClass
{
public:
DeriveOne() {}
virtual void Show()
{
std::cout << "DeriveOne.Show" << std::endl;
}
};
Then you could create a object like this
BaseClass* pBase = BaseClass::Create<DeriveOne>();
if(pBase != NULL) pBase->Show();
I don't know if this is what you need.
codito ergo sum
|
|
|
|
|
I'm using matlab 7.0.1 (R14 sp1)
I want to CONVERT my GUI to a stand alone application (.exe file) that dosent need Matlab to run.
I uesed the mcc function but I faild
I uesd this code
mcc -m mygui.m
it creates an .exe file and some other files
when I run the .exe file, a black window appears for seconds then nothing happen
plz I need ur help
-- modified at 15:51 Tuesday 19th June, 2007
|
|
|
|
|
I have a listview control and i would like to change the background colour of it.. How would i implement this in pure C/C++ using the Win32 API?
Thanks for your help!
--PerspX
|
|
|
|
|
BOOL bSystemColor = FALSE;
COLORREF clrNew = RGB(0,0,0);
COLORREF clrOld = (COLORREF)SendMessage(m_hWnd, EM_SETBKGNDCOLOR, bSystemColor, clrNew);
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
Randor wrote: ...EM_SETBKGNDCOLOR...
Do listview controls respond to messages meant for edit controls?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
heh,
Actually I responded to the question thinking he was asking about a RichEdit control.
|
|
|
|
|
Ignore my previous post, I responded while multi-tasking and forgot the original question.
Try:
SendMessage(hWndList,LVM_SETBKCOLOR,0,(LPARAM)RGB(0,0,0));
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
How about using the LVM_SETBKCOLOR message (ListView_SetBkColor macro)?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks guys maybe i should have looked at the MSDN documentation more closely..
Thanks for your help!
--PerspX
|
|
|
|
|