|
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
|
|
|
|
|
|
OK, I've had to learn on the job doing this and that, done some Win32, some MFC, C++ but without a background in proper design and usage, and I'd like to step back and learn properly. The issues I have are that I'm often confused by things that I don't even know are different, like when someone says "VS 2005 complies C++ better than VC++6". My experience of VS6 is that it did everything fine and I got used to where most things are (though I am still not very clued up on it, at least I have the MS book for it - could not find an equivalent for VS2005). I also get mixed up between when I'm using C++, when I'm using STL, when MFC/raw Win32 etc. I've got quite a few books, some unread, and some read but wondered if anyone who was an expert could give a clear path (or a link to sites that would give this info) to step back, find out about what the current C++ standard is, what's changed from what I may know now (and not even realise), generic info about the development environment and Visual Studio in particular (in Vista, still not happy with it!), going on to C++ learning (more formally with more depth of knowledge), good things to do to try and get practice, perhaps online courses or tutorials or workbooks?, then info on the different things like STL, MFC etc, how they fit in with the bare bones, all the way through to developing good quality apps and code. When I read software design articles (eg some of the ones at flounder) I am inspired to be able to do this properly but have fallen into the trap (not my own fault really) of having to learn 'just enough' without understanding it all and fixing things by brute force or by asking for help or digging through the help files/docs (by the way in places the MSDN help from F1 in VC6 is woeful!)
anyway, I hope someone can take a few minutes to help me. I know these kind of questions often get a generic one line answer, and I can understand that to some extent, but I'd really like to get some help with a more structured plan for building a proper skillset up, perhaps some bad habits will be harder to break but on the other side, some concepts won't be so alien to me having done some fiddling
many thanks,
Lee
|
|
|
|
|
I found Easiest way and reliable way to learn . net by this video series
Though I have not purchased but getting free video's and they are quite useful,LearnVisualStudio. NET
|| ART OF LIVING ||
|
|
|
|
|
To answer a few of your questions, you're using STL when you have to use include any of the STL container headers, such as vector, deque, map, queue, etc. I believe you're using MFC if you have to use anything that requires afxwin.h. As for when you're using C++, well, you're either using C, C++, or Managed C++ unless you're doing some kind of crazy interop work. If you use templates or make use of a C++ compiler, then you're using C++, if you have to use any handles, then you're using Managed C++ (^ vs. *).
|
|
|
|
|
ldsdbomber wrote: having done some fiddling
Some people would say that I learned almost everything I know by fiddling. The key is knowing what to fiddle with.
If you want the full works on C++ Mr Stroustrup is your man. It's his baby.
http://www.amazon.com/s?ie=UTF8&keywords=History&rh=n%3A565718%2Ck%3AHistory&page=1[^]
If this is the latest one it's got lots of STL goodness as well. For advanved STL usage and scary template stuff see www.boost.org[^]
For Microsoft technologies like Win32 and MFC then MSDN is really the definitive source.
It took me a few years to get all the technologies separated out in my head and get a grip on what's what. I guess it's pretty normal.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|