|
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
|
|
|
|
|
Try _directly_ changing the values of the lpwndpos cx and cy values to the minimum (or maximum) sizes when they arrive out of bounds.
|
|
|
|
|
No joy
Make no difference.
Any other suggestions anyone?
|
|
|
|
|
WM_GETMINMAXINFO is the message that you want to override. This message is called right before the WM_ENTERSIZEMOVE message is called, indicating that the program is entering the modal size move loop. Window caches the min max information, and will not let the mouse track to a size any larger or smaller than the dimensions that you specified. This is how you can make it so that the user does not drag the window really tiny, then when they let go it snaps back to a larger size.
WM_GETMINMAXINFO is also called right after WM_WINDOWPOSCHANGING in order to verify that the min and max requirements are met for the window based on what the application sets inside of the handler for WM_WINDOWPOSCHANGING.
I think that your best bet is to handle WM_GETMINMAXINFO for min and max requirements, and anything that needs to be dealt with in between that range should be dealt with in WM_WINDOWPOSCHANGED.
Good Luck
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
Well I tried what you suggested, but Windows doesn't seem to want to call my OnGetMinMaxInfo()
I've got a CVideoView, which is derived from CPlaybackView, which is derived from - you guessed it - CView.
here's what I've got in CVideoView:
...
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
...
DECLARE_MESSAGE_MAP()
...
ON_WM_SIZE()
ON_WM_GETMINMAXINFO()
...
ENDMESSAGEMAP()
...
...
void CVideoView::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
{
TRACE( "In CVideoView::OnGetMinMaxInfo()" );
lpMMI->ptMinTrackSize.x = CXVHC+CXMARGIN*2;
lpMMI->ptMinTrackSize.y = CYVHC+CXMARGIN*3;
}
That TRACE() never prints
As you might have noticed, I commented out my overridden WM_WINDOWPOSCHANGING, cos I thought that might be why OnGetMinMaxInfo() wasn't being called. But it makes no difference.
I'm wondering what brain-dead mistake I've made
|
|
|
|
|
Try placing the code in your frame class instead of your view class.
|
|
|
|
|
Great!
That's fixed it. It's working just right now.
Thanks a lot for all your help guys, today was an enjoyable day in school
Pete
|
|
|
|
|
I am sorry about misguiding you to use the view class, my mind was on one of the earlier questions that related to painting through the view class.
I am glad that you solved your problem though.
kilowatt
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
No problem, you set me on the right track, which was more important. Plus I learned some more about how windows deals with resizing, painting etc.
I appreciate it
|
|
|
|