|
Hi,
I've created an MFC project (a Single document application) in Visual C++ 6.0 and I didn't check the "ActiveX support" box. And by now, I have to insert an ActiveX control in my project !
Of Course, It doesn't work...
So, is there a way to add Active X support without restarting my project from scratch ?
Thanks...
|
|
|
|
|
Simplest way is to create two dummy projects, one just like your existing one, with no ActiveX support, and a second with the ActiveX support on.
Then just use WinDiff on the files (including the DSP) to see what changes you need to make.
Steve S
|
|
|
|
|
thanks, I won a lot of time...
For anyone who has the same problem, you just have to add AfxEnableControlContainer();
at the beginning of the InitInstance() function in your App class ! 
|
|
|
|
|
I am developing a small windows XP application that iterates over a set of files in a folder and extracts information from the files properties (right-click, select properties and then the summary tab) like title, summary etc.
The article Microsoft Knowledge Base Article - 186898 shows how to do this for compund docuemnts like Word documents and so on, using IPropertyStorage.
However, In my application, I access non-compound documents (jpeg-files mostly). They can also have attributes like the office files, but IPropertyStorage doesn't seem to be the right choice for finding the information. Does anyone have any excpreience with this?
Regards // Jonas Pettersson
|
|
|
|
|
Try to replace StgOpenStorage with StgOpenStorageEx and STGFMT_FILE parameter, as described in MSDN article "IPropertySetStorage-NTFS File System Implementation".
|
|
|
|
|
I created a COM dll and inside one of the methods I create a thread(A) that creates a modeless dialog and a second thread(B)(Not from Thread A) that does some background work. My question is whenever I try to cancel(DestroyWindow()) the dialog I get an assertion error, I assuming it has to do with the second thread(B) updating the dialog box controls. I tried killing the threads(A and B), but still the same problem. I'm using AfxBeginThread and AfxEndThread. Is this approach good as I described above, or is there a better way of doing this.
Thanks
|
|
|
|
|
Hi there !!
Have u used , GetExitCodeThread() for killing ur thread, try to kill that thread first which is updating the Dialogbox controls, can u tell me exactly what assertion are u getting !!
Regards
Abhishek Srivastava
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
Hi,
I am using the Microsoft Forms 2.0 CommandButton activeX control in my own active x control. In order to set the text, I need to use the AtlAxGetControl() function call, but I am not sure how to declare the interface pointer. How do I know what the interface is called, such as
CComPtr<icommandbutton (this="" isn't="" right)=""> pButtonCtrl;
AtlAxGetControl( ..., &pButtonCtrl);
Otherwise, is there a simplier way to set the button text? SetDlgItemText() doesn't work.
Cheers,
Joanne

|
|
|
|
|
I can host the Microsoft Forms2.0 control in a dialog and query it's ICommandButton interface and use it to set the Caption property.
//in stdafx.h
<br />
#import "FM20.dll" named_guids,rename("Picture","IPicture")<br />
using namespace MSForms;<br />
//OnInitDialog...
<br />
AtlAxWinInit();<br />
CAxWindow wnd;<br />
RECT rect = {10,10,100,50};<br />
wnd.Create(m_hWnd, rect, _T("Forms.CommandButton.1"), <br />
WS_CHILD|WS_VISIBLE|WS_TABSTOP, 0, IDC_CONTROL); <br />
<br />
CComPtr < ICommandButton > pDisp;<br />
wnd.QueryControl( IID_ICommandButton,(LPVOID*)&pDisp);<br />
ASSERT(pDisp);<br />
CComBSTR bstrCaption(_T("My Button"));<br />
pDisp->put_Caption(bstrCaption);<br />
amit
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - Writing Word addins
Office addin
|
|
|
|
|
Hi,
I've had to dabble in COM (C++) for the current application my company is developing. It's a big application, that has a lot of debug output, and I thought it would be nice for my fellow developers to be able to double click on file/line references in the debug output pane of the application, and be taken into visual studio, where the file would open at the appropriate line (much like double clicking on errors and warnings in visual studio itself).
ShellExecuteEx or DDE can be used to open the file, but the only way I could find to go to the line is to resort to COM: get an IApplication pointer, get the active document, get the text selection in the active document, then goto the line. This works fine, but whenever I get the IApplication pointer, using CoCreateInstance, a new visual studio fires up, even if there's one already available.
I have two questions:
1) Is there an easier way to do this?
2) If there isn't, how can I stop CoCreateInstance from creating new visual studios every time?
Many thanks in advance...
Andy.
|
|
|
|
|
How embarrassing, replying to my own posts. However, I have found a solution (probably wrong, but at least it works). I thought I'd post it here incase anyone else had similar novice difficulties.
The following code checks to see if there's an active visual studio running. If there isn't, then one is created using CoCreateInstance. Next, the specified file is opened, then the specified line is visited.
(note _HRESULT_SUCCESS is just a wee macro I use for testing HRESULT values. Also, you need to include atlbase.h, initguid.h,objmodel/appguid.h,objmodel/appauto.h,objmodel/textauto.h and objmodel/testguid.h).
Modification: Curses; had to remove <code>...</code> tags, because the template instanciations of CComPtr and CComQIPtr were not appearing
void _OpenFileAtLineInVS(const TCHAR* pFilename,const unsigned int Line)
{
CComPtr<IApplication> pApp = 0;
CComPtr<IUnknown> pUnkApp = 0;
if (_HRESULT_SUCCESS(GetActiveObject(CLSID_Application,0,&pUnkApp)))
{
_HRESULT_SUCCESS(pUnkApp->QueryInterface(IID_IApplication,(void**)&pApp));
}
if (pApp == 0)
{
_HRESULT_SUCCESS(CoCreateInstance(CLSID_Application,0,CLSCTX_SERVER,IID_IApplication,(void**)&pApp));
}
if (pApp != 0)
{
// Make sure visual studio is active and visible
pApp->put_Visible(VARIANT_TRUE);
pApp->put_Active(VARIANT_TRUE);
CComPtr<IDispatch> pDisp = NULL;
// Get the documents interface
pApp->get_Documents(&pDisp);
CComQIPtr<IDocuments, &IID_IDocuments> pDocs(pDisp);
pDisp = 0;
// Open the specified file
pDocs->Open(CComBSTR(pFilename),CComVariant("Auto"),CComVariant("False"),&pDisp);
// Get the active document (the newly opened file)
pDisp = 0;
pApp->get_ActiveDocument(&pDisp);
CComQIPtr<ITextDocument,&IID_ITextDocument> pActiveDoc(pDisp);
pDisp = 0;
pActiveDoc->get_Selection(&pDisp);
// Get the text selection object from the active document, and go to the appropriate line
CComQIPtr<ITextSelection,&IID_ITextSelection>(pDisp)->GoToLine(Line,CComVariant(dsMove));
}
}
|
|
|
|
|
Hi,
I'm witting an Outlook plugin in VC++, using ATL.
When a button in outlook is pressed, my plug-in will create a new mail, or reply to the selected one, or forward it. Now, the problem is that after generating this new window(for new mail, reply or fwd), when I close Outlook, another instance of Outlook remains somewhere running (I see it in Task Manager, and I have to close it form there). Any ideea what do wrong? Here is part of my code from the reply command:
for(int i=1; i<=lItemCount; i++)
{
CComPtr<idispatch> spDisp;
CComVariant vt(i); //get selected item number i
hr = spSelection->Item(vt, &spDisp);
if(FAILED(hr))
return;
CComQIPtr< Outlook::_MailItem > spMailItem(spDisp);
CComPtr<outlook::_mailitem> spMailItem2;
if(FAILED(hr))
return;
if(spMailItem!=NULL)
{
spMailItem->Reply(&spMailItem2);
BSTR subj;
spMailItem->get_Subject(&subj);
CString str = "Re:";
str += W2T(subj);
spMailItem2->put_Subject(T2W(str));
BSTR htmlBody;
spMailItem->get_HTMLBody(&htmlBody);
str = ReadHTMLIntoString((CString)W2T(bstrMSname)); //insert the Reply .html
str += "
Original text:
"; //something between our text and the original text
str += W2T(htmlBody);
htmlBody = T2W(str);
spMailItem2->put_HTMLBody(htmlBody);
spMailItem2->Display();
}
spMailItem2.Detach();
spMailItem.Detach();
spDisp.Detach();
}
I think something should be done with spMailItem2, but I just don't know what.
I would really appreciate any help.
Thanks,
Doru K
|
|
|
|
|
dorutzu wrote:
spMailItem2.Detach();
spMailItem.Detach();
spDisp.Detach();
Whoops!
I think you were trying to get the smart pointers to clean up, but they'll do that by themselves. The Detach method is a way to get the smart pointer to stop tracking the underlying pointer, but it does not call Release .
Either call Release , or don't do anything.
|
|
|
|
|
Thanks!
This was the problem indeed! I got, eventually, to the answer by my self, but thanks for your help anyway. Unfortunately, I haven't found too much info on the net on this issue, and I used Detach just for the sake of cleaning up
Thanks again,
Doru K
|
|
|
|
|
I'm creating a COM Dll which calls a modeless dialog box inside a thread. I notice it fails on the create function. Its seems it can't find the resource ID.
Sample code provided.
DWORD WINAPI CComDll::StartThread(PVOID param)
{
CDialog* dlg = new CDialog();
dlg->Create(IDD_DIALOG);
dlg->ShowWindow(SW_SHOW);
}
Thanks
|
|
|
|
|
CDialog is an MFC class. Is MFC support included in your .dll? It sounds like it is not. So when the Create method tries to locate IDD_DIALOG, it cannot use the MFC global AfxResourceHandle.
If you are building the COM .dll using the VS wizard and selecting ATL, be sure to check the Include MFC support option. If it is an ATL .dll and you do not want to recreate the project, look up Howto add MFC support to ATL in MSDN for instructions.
|
|
|
|
|
3142.1
Hi everybody!
I have a problem with COM technology. Here it is:
I have two applications (let's say application A & B, c++ executable applications), and I need to run some methods of B application from A application. This is what I was succesfull at.
Here is the real problem:
I need to create some objects (dynamically) in my A application, (I was trying to inherite them from IUnknown) , and send them to application B (probably as an IUnknown), so I can use them as normal objects of the B application.
Can anybody help me with this?
Here is what I did:
I created client (A) as an client, and an B app. as an server. I have created some methods in B to see if it works (it worked), then I have created an object (X) in A app (inherited from IUnknown), and method in B app, that has an parameter LPUNKNOWN. In A app. I run this function of B's app, and I put there this X object as an parameter FunctionName((LPUNKNOWN)X);
The B app has recieved this X pointer as an IUnknown, and here comes the problem: in B app, I tried to get different interface of B object by QueryInterface function , but it returned me NULL!!! That's the problem..
Does anyone have some experience with it?
Ceno
|
|
|
|
|
Hi,
i'm using Acrobat Distiller through OLE/COM Automation as suggested in the Acrobat Distiller API Reference Guide (tech. note #5158, version 5.0). It seems to work well on Windows 2000, but i'm having COM security issues (i think) on Windows XP.
Here is a simple test case:
[1] Run the DistillerCtrl sample application provided with the Adobe Acrobat SDK v.5.0 with a user of the Administrators group. It works.
[2] Run the DistillerCtrl sample application provided with the Adobe Acrobat SDK v.5.0 with another user not part of the Administrators group. It fails.
I keep having the 0x80080005 - Server execution failed error.
DCOM configuration is set to defaults for the AcroDistX object:
Authentification Level = Default
Launch and Access Permissions = Use Default
Identity = The launching user
The client and the server both run on the same machine running Windows XP (with service pack 1).
The test only fails on Windows XP, i have no problem running it on Windows 2000. What am i missing?
HooK
|
|
|
|
|
Are you using CoInitializeSecurity, and if so, how?
Steve S
|
|
|
|
|
No i'm not using CoInitializeSecurity.
HooK
|
|
|
|
|
Hi there,
I am implementing connection points and i would like to know one thing here that is it possible to do custom marshalling with connection points.
My outgoing interface is something like this,
interface _INBDatabaseHandlerEvents
{
[helpstring("method RecieveBackupInfo")] HRESULT RecieveBackupInfo([in] BackUpInfo* bakupinfo);
}
where backupinfo is my own defined structue using multiple data types and they may not be automation compliant.
i have manually edited the coclass to
[default, source] interface _INBDatabaseHandlerEvents;
dispinterface removed and my object derives from IUnknown now.
QUESTION:
At the client side what should i do include .tlb or .h and .c for interfaces uuid.
And if provide only typelib information would it work if i have registered the proxy stub as well.
And i am just using the typelib to help the coz of not using .c and .h files from server
QUESTION:
how can i include .c file in different cpp for using cocreateinstance. It is not possible but i need the uuids for instantiating the objects.
Should i use typelib for custom interfaces with custom defined parameters it would make a difference or not.
Thanks in advance.
I'm looking forward for an urgent reply.
|
|
|
|
|
Hi,
I am working on a utility which act as an IE extension. I want to add a new 'protocol' (default IE protocols: http:, ftp:, ms-its: ..., I need to impelement my own, e.g. makecall:, goto to IE, I rem that many years ago I browse MSDN, it may called "pluggable protocol xxx", but I can't find anything in MSDN anymore.
Can any one give me a tip? many thanks.
|
|
|
|
|
I think that you need to add something like this to registry:
<br />
HKEY_CLASSES_ROOT\makecall\@ = URL: makecall Protocol<br />
HKEY_CLASSES_ROOT\makecall\URL Protocol = ""<br />
HKEY_CLASSES_ROOT\makecall\DefaultIcon\@ = C:\YourIcon.ico<br />
HKEY_CLASSES_ROOT\makecall\shell\@ = open<br />
HKEY_CLASSES_ROOT\makecall\shell\open\command\@ = "C:\YourApp.exe" "%1"<br />
i'm only pointer to myself
|
|
|
|
|
I create one remote com object - 'execel.exe' to build
execel report. but I want to know the ProcessID of this remote object. Who can help me ?
best regards!
|
|
|
|
|
just add this method
GetServerId([out] DWORD* dwProcessId);
GetCurrentProcessId() look in msdn and there you are.
|
|
|
|
|