|
In the STL section.
I tried this yesterday with no success, but hopefully here is a link to my vector article, which is at http://www.codeproject.com/vcpp/stl/STL101.asp (just in case it didn't work again ).
ed1 wrote:
Which is better for intensive number crunching? (Vectors or Carray)
Vector, only because the STL comes with a ton of algorithms, which have been written to be as optimised as possible.
ed1 wrote:
Can a vector hold a custom structure?
Absolutely, but you'll need to read my article on function objects to see how to use custom objects with the algorithms. Of course CArray has no algorithms at all, so it's hardly a bad thing, in fact you'll find it amazingly powerful.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
There are some good posts here on the board, but nothing really answers my question.
Say I have an object foo, and a function called DoSomethingWithFoo( IDispatch** val ), it seems a bit of a pain to have to use the IDispatch interface when I would like to just pass the object in. Sureley there is an easy way? To make this clearer:
I have a pointer MyFoo*. I want to call a method bar, which does something with foo objects. Unfortunateley, we only have a bar( IDispatch* ). It seems a pain to pass in an IDispatch pointer, then to use idispatch->Invoke, simply to call the method I want, especially when I have lots of methods to call-
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&df=6&app=50&tid=82458&select=82458#xx82482xx
If this isnt clear please say-!
Thanks in advance
MO
|
|
|
|
|
If I understand you well:
IDispatch *pD;
MyFoo *pMf;
pMf->QueryInterface(IID_IDispatch, &pD);
Bar(pD);
pD->Release();
If this is not the answer you're looking for, please explain a little more.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Im not sure if thats what Im after, although Im experiemting now.... ill put it another way:
I have:
Member *myMember;
and a function:
MyClass::getMemberDetails( idispatch **val )
It would be cool if I could just go:
myClassObj.getMemberDetails( &myMember )
But instead I have to do this:
IDispatch *d;
myClassObj.getMemberDetails( &d )
So now the IDispatch item is pointing to the object I want, nameley a Member.
However, to invoke member funcitons on this new member, I have to use IDispatch::invoke, and all of the things which go with it (which I discovered on another post.) Id love to avoid doing all of this....
Hope thats clearer - and your help is much apprecaited on this!!!
|
|
|
|
|
Can you post a code sample? I'm not exactly sure what you asking. Is MyFoo* an interface, or more precisely a pointer to an interface or just a pointer to an instance of a concrete class?
|
|
|
|
|
sorry in the code sample above, member is an interface...!
|
|
|
|
|
Then I think you should be able to what your trying to do. As long as Member inherits from IDispatch, then the compiler will implicitly convert from an IDispatch pointer to an Member pointer. Is it not working?
|
|
|
|
|
What happens if you do this:
IMember *myMember = NULL;
myClassObj.getMemberDetails(&myMember )
|
|
|
|
|
If I just use my interface instead of idispatch:
cannot convert parameter 1 from 'struct IMessengerContacts ** ' to 'struct IDispatch ** '
If I add a cast, it compiles, but subsequent use of the pointer crashes it.... Here is the actual code:
IMessenger *msger;
IMessengerContact *pContact;
IMessengerContacts *pContacts;
IDispatch* id;
long pCount = 0;
hr = CoCreateInstance( CLSID_Messenger, NULL, CLSCTX_INPROC_SERVER, IID_IMessenger, (LPVOID*) &msger );
hr = msger->get_MyContacts( (IDISPATCH**) &pContacts );
pContacts->get_Count( &pCount );
I dont think I can use mine instead, as my object doesnt inherit from IDispatch, it implements it....
Thanks again
|
|
|
|
|
Is the line where it wont compile:
hr = msger->get_MyContacts( &pContacts );
This compiles, but the following line crashes:
hr = msger->get_MyContacts( (IDISPATCH**) &pContacts );
pContacts->get_Count( &pCount );
|
|
|
|
|
as my object doesnt inherit from IDispatch, it implements it
Shouldn't you be inherting from IDispatch and implementing it's methods?
|
|
|
|
|
Apologies, it does already:
IMessengerContacts : public IDispatch
Any ideas why it wont let me pass in an IMessengerContacts??? Hmmm
|
|
|
|
|
I think what I said earlier would only work if your method looked like this :
Messenger::get_MyContacts(IDispatch);
instead of:
Messenger::get_MyContacts(IDispatch*);
I think your gonna have to do this...
IMessenger *msger = NULL;
IMessengerContact *pContact = NULL;
IMessengerContacts *pContacts = NULL;
IDispatch* id = NULL;
long pCount = 0;
hr = CoCreateInstance( CLSID_Messenger, NULL, CLSCTX_INPROC_SERVER, IID_IMessenger, (LPVOID*) &msger );
hr = msger->get_MyContacts( &id );
hr = id->QueryInterface( IID_Contacts, &pContacts );
pContacts->get_Count( &pCount );
...
Ahhh, the joys of COM....
|
|
|
|
|
Thanks, you are a star!! This is basically what the first guy was trying to tell me, but I was too daft to realise
I feel that I understand COM a lot more now after fiddling around with this stuff for the lsat 9 hours !!!
Thanku!
|
|
|
|
|
I'd like to include the formatting rebar in a dialog box I'm creating. Does anyone have a sample of this? Maybe this might be an idea for an article?
The formatting rebar I'm talking about is featured in many MS editor based programs, such as MS Word, or Frontpage, and includes font selection, point selection, bold italic and underline selection etc.
Many thanx,
funbag
skydiving....if at first you don't succeed, you're fecked!
|
|
|
|
|
If I recall correctly, on the MSDN Help there is an example of an application similar to WordPad, maybe you can look it up there.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Couple of questions regarding PropertySheet Wizards:
- Is there a way to remove the upper right corner close button on the wizard pages?
- Is there a way to make one of the pages smaller? My first page in the dialog editor is smaller than the second. When I run the code, both pages are made the same size. I suspect the PropertyPage class sizes all the pages to the size of the largest page. I would like to make my first page the same size that is shown in the dialog editor.
Thanks in advance,
Bob
|
|
|
|
|
I try to set the focus to a control in a dialog window. I do this by calling
SetFocus to the object associated in the end of InitDialog().
But the result is nop. The focus is owned by other control and it doesn't
seem to be happy to renounce.
What is the solution?
rechi
|
|
|
|
|
Have you seen this comment at the end of the OnInitDialog() ?
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Unfortunately, it doesn't.
rechi
|
|
|
|
|
is it possible to create a new shared folder using VC++/MFC..so that files from this folder can be accessed from another machine?
anyhelp will be appreciated!
|
|
|
|
|
|
Hi,
I saw an article posted on full row highlighting in the ListCtrl section.I wanted to know if I could do the same thing if the ListCtrl has only one column in each row.Currently the blue highlight rectangle appears only for the length of the text (in small icon report view mode).Is it possible to extend the highlight to the entire width of the screen?I am making use of Embedded VC and basic Common Controls supported by WinCE(ie no MFC).
Thanks in advance,
V
|
|
|
|
|
IIRC, I had the same problem once, and I used Custom Draw to fix it by getting the item's rect, extending it to the end (right side) of the control, and then filling in that rect with the appropriate color at the appropriate painting stage.
However, I do not know if WinCE supports Custom Draw...
Peace!
-=- James.
|
|
|
|
|
Hello everyone,
I want to stop a CView-derived window from resizing below a certain size. I've tried overriding OnWindowPositionChanging() as follows:
void CPlaybackView::OnWindowPosChanging( WINDOWPOS *lpwndpos )
{
UINT cx, cy;
cx = lpwndpos->cx;
cy = lpwndpos->cy;
m_rcFrameHeader.SetRect(
CXMARGIN,
cy - CYMARGIN - CYFH,
cx - CXMARGIN,
cy - CYMARGIN );
m_rcScreen.SetRect(
CXMARGIN,
CYMARGIN,
cx - CXMARGIN,
m_rcFrameHeader.top - CYMARGIN );
if( m_rcScreen.Height() < 0 )
{
m_rcScreen.bottom = m_rcScreen.top;
lpwndpos->flags |= SWP_NOSIZE;
}
CView::OnWindowPosChanging( lpwndpos );
}
but the window is still resizing. The contents isn't redrawn, coz my OnSize isn't called, but the window still resizes.
Do I have to override WM_GETMINMAXINFO? From my reading of MSDN this won't even be called coz I overrode WM_WINDOWPOSITIONCHANGING.
Anyone got any ideas?
TIA,
Pete
|
|
|
|