|
in fact, even i'm not sure if it's possible, i would like to creta a library of functions which could be called from excel or vba, i don't know, so that as i need some array of inputs which are created in excel, i could use the inputs parameters in excel and use c++ methods to do calculations.
is it enough to help me, because it will be very difficult to specify all my application in only few words.
thanks
gerald
|
|
|
|
|
Do a search on MSDN for "Excel COM Add-ins and Automation Add-ins" or do a search for Office COM Add-ins.
Michael
|
|
|
|
|
I've an ActiveX control which displays drawing data.I want to subclass the control.when I execute my dailog based application,the control is subclassed through DDX_Control.Till here everthing is fine.
when I give the control a drawing file to display(through the wrapper function provided for the control),a couple of new windows are created(I checked this in SPY).So the old subclassing in not working and I'm not able to track the messages for the new windows.
How to subclass these new windows???
m_volo.SetSrc(PathName);// This creates additional windows,volo is a
variable of control and SetSrc the wrapper function.
Ravi
|
|
|
|
|
My OS is Win2000 Server.
AddIPAddress(...) or others better?
Shuyi Vi
|
|
|
|
|
I have such a clever little idea for my next mini-project. I know how to make it such that the Scroll Lock light comes on by simulating the pressing of Scroll Lock via SendInput(). BUT.. is there a way to simply turn on the light without bothering with inserting a keystroke into the chain?
I guess these days with Win32 it's not as easy as just poking a low memory address like before.
- Jason
SonorkID: 100.12194
's your uncle
|
|
|
|
|
This link might help you :-
http://www.codeguru.com/system/NTKbdLites.shtml
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hello.
I got a problem when using vector which is filled in dll. I have a vector of objects, then I pass this address of this vector to the function in a loaded dll. In the dll I'm filling this vector with some values. And problem is that when free dll handler, the memory in the vector got released also, so vector couses an exception when destructors of objects are called.
So it works untill dll FreeLibrary is called.
I've descover that there's no problem when destructor is not decleared as a vertul function. But what if I want to have it virtual?
There's an example of my code:
//It's a simple object:
class CSJImage
{
public:
CSJImage(){};
CSJImage(const CSJImage& orig){};
CSJImage &operator=(const CSJImage& orig){};
// remove virtual and everything is fine,
// but with virtual I have an error if I want to clear the vecor!
virtual ~CSJImage(){};
};
// vector type which address is passed to the dll
typedef std::vector<csjimage> VectorType;
// prototype of function in the dll
typedef int(*fntTest)(VectorType*);
This's function in DLL:
extern "C" __declspec(dllexport)
int Test(VectorType *vec)
{
CSJImage so1,so2;
vec->push_back(so1);
vec->push_back(so2);
return 2;
}
In the main program I'm doing this:
VectorType vec;
HINSTANCE m_hAcqLib;
fntTest fntAddr;
// Load function address into fntAddr here!!!
fntAddr=GetAddress();
fntAddr(&vec);
// Here I can use vec and what it contains
// vec.clear() // this wouldn't couse any exceptions
if(m_hAcqLib!=NULL) FreeLibrary(m_hAcqLib);
// But here I can not any more
vec.clear() // this couses an exception!
Thanks for help
Alexander.
|
|
|
|
|
Hi Alexander, your problem does not have to do with STL, but rather is a consequence of how C++ handles virtual functions. Let me explain:
Suppose class A has one or more virtual functions (as the destructor in your case). Then, for A and every class deriving from A the compiler creates an static table of pointers to the actual implementations of such virtual member functions (what is called a virtual table). Then, a "hidden" pointer pvtable is placed inside each instance of A or a derived class pointing to the appropriate virtual table. This way, when a program calls a virtual function on a A* variable, it access the right implementation by means of pvtable (different compilers might use other approaches to implementing virtual member functions, but you got the idea).
Now, the problem with your app is that the main program is creating a virtual table for CSJImage and the DLL has created another CSJImage virtual table of its own. So, CSJImage s created in the main program and in the DLL point to different (if equivalent) virtual tables. Now the cause of the crash is clear: when you unload the library, those CSJImage s point to a no longer existent virtual table, and an access violation pops up when invoking their destructor.
Now for the solutions:- The simplest solution is of course avoiding releasing the library, or making the destructor non virtual.
- If none of those are an option, then you have to make sure that all
CSJImage s are constructed inside the main program, not into the DLL. You can do so by defining a CSJImage factory function inside the main program and passing along a pointer to this factory to the DLL, like this:
typedef CSJImage* (* CSJIMAGE_FACTORY)();
CSJImage* CSJImageFactory()
{
return new CSJImage();
}
typedef std::vector<CSJImage*> VectorType;
typedef int(*fntTest)(VectorType*,CSJIMAGE_FACTORY);
...
fntTest fntAddr;
fntAddr=GetProcAddress(...);
fntAddr(&vec,CSJImage);
extern "C" __declspec(dllexport)
int Test(VectorType *vec,CSJIMAGE_FACTORY factory)
{
CSJImage* so1=factory();
CSJImage* so2=factory();
vec->push_back(so1);
vec->push_back(so2);
return 2;
} The downside is that you have transformed your vectors of CSJImage s into vectors of pointers to CSJImage , which adds the burden of properly deleting everything; but that's the price you have to pay for having polymorphic (i.e. with virtual member functions) types.
A rule of thumb when working with polymorphic types: whenever you define a polymorphic type A , have pointers to A instead of raw A s. Otherwise, chances are things won't work as expected.
Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a lot! Now I understand.
|
|
|
|
|
I origanlly placed this message in the lounge by purpose, me so stupid...
Anyways RTTI is still unfamiliar to me and is still unclear what exactly i can do with it. Heres the problem:
Assuming the following function is within a template and template functions can be passed the template parameter.
BOOL GetType(Type)
Will RTTI allow me do dynamically determine the types passed. For instance determine if it's a UINT or maybe is't a struct with 5 members 4 int's and one LPSTR.
Basically can I get the type passed into the function and maybe enumerate the sub-types if any???
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
RTTI allows you to find out if an object of a base class type is of a specificderived type.
CWnd * pWnd = new CEdit();
CButton * pButton = dynamic_cast<CButton*>(pWnd);
if (pButton)
{
AfxMessageBox "It's a CButton"; // this will NOT happen
return;
}
CEdit * pEdit = dynamic_cast<CEdit*>(pWnd);
if (pEdit)
{
AfxMessageBox("It's an edit box, and as an added bonus, RTTI works !!"
}
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
<Center><A href = "http://www.sonork.com" target = "_Blank">Sonork</A> ID 100.10002:MeanManOz</Center><Center>I live in <U><B>Bob's HungOut</B></U> now</center>
|
|
|
|
|
I see...
I guess that means what i wanted to do i can't...?
Crummy...I still don't see any usefulness for RTTI, ah well atleast now i know what it does, and maybe in the future i'll even be able to use it...
Thanx again!
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
Crummy...I still don't see any usefulness for RTTI, ah well atleast now i know what it does, and maybe in the future i'll even be able to use it...
It's VERY useful. you will often have a container of a base class pointer, and want to tell which of them is of a specific derived type, for example.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
when new another view(MDI window) , the deactive window lose the caret, but when active it sometime later, it will not show the caret, how to resolve it?
one is the other who absorbs the thoughts of others
|
|
|
|
|
Hi all,
I have a MDI MFC Application that causes OTHER applications that happen to be running at the same time to FLICKER uncontrollably whenever my application updates/refreshs itself. I understand how EraseBackground and PreCreateWindow can be used to eliminate flicker within the same application, but how I do I prevent my application from causing other apps to flicker?
Many thanks in advance!
|
|
|
|
|
You're not create a CWindowDC with NULL, are you ?
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Hi,
Thanks for replying, however I am not sure what CWindowDC is/has to do with MFC? Could you elaborate?
|
|
|
|
|
CWindowDC w;
w.CreateCompatibleDC(NULL);
will give you access to a DC for the entire screen. I thought maybe you were causing the whole screen to be refreshed somehow.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
No...I am doing no such thing...My app is a simple MFC MDI application - real straight forward. Anyone have a inkling as to what might be happening?
|
|
|
|
|
if you are 'doing' graphics and your display is set to 8-bit color (aka 256 color mode) then you are probably seeing palette flashing. You need to do a little research about palette management.
|
|
|
|
|
My screen is set to "million colors". In addition, my own application is NOT flickering/flashing - _other_ applications that are also on the desktop are...
?
|
|
|
|
|
Are you attempting to steal the focus anywhere in your program?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hi.
I have learned the fundamentals of C++. To honest, I truly enjoy programming using C++ and prefer to program using C++.
I signed up for a college course named "GUI Programming." I read the course information and saw that it goes over menu, dialogs, etc. I picked up the books for the spring semester today, and I found out that course is actually a Visual Basic course with emphasis on GUI. I was appalled when I saw the VB book. I thought all alone that the class was GUI programming using C++. I immediately returned the textbook and will drop that class.
My passionate is C++. I want to program exclusively using C++ no matter how difficult GUI is using C++. I would like to know what programming language do programmers use to program the GUI interface under Windows and Linux's XWindows? I returned the textbook, but I have not drop the class. The only reason I can see going through with the class is if it is possible to somehow convert GUI in VB into C++. However, I greatly prefer to use C++ exclusively.
Last, I really want to learn GUI. What are some good C++ books with emphasis on GUI programming?
Thanks,
Kuphryn
|
|
|
|
|
Any book on MFC programming will focus largely on GUI development. I like MFC programming with Visual C++ Unleashed, personally. I believe the M$ book on MFC is very good as well, as you'd expect.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
If you really want to learn about GUIs, then you should stick it out and take the class. You'll probably pick up some good tips on human factors engineering. If you're that serious about C++, then learning to program GUIs in VB will give you that much more appreciation for what you can do with C++. If your college doesn't offer any other GUI classes, then buy yourself a good book and learn on your own (that's what I did). But I definitely recommend taking the class just for the experience.
Good luck to you! GUI programming rocks.
Jon Sagara
What about ?
|
|
|
|