|
If you leave the .rc .bmp empty you could always add whatever you want from the code. You would still be stuck with the resource though, but that is the way CDialogBar works.
You can also use a CToolBar to add arbitrary controls in. But this also requires a resource. CToolBar provides more control with GetToolBarCtrl(), so if you want to do more advanced stuff, that is probably the way to go.
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Hi,
I´m running word as embedded ( like if it where and standalone application) throught automation, I would like to move and resize the window to a desired position and size ( just to make it fit between my windows), but I got the problem that it seem that Word doesn´t work with pixels ???, do you now something about that ?, How can I convert from pixels to word coordinates in order to move the Ms Word window ?
I use the methods from the application interface:
SetLeft();
Resize();
Thanks, Bye !
Braulio
|
|
|
|
|
I would like to create a vc++ application which could be used from excel. in fact i would like to use the calculation possibilities from c++ and use the environment of excel. I heard that i have to create a dll application, but i never do that before, so i would like to know if anybody could give me a sample of code or indicate me a place where i could find some explanation to do that.
thanks in advance
gerald
|
|
|
|
|
there's an MSDN sample called COMEXCEL, which controls an Excel-programm out of a c++-app. Maybe youcan make it go in the other direction!
good luck!
|
|
|
|
|
i don't want to control excel, i just want to do some calculation with c++ from excel so that i could use the excel environment and benefit of the vc++ compilation
do you see what i mean?
|
|
|
|
|
You'll probably need to create a COM DLL that can be called from Excel VBA via the CreateObject method.
Michael
|
|
|
|
|
could you tell me more about this way of working?
thanks
|
|
|
|
|
It depends on what your are trying to achieve but in theory,
Create an ATL DLL with a Simple COM object, add your methods to the object.
In Excel create your VBA code to call your functions and return your results.
If you need a more detailed answer, you'll need to supply more information about what you want to do.
Michael
|
|
|
|
|
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?
|
|
|
|