|
Hi,
I'm using Ms Word automated from my application, and in that instance of Ms Word, I insert from my app and ActiveX control ( that I have developed with ATL).
I my application I get the dispatch of my ActiveX control....
It's possible to connect to my sink interface in the ActiveX control ? ( I mean, receive in my app, outgoing events from the ActiveX), or is it impossible ?, I have read that the implementation of the connection points in ATL is not prepared for that? Is that true ?...
A code snippet about what I want to do ( quite standard thing...):
COleVariant vClassType = "MySinkSvr.PruCon";
Word::InlineShapePtr pShp = m_pWord->GetSelection()->InlineShapes->AddOLEControl(vClassType);
Word::OLEFormatPtr pFmt = pShp->OLEFormat;
TRY {
LPDISPATCH pDispatch = pFmt->Object;
m_pCon = pFmt->Object;
m_pCliSink = new CCliSink;
LPUNKNOWN pUnkSink = m_pCliSink->GetIDispatch(FALSE);
if(AfxConnectionAdvise(pDispatch, DIID__IPruConEvents, pUnkSink,FALSE, &_dwCookie)) {
TRACE("Success !");
} else {
TRACE("Failure !");
}
}
How can I do it for different process space ?, Thanks in advance, Greetings
Braulio
|
|
|
|
|
Hi, Braulio, have you seen this before ?
Office automation
HTH
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
Hi Joao !
Yes, I've been diving on that articles, a lot of times, but it seems that what I want to do is a little bit special .
Well, for me it´s normal. Just have my report ActiveX control, in Ms Word Pasted ( then I can control the look and feel, in my way, and update sinchronize...).
For sinchronizing, the problem is that the ActiveX it's inside Word, and I can not hook up the connection point to my EXE ( it seems that the proxy thing doesn´t work well, there is no marshaling or no conversion at all of the address... ).
And the most funny thing come with this, take a look at "Q150431", to print my ActiveX in Ms Word, it uses the oold windows 3.1 metafile format, ... that´s another funny thing... I have enhanced metafile, and then what I got from the printer is crap ... sh*tty microsoft...
Greetings
Braulio
|
|
|
|
|
Braulio Díez wrote:
I have enhanced metafile, and then what I got from the printer is crap
Hum, do a search on Microsoft ATL archives for EMF or WMF (put it on the "for" textbox) , there is some discussions on office not suporting EMF and converting your printer output in the right format
look also on ATL Yahoo group and WTL yahoo group
these are the best places for look on COM/ATL information (lots of ATL experts in these 2 groups)
HTH
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
I know that it went ok if it returns NOERROR but it returns -2147023673 how do find out what this means? In the MSDN library it says it returns an "OLE defined error" if an error happens, how do i get that error description?
Thanks
|
|
|
|
|
Use error lookup
Tools->Error Lookup
Or in the debuggers watch window type [var with HRESULT],hr
/Magnus
|
|
|
|
|
Thanks for the help, but what is it exactly i should type in the watch window?
Thanks
|
|
|
|
|
HRESULT hRes = SomeFunc();
then you would type
"hRes,hr" in the watch window
/Magnus
|
|
|
|
|
How to convert HDC to Color Bitmap?
I used from "CreateCompatibleBitmap" but output bitmap was monochromatic.
|
|
|
|
|
The "hDC" must have the image already? you can use the provide function to do that!
HBITMAP GetBitmapFromDC(HDC hDC, int x, int y, int nWidth, int nHeight, bool bCopyToClipboard )
{
HDC hMemDC = ::CreateCompatibleDC( hDC );
HBITMAP hImage = ::CreateCompatibleBitmap( hDC, nWidth, nHeight );
HBITMAP hOldBitmap = (HBITMAP) ::SelectObject( hMemDC, hImage );
::BitBlt(hMemDC, 0, 0, nWidth, nHeight, hDC, x, y, SRCCOPY);
if (bCopyToClipboard)
{
::OpenClipboard( AfxGetMainWnd() );
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, hImage);
::CloseClipboard();
}
::SelectObject( hOldBitmap);
::DeleteDC( hMemDC );
return hImage;
}
Good luck!
"One good thing about getting older, you don't lose the ages you've been!"
|
|
|
|
|
I have a bmp handle that gave it from open dialog.
How can I resize it and show in listview by normal size.
|
|
|
|
|
Did you try CreateCompatibleBitmap ?
Just a thought
|
|
|
|
|
I'm including MSHTML into my class definition like this :
#include <comdef.h>
#include <mshtml.h>
#pragma warning(disable : 4192)
#pragma warning(disable : 4049)
#pragma warning(disable : 4146)
#import <mshtml.tlb> no_auto_exclude
The problem is, that when i modify my .cpp file, compiler throws these errors :
.....manualdlg.cpp(18) : fatal error C1083: Cannot open compiler generated file: '.........\debug\mshtml.tlh': Permission denied
Error executing cl.exe.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Debug\ManualDlg.sbr': No such file or directory
But when i try to run compile again, it will finish without any errors, until i modify my .cpp again. So i always have to compile two times. Does anybody have some idea how to solve this, please ? (i'm using VC++ 6.0 SP2).
Thanks
|
|
|
|
|
It so happens that VC++ generates mshtml.tlh everytime you type a character is .cpp file. i don't know why but it happens like that. So turn off intellisense, this would fix the problem.
|
|
|
|
|
I turned off all checkboxes in Tools->Options->Editor in 'statement completion options' area, but it has no effect
|
|
|
|
|
I wrote the following functions to draw rotated (0, 90, 180 and 270 degrees) WMF. It almost works, the rotation itself seems to be correct, but the translation is not. I get WMF which is properly rotated, but it is placed in the wrong place.
Note, this function must work under NT 4.0/2000/XP.
What is the reason of this problem?
long G_lHeightWmf = 0, G_lWidthWmf = 0;
static int CALLBACK WMFEnumCallback(HDC hdc,HANDLETABLE *lpHTable,METARECORD *pmfr, int nObj,LPARAM lparam)
{
long width = 0,height = 0;
hdc;lpHTable;nObj;lparam;
if(pmfr->rdFunction==META_SETWINDOWEXT)
{
width=abs((SHORT)pmfr->rdParm[1]);
if(width>G_lWidthWmf)
G_lWidthWmf=width;
height=abs((SHORT)pmfr->rdParm[0]);
if(height>G_lHeightWmf)
G_lHeightWmf=height;
}
return TRUE;
}
void GetSizeWMF(HDC A_hDC,HMETAFILE A_hMetaFile,long *A_pWidth,long *A_pHeight)
{
if(A_hMetaFile!=NULL)
{
G_lWidthWmf=0;
G_lHeightWmf=0;
EnumMetaFile(A_hDC,A_hMetaFile,WMFEnumCallback,0); // <--to calcule size wmf
*A_pWidth=G_lWidthWmf;
*A_pHeight=G_lHeightWmf;
}
}
void DrawWMF(HDC A_hDC,RECT *A_pRect,HMETAFILE A_Hmf, bool A_bDrawRotated/* = false*/)
{
POINT ptRect[2], ptSize[2] = {0};
SIZE sizeViewNew, sizeViewNewLP;
int nSavedDC;
BOOL bOK = TRUE;
XFORM XForm, XFormSaved;
int nGraphMode = 0;
float fPixelXPermm(0.f), fPixelYPermm(0.f);
float fScaleXY(1.f), fScaleYX(1.f);
CRect rcNormal(A_pRect->left, A_pRect->top, A_pRect->right, A_pRect->bottom);
long dx = 0, dy = 0;
rcNormal.NormalizeRect();
if(A_pRect != NULL && A_Hmf != NULL)
{
rcNormal.SetRect(A_pRect->left, A_pRect->top, A_pRect->right, A_pRect->bottom);
rcNormal.NormalizeRect();
if(GetDeviceCaps(A_hDC,TECHNOLOGY)!=DT_METAFILE)
{
fPixelXPermm = GetDeviceCaps(A_hDC,LOGPIXELSX)/MMPERINCH;
fPixelYPermm = GetDeviceCaps(A_hDC,LOGPIXELSY)/MMPERINCH;
}
else
{
HDC hScreenDC = GetDC(NULL);
fPixelXPermm = GetDeviceCaps(hScreenDC,LOGPIXELSX)/MMPERINCH;
fPixelYPermm = GetDeviceCaps(hScreenDC,LOGPIXELSY)/MMPERINCH;
ReleaseDC(NULL, hScreenDC);
}
ptRect[0].x = rcNormal.left;
ptRect[0].y = rcNormal.top;
ptRect[1].x = rcNormal.right;
ptRect[1].y = rcNormal.bottom;
bOK = LPtoDP(A_hDC, ptRect, 2);
sizeViewNew.cx = abs(ptRect[1].x - ptRect[0].x);
sizeViewNew.cy = abs(ptRect[1].y - ptRect[0].y);
ptSize[1].x = sizeViewNew.cx;
DPtoLP(A_hDC, ptSize, 2);
sizeViewNewLP.cx = abs(ptSize[1].x-ptSize[0].x);
ptSize[0].x = 0;
ptSize[0].y = 0;
ptSize[1].x = 0;
ptSize[1].y = sizeViewNew.cy;
DPtoLP(A_hDC, ptSize, 2);
sizeViewNewLP.cy = abs(ptSize[1].y-ptSize[0].y);
if(bOK && sizeViewNew.cx > 0 && sizeViewNew.cy > 0)
{
fScaleXY = float(sizeViewNew.cx)/sizeViewNew.cy;
fScaleYX = float(sizeViewNew.cy)/sizeViewNew.cx;
nSavedDC = SaveDC(A_hDC);
SetMapMode(A_hDC, MM_ANISOTROPIC);
SetViewportOrgEx(A_hDC, ptRect[0].x, ptRect[0].y, NULL);
SetViewportExtEx(A_hDC, sizeViewNew.cx, sizeViewNew.cy, NULL);
GetSizeWMF(A_hDC, A_Hmf, &dx, &dy);
float sYX = (float)dy/(float)dx;
float sXY = (float)dx/(float)dy;
if(A_bDrawRotated)
{
GetWorldTransform(A_hDC, &XFormSaved);
nGraphMode = GetGraphicsMode(A_hDC);
SetGraphicsMode(A_hDC, GM_ADVANCED);
switch(TGraphicFilesSettings::GetCurrentRotationAngle())
{
case 270:
{
SetViewportOrgEx(A_hDC, ptRect[1].x, ptRect[0].y, NULL);
XForm.eM11 = 0;
XForm.eM12 = sYX;
XForm.eM21 = -sXY;
XForm.eM22 = 0;
XForm.eDx = 0;
XForm.eDy = 0;
break;
}
case 180:
{
SetViewportOrgEx(A_hDC, ptRect[1].x, ptRect[1].y, NULL);
XForm.eM11 = - 1;
XForm.eM12 = 0;
XForm.eM21 = 0;
XForm.eM22 = - 1;
XForm.eDx = 0;
XForm.eDy = 0;
}
break;
case 90:
{
SetViewportOrgEx(A_hDC, ptRect[0].x, ptRect[1].y, NULL);
XForm.eM11 = 0;
XForm.eM12 = -sYX;
XForm.eM21 = sXY;
XForm.eM22 = 0;
XForm.eDx = 0;
XForm.eDy = 0;
}
break;
}
ModifyWorldTransform(A_hDC, NULL, MWT_IDENTITY);
SetWorldTransform(A_hDC, &XForm);
}
PlayMetaFile(A_hDC, A_Hmf);
RestoreDC(A_hDC, nSavedDC);
if(A_bDrawRotated)
{
SetWorldTransform(A_hDC, &XFormSaved);
ModifyWorldTransform(A_hDC, NULL, MWT_IDENTITY);
SetGraphicsMode(A_hDC, nGraphMode);
}
}
}
}
|
|
|
|
|
I have a class call CFileDog, it is derivered from CNALABase which uses a template member to store data to a file.
But whenever i run the program it crashes, i worked out that it wirks when CFileDog is used as a global, but inside a class or function it crashes,
Con anyone help.
Thanks
|
|
|
|
|
Without more info, it is hard to say what your problem is. A little code'd help a lot (definitions of the classes involved, crashing code, tc.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is the class going out of scope whilst you are still trying to call its functions or access its data.
Michael
|
|
|
|
|
hi all,
i want to clarify my mind that the memory addressing for diff. process and thread.
as i know the pointer in diff. process is not the same. each process has its own local memory addressing. so, it need shared memory to communicate.
how about diff. thread in same process? do they share the same local memory address?
i feel it is true as i can access static array inside a thread. but, all thread can only access static memory of a object, why?
pls try to keep me some idea!
thanks,
chaze
|
|
|
|
|
zecodela wrote:
how about diff. thread in same process? do they share the same local memory address?
Yes, all threads in a process have access to the data in the process space.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
You are getting the picture.
Processes have differnet address space, meaning a pointer cannot go out current process space. Even if you obtain an address of an object from a diffrent process, trying to access it will give you an access violation.
Threads share the same address space, but have different "stack space". This means that a global object can be accessed/modified by two threads at the same time so you must protect it with semaphores, critical sections etc. However if two threads are executing the same function at the same time the local variables declared in that function will be "different".
Best regards,
Alexandru Savescu
|
|
|
|
|
hello 2 of you!!!
i want to learn more.
what is the meaning of 'stack space'? what will it affect?
and, how about 'static'? why all thread function can only access static member of its own class? (but, if i used PostMessage() posting a pointer of a local variable inside the thread function, outside can still access these local variable)
what is the use of 'static' in this case?
|
|
|
|
|
thanks thanks...!!!
chaze
|
|
|
|
|
zecodela wrote:
what is the meaning of 'stack space'? what will it affect?
Suppose you have a function like this
int f (int y)
{
int x = y;
return x;
}
And then you create two threads that call function f at the same time but with different values: (i.e the first one calls f(1) and the second calls f (2)). In this case the local x will have different values accross the different threads. This is what I meant with 'stack space'.
zecodela wrote:
why all thread function can only access static member of its own class?
I am not sure what you mean. Do you refere to thread created by AfxBeginThread or with threads derived from CWinThread?
Also you can use PostMessage to send pointers to different objects across threds.
Best regards,
Alexandru Savescu
|
|
|
|
|