|
I suppose there are two ways:
1. Add a member "m_db" to your dialog's class and set it when you construct the object, right before calling DoModal.
2. Use the global CWinApp to get the document object and then m_db from there. I don't recommed it, but the code would look something like this:
CDocTemplate* pDocTemplate = AfxGetApp()->GetNextDocTemplate(AfxGetApp()->GetFirstDocTemplatePosition());
CYourDocument* pDoc = (CYourDocument*)pDocTemplate->GetNextDoc(pDocTemplate->GetFirstDocPosition());
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hello,
I'm having the following problem. I've been developping with the Messenger Typelibrary in both VB and Delphi for quite a while now. As I wanted to switch to C++, I downloaded the headers and lib file that Microsoft gave free for download on their site. All seems to be more or less ok, I see all the classes, but NO EVENTS! None whatsoever. When I try to add a member function it says that the implementation is not found. I need the OnTextReceived event for instance, I can't find it anywhere. Not in the headers, not in the help that came with it either!
After a bit of searching on the MS Site I found a similar function DOES exist in the Exchange API, I don't see how those 2 are connected, if they even are...
Can anyone help me? Is it not possible in C to pull a trick like VB or Delphi? Just import the msmsgs.exe?
Thanks a lot,
- Fahr
|
|
|
|
|
Looking through the messenger sdk headers, there seems to be a lot of events although I can't see one for OnTextReceived.
Have you tried using #import on the Messenger Typelibrary and see if that generates the missing events. It is possible that the SDK uses an earlier/later version of the COM interfaces?
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
The main problem with that is that the actual typelibrary is in the msn executable... I have NO idea how to import it :S
Neither do I have any idea how to import type libs in C w/o header files in general :P
- Fahr
|
|
|
|
|
#import "C:\Program Files\Messenger\msmsgs.exe"
will generate you a header file for the typelib. I've checked with my version and it generates an event for OnTextReceived.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
possibly and extremely stupid newby question: WHERE do I type the #import so it generates a class/header/whatever ??
I never worked with typelibs in C w/o having pre-made headers :S
Thanks,
- Fahr
|
|
|
|
|
#include "stdafx.h"
#import "C:\Program Files\Messenger\msmsgs.exe"
int _tmain(int argc, _TCHAR* argv[])
{
Messenger::IMsgrObject2Ptr oMsgrObj = NULL;
Messenger::IMsgrUsersPtr oUsers = NULL;
Messenger::IMsgrUserPtr oUser = NULL;
oMsgrObj.CreateInstance("Messenger.MsgrObject");
oUsers = oMsgrObj->GetList(Messenger::MLIST_CONTACT);
return 0;
}
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
Thanks an amazing bunch!! It works!!
Will it compile the exe along so I only need a running instance, or will it need the exe to be always in the same dir?
- Fahr
|
|
|
|
|
It only uses the exe to generate the msmsgs.tlh, msmsgs.tli files. The exe is just acting as the type library. As long as MS Messenger is on the machine that you install on, then your app will just run.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
Also, I stumble upon the following error when I try to define the OnTextReceived function:
c:\program files\microsoft visual studio\myprojects\msntest\stdafx.cpp(23) : error C2084: function 'long __thiscall Messenger::DMsgrObjectEvents::OnTextReceived(struct Messenger::IMsgrIMSession *,struct Messenger::IMsgrUser *,class _bstr_t,class _bs
tr_t,short *)' already has a body
what am I supposed to do with that? I'm guessing it is redifined or something?? I don't get it...
Sorry if I sound too much like a noob, this is all just new to me :P
And on another note, can I make it like a class in my classview? It would be a lot easier I think...
Thanks,
- Fahr
|
|
|
|
|
Hi,
I wrote a class for an ownerdraw listbox (LBS_OWNERDRAWFIXED). When used as a child window, MeasureItem and DrawItem are correctly called.
When used as a popup, these methods are not called (neither OnMeasureItem and OnDrawItem in the owner window).
How to have an ownerdraw listbox used as a popup ??
Thanks
|
|
|
|
|
When i save my MDIDocument I want to speicify the Default File Extension for the Document. Where and how should i do it ?
|
|
|
|
|
I have this silly program I am doing for class. I want to add a vector to it but I get the below error.
I have added to my working program
#include <vector><br />
using namespace std;<br />
<br />
vector<CShape *> v;
and then get this error. With out the 3 lines my program works fine. I'm not even using the vector anyplace yet.
--------------------Configuration: CIS279_8 - Win32 Debug--------------------
Compiling resources...
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE/eh.h(32) : error RC2188: #error : "eh.h is only for C++!"
RC : fatal error RC1116 : RC terminating after preprocessor errors
Error executing rc.exe.
Creating browse info file...
CIS279_8.exe - 2 error(s), 0 warning(s)
Any Ideas?
Thanks,
Jeff Patterson
Programmers speak in Code.
www.anti-dmca.org
|
|
|
|
|
what is the name of the file to which you added the #include ?
is it foo.c or foo.cpp ?
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
|
something strange is going on here.
#include <vector>
<small>Jeff Patterson
Programmers speak in Code.
<a href="http://www.anti-dmca.org">http://www.anti-dmca.org</a>[<a target=_blank title='New Window' href="http://www.anti-dmca.org">^</a>]
</small>
|
|
|
|
|
you need to put source code inside <pre> tags (and put spaces around any angle brackets. otherwise, the CP boards eat them...
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
What is the extension of your source file? This error is similar to when you name a file .C and the C++ mode will be turned off. Be sure to name it C++ and check your project settings to be sure that C++ compilation is enabled.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
I was trying to include it in my created .h file.
Why must I include this in a cpp file and declare it in a .h file? It is working now but this seems nonstandard.
Am I missing something?
Thanks
Jeff Patterson
Programmers speak in Code.
http://www.anti-dmca.org[^]
|
|
|
|
|
Jeff Patterson wrote:
It is working now but this seems nonstandard.
Yes, it is nonstandard, but it's a very common feature of compilers. For easier use of old C code, they only enable C++ extensions in files with specific extensions, like cpp, cc, cxx, and so on.
You can always force C++ compilation, even without these extensions.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
Thanks.
Since you have grabbed my curiosity now
How do you force C++ compilation?
Jeff Patterson
Programmers speak in Code.
http://www.anti-dmca.org[^]
|
|
|
|
|
You can use one of the Tc, /Tp, /TC, /TP to specify source file type or, in VC.NET (I don't recall where it is in VC 6.0), open the project's Property Pages, "C/C++", "Advanced", "Compile As"
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
|
Jeff Patterson wrote:
using namespace std;
There really is no point in having namespaces if you're going to pull them into the global namespace holus bolus. You should instead have using statements like this
using std::vector;
Yes, all the books do it wrong, I don't know why.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
all the books do it wrong, I don't know why.
because it's not wrong.
if "using namespace x" was wrong, his holiness Bjarne wouldn't have included it.
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|