|
|
Something like this ?
CMyMainWnd::OnCommand1()
{
CMyDoc* pDoc = GetActiveDocument();
POSITION pos = pDoc->GetFirstViewPosition();
while( pos )
{
pView = pDoc->GetNextView( &pos);
if( pView->IsKindOf(RUNTIME_CLASS(CMyView1)))
{
((CMyView1*)pView)->WelcomeYou();
}
....etc
}
}
|
|
|
|
|
Thanks for your idea. I do think this approach works except a maintainence problem. Any time I add a view or I have a new command which will cause a train reaction for other view, I have to add a new handler in the CMyMainFrame or add a new IsKindOf(..) in the while loop, right?
|
|
|
|
|
Or you can send the message to each view ...
//
while(....)
{
pView->SendMessage( );
}
and each view will process the message in his own way.
|
|
|
|
|
Think about overriding OnCmdMsg( )and route the messages yourself.
|
|
|
|
|
I will take this approach and give it a try.
Thanks.
|
|
|
|
|
Hi There,
I have a question about tree controls. If I set a tree item's data to something like a pointer to a class or something, when is the appropriate time to delete the pointer?
This is inside a dialog bar which houses the tree control.
Thanks,
Aaron
|
|
|
|
|
When you receive a TVN_DELETEITEM notification for an element in the tree control. That is by far the best way.
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?
|
|
|
|
|
OK, thanks. I suppose this is sent out both when a single item is deleted from an active tree control and during the destruction of the entire control?
|
|
|
|
|
When you delete the control, TVN_DELETEITEM will be sent for each item in the control. It sounds excessive, but it works just fine.
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?
|
|
|
|
|
Thanks!
|
|
|
|
|
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
|
|
|
|
|