|
I want to be able to display a toolbar to the users with custom buttons (defined in a settings file - NOT resources) and a custom bitmap (also defined external to the application).
Is this possible to with a CToolBar? I know I can use SetButtons to customize the buttons, but it looks like the only way to set a bitmap into a CToolBar is through LoadBitmap. And I don't think I can use LoadBitmap with a non-resource based bitmap.
Any ideas? I'm trying to do it without writing a custom control... if there's no way, I'll just make 'em static. Just trying to be a bit fancy.
J
|
|
|
|
|
Oi. I'm stupid. Just found CToolBar::SetBitmap().
J
|
|
|
|
|
There are many, many ways of getting a CBitmap or BITMAP from a file. See the relevant areas on codeproject.
good luck
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Quick Question! How do I go about changing the colors of the text and background in a standard list box?
|
|
|
|
|
In the parent window of your listbox handle this message:
WM_CTLCOLORLISTBOX
This will allow you to select a brush for the background and set teh color of the text.
|
|
|
|
|
Check this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hi,
I have an "IPicture *" object in my ActiveX control, and I would like to serialize it ( so when the object is save in the container It can be loaded later).
The problem that property maps work pretty well for simple things like integers, or boolean, but I have no idea how to save my IPicture object.
Can you help me please ?, Thanks in advance, Bye !
Braulio
|
|
|
|
|
Try with this
PROP_ENTRY("Picture", DISPID_PICTURE, CLSID_StockPicturePage)
or with CLSID_MSStockPicture.
I think if i'm not mistaken that this stock implementation supports jpg, gif , bmp, wmf and ico files.
I think also you must include the MSStkPPg.H .
Ah and you must distribute the MSStkPPg.dll.
Hope this helps Braulio,
Joao Vaz
|
|
|
|
|
Hi Joao !
Thanks, for the tip, but for the DISPID_PICTURE, I need to set a property with a dispatch pointer isn´t it ?, mmm... the problem that I have is that the pointer that contains the metafile can be NULL , sorry but I don´t understand too much the prop_entry for saving com objects.
I have tried a dirty way:
In my .H file I have:
CComQIPtr<ipicture> _Pict; // Better to use smart pointers, just forget about AddRef, Release, QInterface...
TO LOAD
HRESULT IPersistStreamInit_Load(LPSTREAM pStm, ATL_PROPMAP_ENTRY* pMap)
{
CComPtr<IPictureDisp> pic;
LARGE_INTEGER l;
l.QuadPart =0;
pStm->Seek(l, STREAM_SEEK_SET, NULL);
OleLoadPicture(pStm, l.LowPart, FALSE, IID_IPictureDisp, (void **) &pic);
if(pic) {
_Pict = pic;
}
HRESULT hr = MyAtlIPersistStreamInit_Load(pStm, pMap, this,
(IUnknown*)(IDispatch*)this);
if (SUCCEEDED(hr))
m_bRequiresSave = FALSE;
return hr;
}
TO SAVE:
HRESULT IPersistStreamInit_Save(LPSTREAM pStm, BOOL fClearDirty,
ATL_PROPMAP_ENTRY* pMap)
{
if(_Pict) {
CComQIPtr<IPersistStream> p = _Pict;
p->Save(pStm, FALSE);
}
return MyAtlIPersistStreamInit_Save(pStm, fClearDirty, pMap, this,
(IUnknown*)(IDispatch*)this);
}
It seems to work, but I´m not sure if it´s a time bomb , what do you think about it ?, Thanks a lot Joao, Bye !
Braulio
|
|
|
|
|
Hum, it seems a working clever hack
To tell the truth, it's almost one year that i don't touch ATL, i'm currently
currently working with TCL(kinda of perl) , javascript and html , what a programmer makes for a living ..., oh well only more 2,3 months and counting...
Despicte all the braindamage that COM and ATL provocated on me, i miss it , well..., what a heck, i will start definity to work again on COM and c++ just to amuse myself, these fuc**** months, i want my C++ mummy
Good luck on your project Braulio, and asta la vista ...
Joao Vaz
|
|
|
|
|
Thanks !
He he, it's truth, C++ and ATL it´s like a drug... sometimes you hate it but you need it ... But anyway sometime is good to have some stop with ATL programming if not you can turn crazy
It´s a pity that Microsoft it´s going to throw ATL to the garbage , they have released a new version and then... not more like with MFC, ... but the people says that .net i´ts easy and powerfull ( we will be working with VBasic in some years ).
See ya !
Braulio
|
|
|
|
|
Hey Braulio, on VC .NET you still have ATL 7.0 and ATL Server(programming ISAPI applications, web services, ...), so your knowlege do not go the trash can, and by the way, i saw in a microsoft newsgroup thread, that will be mc++
(managed c++) form designer in VC8++ , from a member on the VC++ compiler team, like thre is a vb.net and c# form designer,they simple didn't have time, so nothing is lost, and don't forget Stan Lippman , one of the c++ Arquictects now works for Microsoft , and it keeps saying that c++ will play a major role on .NET plataform, so i don't believe that this guy could lie to us , c++ programmers
Cheers,
Joao Vaz
|
|
|
|
|
Hi.
I have two classes, CMyFirstClass and CMySecondClass.
MyFirstClass creates CMySecondClass objects dynamically. It is NEVER appropriate to create a CMySecondClass outside of the CMyFirstClass object.
To make things tidier, i put the declaration of CMySecondClass inside of CMyFirstClass. Now I have a shorter list in Class View. And my app still works.
My question: Is this a good idea? is there a compelling reason NOT to nest class declarations?
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
Nested classes are quite heavy used in MFC, If I´m not wrong ( or if the things haven´t change this times ), for example is how MFC creates COM objects ( the macros for the interfaces, declare just nested classes), so I think it´s ok.
HTH
Braulio
|
|
|
|
|
Jon Hulatt wrote:
Is this a good idea?
why not?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I think it is more a style thing. Unless it is a very small class utility class I don't like to nest classes. Makes it harder to read otherwise. Just my opinion though.
|
|
|
|
|
You don't prevent third code from creating CMySecondCLass es just by defining it into CMyFirstClass . It is required also that:- The nested class lies in the private part of the nesting class,
- or the constructors for the nested class are private and the nesting class is a friend of the nested class
Apart from this, nesting it is an excellent way to restrict visiblity and show design dependencies between classes (IMHO).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The declaration of the second class is within a protected: section.
Doesn't really bother me if technically i could create an instance of the second class elsewhere, it's definately more of a design and organisation thing.
I just wondered if i was overlooking some limitation or side effect of class nesting.
Obviously not, great!
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
|
thanks nish. although it's got to be a class, because it has member functions and things. besides, what's the difference between a struct anyway?
And I like the whole nested classes thing. it makes things more confusing for the uninitiated. Which makes me feel cleverer.
Does anyone else here secretly enjoy it when they come up with something really complicated that noone else will ever make head or tail of?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Does anyone else here secretly enjoy it when they come up with something really complicated that noone else will ever make head or tail of?
No, because every time I do something like that, I am the one who can't make heads or tails out of it 2 months later.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
A struct and a class are basically the same thing in c++, however a struct defaults all of its members to public and the classes default declaration is private.
Other than that you can inherit and do all of the things that you can do from a class, with a struct.
|
|
|
|
|
Jon Hulatt wrote:
Does anyone else here secretly enjoy it when they come up with something really complicated that noone else will ever make head or tail of?
I enjoy it, but I also enjoy trying to explain to someone what I actually did, and try to help them understand it, then they get a deeper appreciation for some of the code that I develop.
|
|
|
|
|
Jon Hulatt wrote:
Does anyone else here secretly enjoy it when they come up with something really complicated that noone else will ever make head or tail of?
I prefer hearing that my code and interfaces are clear and easy to understand. Code that is extremely hard to understand is usually an indication of poor design.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Theres nothing wrong with nested classes. If CMySecondClass is only meaningful in the context of a CMyFirstClass object, then nesting the classes makes this clear.
However, if the second class is an implementation detail that doesn't appear in the public interface, there is another technique that you may be able to apply. In the header file that declares CMyFirstClass you simply give a forward reference to CMySecondClass:
class CMySecondClass;
class CMyFirstClass
{
public:
protected:
CMySecondClass *m_p_instance;
};
Now, both the declaration and implementation of CMySecondClass can be put in the implementation file
for CMyFirstClass. This provides much stronger encapsulation than a nested protected or private class, since the details of CMySecondClass aren't even visible to code that uses CMyFirstClass (other than the fact that CMySecondClass exists). With a nested protected or private class, the details of CMySecondClass are visible, but access is restricted.
Stephen C. Steel
Kerr Vayne Systems Ltd.
|
|
|
|
|