|
Please excuse if this has been asked before,
but i have a handler for when the user clicks on a menu item,
this is the code that i have:
void CTestApp::OnTestMenu()
{
CWnd* pWind;
pWind = theApp.GetMainWnd();
CClientDC dc(pWind);
dc.TextOut(200,200, "Hello World");
}
This works fine, but it doesn't repaint the screen if it gets covered.
I guess what my question is, do i need to create a Global Device Context that i write to from different parts of my app and then paint this to the screen in my OnDraw() ?
Thanks
|
|
|
|
|
In Windows you need to implement your drawing code in handler of WM_PAINT message. In MFC this will be OnDraw if you're CView-derived class or OnPaint otherwise.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
I have a DLL, that I called from a different proccess space ( I run it in an automated instance of word, and I get control to it from my application).
I pass an LPUNKNOWN pointer to pass one stream with one metafile, the problem comes when I try the DLL in a computer where I haven´t build the project with Visual Studio, then my dll crashes when passing that parameter.
How can I fix that ? ( is there some extra file or registry thing, instead of LPUNKNOWN maybe LPIDISPATCH ?, or merging proxy stub ? ( how to do this manually...) ?
Thanks, Bye !
Braulio
|
|
|
|
|
Braulio, explain better your problem ...
You are using two computers, eg. try to call the dll from another computer ?
You registered properly the dll ?
Merging the proxy/ stub normally isn't necessary if you are using type library ,marshaling, I presume you are, because you are using automation, and using automation requires automation compatible parameters , eg . passing IDispatch pointers to world ...
Joao Vaz
|
|
|
|
|
Hi Joao !, Nice to meet you again !
I´m still working on the Ms Word thing... ( I have my ATL ActiveX control in a DLL, then Ms Word automated, and my MFC application that controls that Ms Word app).
I've a method defined in an interface to pass the Metafile to the ActiveX, that method has as a parameter an LPUNKNOWN ( later I make a QI to IStream), should I pass IDisptach pointers instead of IUnknown ?.
The problem that I have is that the call to this method only works in the computers where I have compiled the DLL. If not, when I call the method it fails ( just crashes, or gives me a message saying that something is going wrong).
I register the DLL calling this "regsvr32 MyDll.dll", did I missed any parameter ?.
My idea was to generate the Proxy/Stub DLL ( merged in my DLL), to call the methods, is that a good idea ?
Thanks a lot Joao, Bye !
Braulio
|
|
|
|
|
Just one stupid question... I don´t need to copy or register the TLB of my DLL isn´t it ? ( is only to build the object that uses it isn´t it ?).
Where can I find a list of automation compatible parameters ?
Thanks, greetings
Braulio
|
|
|
|
|
The automation marshaler works with VARIANT compatible types ( VT_BSTR, VT_I4, etc). If you want to make cross-apartment calls in your app you can use the automation marshaler or generate and register a proxy/stub for your interfaces ( don't pass pointers to interfaces from one apt. to another, use CoMarshalInterface / CoUnmarshalInterface ).
Do you have any COM related messages when your app crashes, or just an access violation exception ?
|
|
|
|
|
Hi !
Well, what I did was to pass and IStream interface pointer to the ActiveX, I passed it as LPUNKNOWN pointer. Should I use CoMarshalInterface/Co... ( how can I use that ?).
The funny thing is that in the machine where I compile the source it works but in others machines not
About crash, in XP sometimes crashes sometimes gives a message saying that the font is too big ( the stream contains a metafile), in Me it says that there was inconsistence or the operation cannot be done ( something like that).
What I have is:
MyApp |---> Word Automated --> My DLL|
What can I do ? , Thanks a lot Bye !
Braulio
|
|
|
|
|
I don't think your problem is related to marshalling then. Did you reposition the current seek pointer in the stream ( IStream::Seek ) at the beginning of the stream ? Because if you write into the stream the current position will be updated and the next client will read from that position.
|
|
|
|
|
Here I show you what I do to write ( from one process), and to read ( from the DLL that is hosted on another process):
Write:
IStreamPtr spStream;
CreateStreamOnHGlobal(hGlob, TRUE, &spStream);
if(spStream) {
if((SUCCEEDED(p->Save(spStream, FALSE))) && (pBsMetaCtrl != NULL)) {
IUnknownPtr pUnk = spStream;
VARIANT VUnk;
VUnk.vt = VT_UNKNOWN;
VUnk.punkVal = pUnk;
pBsMetaCtrl->SetMetafile(VUnk);
Read:
(...)
BOOL SetMeta(IStream *pStream, IPicture **Pict)
{
BOOL bResult = FALSE;
CComPtr<IPictureDisp> pic;
LARGE_INTEGER l;
l.QuadPart =0;
pStream->Seek(l, STREAM_SEEK_SET, NULL);
OleLoadPicture(pStream, l.LowPart, FALSE, IID_IPictureDisp, (void **) &pic);
if(pic) {
pic->QueryInterface(IID_IPicture, (void **) Pict);
if(Pict) {
bResult = TRUE;
}
}
return bResult;
}
I don´t know, if I have to do something special to share that global memory ?, can you help me a little bit more ?, Thanks a lot
Braulio
|
|
|
|
|
The code that I use to write ( from one process outside the DLL), and to read ( from my dll that is hosted on Ms Word), is:
write:
IStreamPtr spStream;
CreateStreamOnHGlobal(hGlob, TRUE, &spStream);
if(spStream) {
if((SUCCEEDED(p->Save(spStream, FALSE))) && (pBsMetaCtrl != NULL)) {
IUnknownPtr pUnk = spStream;
VARIANT VUnk;
VUnk.vt = VT_UNKNOWN;
VUnk.punkVal = pUnk;
pBsMetaCtrl->SetMetafile(VUnk);
read:
(...)
BOOL SetMeta(IStream *pStream, IPicture **Pict)
{
BOOL bResult = FALSE;
CComPtr<IPictureDisp> pic;
LARGE_INTEGER l;
l.QuadPart =0;
pStream->Seek(l, STREAM_SEEK_SET, NULL);
OleLoadPicture(pStream, l.LowPart, FALSE, IID_IPictureDisp, (void **) &pic);
if(pic) {
pic->QueryInterface(IID_IPicture, (void **) Pict);
if(Pict) {
bResult = TRUE;
}
}
return bResult;
}
I don´t know what I'm doing wrong, seems that I'm not getting something ok from the global memory, can you help a little bit more ? Thanks a lot,
Braulio
|
|
|
|
|
Braulio, well for merging the proxy/stub, the easy way , is
This is for VC6++
- Create a ATl Dll Server , check <<allow merging="" of="" proxy="" stub="" code="">>
This will create a file named dlldatax.c that includes code generated by MIDL compiler , two file sin particular are generated: dlldata.c, which declares the DLL entry points for the stub and the file suffixed with _p.c which implements the proxy and stub object.
- Go to Project Settings select the dlldatax.c file and from the General tab and uncheck Exclude file from build.
-From the C/C++ tab for this file select the Precompiled Headers category and make sure that this file does not use precompiled headers.
-Define the symbol _MERGE_PROXYSTUB for the entire project.
If you have a custom or dual interface then this will bloat your server with the type library marshaler that isn't necessary, you already merged the proxy/stub so here are the steps to take off the type library marshaler, letting alone the universal automation marshaler:
Use the Resource Includes item of the View menu and remove the type library resource from the Compile-time directives box.
Change the calls to _Module.RegisterServer() and _Module.UnregisterServer() to have a parameter of FALSE. You will find these calls in DllRegisterServer() and DllUnregisterServer() in the main cpp file of your project (the one that has the same name as your project).
Edit the RGS file for every object implemented in the server and remove the reference to the type library. For each object it adds, Object Wizard will add an RGS with the short name you specified for the object, within this there will be a script to register the object, and there will be a line that starts with 'TypeLib'; remove this line.
This is all
Perhaps after this, thsi will not crash ?
As solon asked, the error is a exception error or a error message ?
Joao Vaz
|
|
|
|
|
Hi Joao !
Thanks for the tip, I will try that.
About error or exception, is a little bit strange sometimes gives an error, sometimes an exception...
One of the problems, is that I´m givin the IStream as a LPUNKNOWN pointer ( I don´t know if I should wrap it in a IDispatch pointer..., or maybe I have to use the proxy stub thing).
Thanks a lo Joao... ( je je If I fix this I will write one article in codeproject... XD ).
Greetings
Braulio
|
|
|
|
|
Any tut's or examples on the basics on Drag and Drop???
I've tried but had no success dragging files off the desktop into a CListView so i'd like to read a basics tutorial if possible...
Know of any...?
Thanx in advance!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
For dragging files, you don't need COleDropTarget. Use CWnd::DragAcceptFiles and WM_DROPFILES.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanx, I'll try that and hope for the best.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Ahhh! sweet exactly what I wanted
Thanx Tomasz.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
I just read your first tutorial on Shell extensions...awesome I really appreciate you writting those.
I'll definetly have a read of the others too.
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
how do you put a code like mailto: so that when a user clicked the email address it will open up the outlook express so that the user can email someone... i am trying to put my email address in my about dialog box for my program but i cant seem to figure out how to put mailto. is there any way to do that???
Thank you very much,
John
|
|
|
|
|
Use ShellExecute - Nish has an article on it around here somewhere.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
thanks...
Thank you very much,
John
|
|
|
|
|
For ready-to-use class, check Dec'97 issue of MSJ, C++ QA column by Paul DiLascia. The article may be included in MSDN on your harddisk. If it's not there, go to msdn.microsoft.com for online version.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
I have an already created project and I want to merge the proxy/stub code into my DLL, ... how can I do that now ? ( When I created the project I didn´t think that I needed that, ... aaahh stupid check box... stupid me...).
Do I have to compile at least one time with NMake in order to make this proxy stub thing work ?
Thanks in advance, Bye !
Braulio
|
|
|
|
|
I'm developing a Visual .Net application that uses the CMultiPageDHtmlDialog class. This clas uses html pages to display information to the user. The problem is the fact that i have ActiveX int Html pages and when a new page is load, a MessageBox appears informing the user that an ActiveX can be unsafe ... . How can I avoid this messages? I try to change the configurarion of mi Internet Explorer but it dont works.
Thank You.
Jose Vicente
|
|
|
|
|