|
AFAIK you CANNOT share C++ code compiled with one vendor's compiler for use by another vendor's compiler. So if you write a C++ class in MSVC and make it into a DLL, you can't then use that dll/class with another vendor's compiler (like Borland). The problem is that each vendor has different ways of layout various C++ internals, such as virtual function tables, multiple inheritance, name mangling (for function overloading, a C++ feature), etc. Plus other features, like operator new/delete may be done differently and the vendor's underlying C Runtime may have a different memory manager, which will cause problems for stuff like the STL (classes like std::basic_string use the C runtime).
Part of the reason for COM was that C++ couldn't be shared this way. You'll note that when application's expose their API for 3rd party plug-ins in C++ they ALWAYS state the compiler you have to use. For example, Alias|Wavefront's Maya program (a powerful 3D Editor) has a sophisticated plugin API in C++, but you MUST use the MS VC compiler to develop for it - you can't use Borland, Digital Mars, GCC or anything else.
This is a known problem, and so far the vendor's have never agreed to a common C++ ABI. It's slightly less of a problem on other platforms, but it's still there. For example on linux most people use GCC and the GCC folks have published and (supposedly) adhere to an open binary ABI for C++. Mac OS X also shares this ABI and I believe that vendor's like Metroworks also honor it (at least on OS X).
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
You have to export an explicit instantiation of vector<AnotherClass> . The procedure is thoroughly explained in this MSKB article[^].
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi
How to resize an ATL activeX Control ? (from inside the Control's code)
I use SetWindowPos or MoveWindow and they work..But when the contol is activated (the user clicks it) it's resized back to the original size.
any help with this ?
I use ATL 3.0
|
|
|
|
|
|
However if your constol is being hosted in Internet Explorer - that won't work.
The "trick" in IE is to find the IHTMLObjectElement that represents your ActiveX control & change it's height / width. This will cause IE to adjust it's layout & resize your ActiveX control's window.
[ Jason De Arte | Toy Maker | 1001010.com ]
|
|
|
|
|
Jason De Arte wrote:
However if your constol is being hosted in Internet Explorer - that won't work
Are you sure ?
In fact I used this in IE6 and worked fine !!
does this change for other IE versions ?
|
|
|
|
|
I am as certain of that just as I am certain of my ability to spell the most common of words.
constol d'oh!
[ Jason De Arte | Toy Maker | 1001010.com ]
|
|
|
|
|
Dear Sirs,
Would you be so kind as to suggest me how it is possible to make IE Toolbar in your sample multiline. I tried SetRows() but it does not help me(of course I used TBSTYLE_WRAPABLE). I have read similar article here about problems with SetRows() in a simple floating Toolbar, it was solved be resizing parent control (or so?). I also had no luck in this approach. I always getting one line (but seems to me SetRows return correct coordinates as it should be to display the whole toolbar).
By the way, I used cmnctrl1 sample from MSDN and here SetRows works to set 2 lines(but not 3) even without TBSTYLE_WRAPABLE.
Best Regards,
Igor
|
|
|
|
|
I'm mentally preparing myself to start using std::vector instead of C-style arrays when interacting with legacy C APIs like the Win32 API. I mean to use &vec[0] to pass a pointer to a writable buffer to the APIs, but I wonder if &vec.front() is enough (I'd prefer it to be so).
In the std implementation we use (the one by Plauger), &vec[0] and &vec.front() evaluates to the equivalent result. Is it guaranteed to be so, or is one of them preferred over the other in this case?
Thanks for any input!
--
The Blog: Bits and Pieces
|
|
|
|
|
Both formulations are the same, and guaranteed to be so.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_subclas3.asp
Note Do not superclass the scroll bar control class because Windows uses the class name to produce the correct behavior for scroll bars.
But I cannot find any special code that handle the scrollbar in ATL.
|
|
|
|
|
You can subclass the scrollbar. Subclassing doesn't affect the class name. The article mentions that superclassing scrollbars don't work.
I.e., create the scrollbar, and then subclass it. See CWindowImpl::SubclassWindow() .
retinoscopy wrote:
But I cannot find any special code that handle the scrollbar in ATL.
Scrollbars are usually handled by intercepting WM_HSCROLL and WS_VSCROLL . When the scrollbar is manipulated by the user, it sends either of those messages, depending on its orientation, to its parent window. Windows can be created using the WS_HSCROLL and WS_VSCROLL window styles, which will automatically add scrollbars to the window. This is done by windows itself, and not ATL (MFC nor WTL for that matter).
See this[^] for information about scroll bars, and then take a look at either CWindowImpl::SubclassWindow (to implement a class which handles the subclassing), or see CContainedWindowT[^] (to intercept scroll bar messages in another class' message map).
If you haven't already, take a look at WTL, as it makes windowing with ATL a lot easier.
--
...Coca Cola, sometimes war...
|
|
|
|
|
Thank you for you timely reply.
|
|
|
|
|
I don't have the WTL yet, but I will download it to look into the code.
I wonder why the scrollbar must be handled differently from all other controls, i.e. cannot be superclassed? Suppose that I want to create a scrollbar control and I want intercept all windows messages sent to it, if I cannot superclass it, I have to globally subclass it, otherwise I have to setup some CBT hook before creating the control. If I globally subclass the scrollbar, however, I think I have to undo the subclassing of all scrollbar that are created (just after I globally subclass the scrollbar control) by another threads from some DLLs made by other people.
|
|
|
|
|
retinoscopy wrote:
I don't have the WTL yet, but I will download it to look into the code.
WTL is sort of like MFC, but very much ATLish. WTL provides all the standard controls with CWindow-derived counter parts, as well as a couple of controls implemented in WTL (CWindowImpl-derived). For the most part, the MFC docs are valid.
retinoscopy wrote:
I wonder why the scrollbar must be handled differently from all other controls, i.e. cannot be superclassed?
Probably due to some laziness of a Microsoft hacker It was probably a tradeoff they made to make some implementation aspect easier.
--
...Coca Cola, sometimes war...
|
|
|
|
|
Hi I've basically created a Class called a Session which uses the STL <vector> container to Add 'Jobs objects'. The Job objects add further record objects.
The class as it stands is working fine.
What i want is to write the Session object to a file.
then the next time the app starts i want to read back in the class data from the file.
What i've tried:
1:
I've played with File Mapping, and it seems fine with structures but when i try it with my class using STL, it falls over.
2:
ofstream using the binary flag. - this seems to write it away ok but i have real trouble reading it back in.
Have you had any experience writing a class object to a file that uses the STL?
thanks in advance
Carl
Assemblysoft.com
|
|
|
|
|
crandall wrote:
Have you had any experience writing a class object to a file that uses the STL?
What I usually do is overload the << operator and use that to write my class data members to the stream. You can do this for a stream or a CArchive if you're blending in MFC. This way you could just add the object in your Serialize() code or just insert it natively to a stream.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
1:
If i overloaded the << operator would i be able to achieve something like below?
(might not be completely accurate as just started using fstream rather than fstream.h)
Session s1
s1.DoSomething();
ofstream dataOut(pfileName,ios::binary);
dataOut.write( (char*) &s1,sizeof s1);
dataOut.close();
//On another Day
ifstream fin;
Session *pob;
ifstream fin;
fin.open(pfileName,ios::binary);
fin.read((char*) pob,sizeof(pob));
pob.DoSomething();
fin.close();
2:
With the read in, If the Session contains a vector container of objects of another class, would the sizeof(pob) be correct?
thankyou
Carl
|
|
|
|
|
No, it doesn't work that way. You have to manually store off your data members individually because they are most likely not in a contiguous memory block. If Session was a struct and you were careful of your struct member data alignment, then that could possibly work out OK.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Ok i see how i would do that for the Session class, and i just read an article on transient types which need to be converted to basic types first, but how would i go about storing the items in the vector?
do i store each member of each object by looping through with an iterator?
thanks
Carl
|
|
|
|
|
crandall wrote:
do i store each member of each object by looping through with an iterator?
yup.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Ok so i can't see why i can't get that bit to work.
How about reading it back in? (please don't just say reverse it)
I create an object of the class
Do i then go through and push_back (re create) from my basic types?
Does that mean i need to store the amount of records for later?
STL was supposed to make my life easier - lol
thanks
Carl
|
|
|
|
|
crandall wrote:
(please don't just say reverse it)
Well, you could either store the number of records as you mentioned, or you could just process until you reach eof(). Have a look at my CDataFile class[^] to see how I do it.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
thanks a lot for your help
|
|
|
|
|