|
Hi stuart,
I have one more issue.
My application works fine for Office 2007.
For office 2003, AfterCalculate is not triggering.
Googled, in msdn got the clue that it is new in 2007 and its not available in 2003.
If you have any idea, please let me know.
Thanks in advance.
Regards,
gtag
|
|
|
|
|
Hi All,
I have a little tricky question for you all. Maybe (I hope so) someone can help me with my problem.
I work in Visual Studio 2005 with an C++ project. This project does not support ATL + MFC and it should not be changed, if it’s possible. Now I should call an function / get an information out of an COM (.exe) server that is still running.
Below you can see the code that was created by the MIDL Compiler / by the OLE/COM Object Viewer from my test_programm.exe(COM server).
In the code of the Test.idl file you can see the following:
dispinterface ICWOLEEvents {
properties:
methods:
[id(0x00000001)]
void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept);
[id(0x00000002)]
void OnShowMessageDlg(
[in] IMsgDlg* pIMsg,
[out, retval] VARIANT_BOOL* Result);
};
The problem now I have is that I must call / work with the OnConfigurationApply and the OnShowMessageDlg functions in my C++ project. I’ve implemented the three (Test_h.h / Test_i.c / Test.idl) files in my project and I could recompile it without any error messages.
Now my questions are:
- How can I work with these two functions(OnConfigurationApply and the OnShowMessageDlg) in my C++ project?
- Is there anywhere an simple/complete c++ example project?
- Can someone explain me how I must start to work / get some information with these functions?
I’ve posted a few weeks a similar question. But now after my holiday I will post this question a little bit more detailed again.
Let me know if you need any more information about these files.
MANY MANY thanks for any hints.
Juergen
Test_h.h
.
.
.
MIDL_INTERFACE("6775FB91-B5BE-11D6-A996-0050BA24C7B9")
ICWOLEEvents : public IDispatch
{
};
.
.
.
Test_i.c
//Created with the MIDL Compiler
.
.
.
MIDL_DEFINE_GUID(IID, IID_ICWOLE2,0xF560F761,0x2948,0x11D7,0xA9,0xBF,0x00,0x50,0xBA,0x24,0xC7,0xB9);
MIDL_DEFINE_GUID(CLSID, CLSID_CWOLEv2,0xF560F763,0x2948,0x11D7,0xA9,0xBF,0x00,0x50,0xBA,0x24,0xC7,0xB9);
.
.
.
Test.idl
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: test_programm.exe
[
uuid(90B4344B-90CD-4527-BC00-4F4D45C793D6),
version(2.13),
helpstring("CW CWOLE")
]
library CW_CWOLE
{
importlib("stdole2.tlb");
interface ICWOLE2;
dispinterface ICWOLEEvents;
.
.
.
.
.
[
uuid(6775FB91-B5BE-11D6-A996-0050BA24C7B9),
version(1.1),
helpstring("Event dispatch interface for CW CWOLE")
]
dispinterface ICWOLEEvents {
properties:
methods:
[id(0x00000001)]
void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept);
[id(0x00000002)]
void OnShowMessageDlg(
[in] IMsgDlg* pIMsg,
[out, retval] VARIANT_BOOL* Result);
};
typedef [uuid(5CBBA151-1C47-4D6C-B14C-C527E333F812), version(1.2)]
enum {
ECS_DEFAULT = 0,
ECS_FRONT = 1,
ECS_LEFT = 2,
ECS_RIGHT = 3,
ECS_LEFTUP = 4,
ECS_RIGHTUP = 5,
ECS_TOP = 6,
ECS_BACK = 7,
ECS_BACKLEFTUP = 8,
ECS_BACKRIGHTUP = 9,
ECS_BOTTOM = 10
} ECamSetup;
typedef [uuid(9545E3CA-6401-4418-A040-DA3A89E2C792), version(1.3)]
enum {
EPM_PERSP = 0,
EPM_ORTHO = 1,
EPM_2D = 2
} EProjectionMode;
[
uuid(F560F763-2948-11D7-A9BF-0050BA24C7B9),
version(2.13),
helpstring("CWOLE2")
]
coclass CWOLEv2 {
[default] interface ICWOLE2;
[default, source] dispinterface ICWOLEEvents;
};
|
|
|
|
|
Is nobody out there who can help me? A link to a complete tutorial or anything else?
|
|
|
|
|
To implement a connection point handler (for that is what you need to do), you need to implement a COM object that can receive those events. This CodeProject article[^] seems to explain it quite nicely without using ATL or MFC.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi - thanks in advance for any enlightenment you can provide!!
I have a basic C# app running on XP SP2, using the Media Player 11 SDK download. Code looks like the following...
- The PROBLEM is that this runs OK for a WMA audio file, but throws for a WMV file on the line
drm.GetDRMProperty( strWMDRM_ActionAllowed_Playback,... with HRESULT 0xC00D002B, which is NS_E_INVALID_REQUEST
- so the QUESTIONs:
1) The IsDRM attribute that I can query on the WMA, which I found in the SDK drmexternals.h, Why is this not anywhere
in the SDK sample code, or elsewhere in the SDK includes? It is not documented in Microsoft's media attributes lists either.
2) Where can I get better info regarding audio vs video file attribute and DRM querying in C++ or C#?
3) How can I query WMV for playability and protection, as I have working for WMA?
code....
<pre>
// File attributes to be queried
public string strATTR_IsProtected = "Is_Protected";
// DRM properties to be queried
// This works for wma, but not wmv?? Do not see this in the DRM attribute list in Help.
public string strWMDRM_IsDRM = "IsDRM";
public string strWMDRM_ActionAllowed_Playback = "ActionAllowed.Play";
public string strWMDRM_DRMHeader_LicenseAcqURL = "DRMHeader.LAINFO";
private void OnPickAudioFileToPlay(object sender, EventArgs e)
{
OpenFileDialog openFileDlg = new OpenFileDialog();
openFileDlg.InitialDirectory = "c:\\";
openFileDlg.Filter = "WMA files (*.wma)|*.wma|MP3 files (*.mp3)|*.mp3|All files (*.*)|*.*";
openFileDlg.FilterIndex = 0;
openFileDlg.RestoreDirectory = true;
checkBoxFileProtected.Checked = false;
DialogResult dr = openFileDlg.ShowDialog();
if (DialogResult.OK == dr)
{
string file = openFileDlg.FileName;
// Get properties
// from wmsdkidl.h
// static const WCHAR g_wszWMProtected[] =L"Is_Protected";
IWMMetadataEditor editor;
IWMHeaderInfo3 hi3;
IWMDRMEditor drm;
bool bLocked = false;
uint iRes;
try
{
iRes = WMFSDKFunctions.WMCreateEditor(out editor);
bool bProtected = false;
string strDistributedBy = null;
editor.Open(file);
hi3 = (IWMHeaderInfo3)editor;
ushort wAttribValueLen = 4;
byte[] pbAttribValue = new Byte[wAttribValueLen];
WMT_ATTR_DATATYPE wAttribType;
ushort pwStreamNum = 0;
iRes = hi3.GetAttributeByName(
ref pwStreamNum,
strATTR_IsProtected,
out wAttribType,
pbAttribValue,
ref wAttribValueLen);
bProtected = BitConverter.ToBoolean(pbAttribValue, 0);
drm = (IWMDRMEditor)editor;
iRes = drm.GetDRMProperty(
strWMDRM_ActionAllowed_Playback,
out wAttribType,
pbAttribValue,
ref wAttribValueLen);
bLocked = (!BitConverter.ToBoolean(pbAttribValue, 0));
checkBoxFileProtected.Checked = bProtected;
checkBoxFileLocked.Checked = bLocked;
if (bLocked)
{
pbAttribValue = null;
iRes = drm.GetDRMProperty(
strWMDRM_DRMHeader_LicenseAcqURL,
out wAttribType,
pbAttribValue,
ref wAttribValueLen);
pbAttribValue = new byte[wAttribValueLen];
iRes = drm.GetDRMProperty(
strWMDRM_DRMHeader_LicenseAcqURL,
out wAttribType,
pbAttribValue,
ref wAttribValueLen);
if (2 < wAttribValueLen)
{
if ((0xFE == Convert.ToInt16(pbAttribValue[0])) &&
(0xFF == Convert.ToInt16(pbAttribValue[1])))
{
// UTF-16LE BOM+
if (4 <= wAttribValueLen)
{
for (int i = 0; i < pbAttribValue.Length - 2; i += 2)
{
strDistributedBy += Convert.ToString(BitConverter.ToChar(pbAttribValue, i));
}
}
}
else if ((0xFF == Convert.ToInt16(pbAttribValue[0])) &&
(0xFE == Convert.ToInt16(pbAttribValue[1])))
{
// UTF-16BE BOM+
if (4 <= wAttribValueLen)
{
for (int i = 0; i < pbAttribValue.Length - 2; i += 2)
{
strDistributedBy += Convert.ToString(BitConverter.ToChar(pbAttribValue, i));
}
}
}
else
{
for (int i = 0; i < pbAttribValue.Length - 2; i += 2)
{
strDistributedBy += Convert.ToString(BitConverter.ToChar(pbAttribValue, i));
}
}
}
}
textBoxDistributedBy.Text = strDistributedBy;
}
catch( System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine( ex.Message );
return;
}
// Play file...
if (! bLocked)
{
textPlayAudioFile.Text = file;
axWindowsMediaPlayer1.URL = file;
}
}
} // END pick file to play
<\pre>
|
|
|
|
|
Hi,
I am trying to retrieve a shortcut's arguments but when I do so, I get some strange random/chinese symbols.
I've checked multiple times the code and I can't see any reason why this is happening.
I also use the IShellLinkW GetPath, but I have no problem with it.
here is the code I have :
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WIN32_FIND_DATAW
{
public int dwFileAttributes;
public FILETIME ftCreationTime;
public FILETIME ftLastAccessTime;
public FILETIME ftLastWriteTime;
public int nFileSizeHigh;
public int nFileSizeLow;
public int dwReserved0;
public int dwReserved1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string cFileName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
public string cAlternateFileName;
}
[ComImportAttribute()]
[GuidAttribute("000214F9-0000-0000-C000-000000000046")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IShellLinkW
{
void GetPath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile,
int cchMaxPath,
out WIN32_FIND_DATAW pfd,
uint fFlags);
void GetArguments([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs,
int cchMaxPath);
}
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("0000010B-0000-0000- C000-000000000046")]
public interface IPersistFile
{
[PreserveSig]
void IsDirty();
void GetClassID(out Guid pClassID);
void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode);
}
[ComImport(), Guid("00021401-0000-0000-C000-000000000046")]
public class ShellLink
{
}
public class ShortcutTargetInfo
{
internal static string getArguments(string shortcutPath)
{
IShellLinkW linkW = (IShellLinkW)new ShellLink();
((IPersistFile)linkW).Load(shortcutPath, 0);
StringBuilder sb = new StringBuilder(260);
linkW.GetArguments(sb, sb.MaxCapacity);
Marshal.ReleaseComObject(linkW);
linkW = null;
return sb.ToString();
}
}
can anyone help me find the cause of this strange behavior.
|
|
|
|
|
I have an interface, I1 declared in library A, I use I1 in library B by writing code like
///////////////// begin /////////////////////
import "A.idl"
[
object,
uuid(...),
......
]
interface I2 : IDispatch{
[propget, id(1), helpstring("...")] HRESULT I1([out, retval] I1** prop);
};
///////////////// end ///////////////////
Both project A and project B built all right.
Now I import A.tlb and B.tlb in project C, and write following code
///////////////// begin /////////////////////
CComPtr < I1> spI1;
///////////////// end ///////////////////
compil failed with message error C2872 : "I1" : ambiguous symbol . While what I hope is only one I1, but now there are two.
How to resolve this problem?
|
|
|
|
|
Since you have import A.idl in B.idl, it would be enough to import only B.tlb.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Is there any other way to use I1 in B.idl except import?
What I really wonder is how to build a software structure like MS Office. In Office, the _CommandBars is in mso.dll, WinWord.Application is in WinWord.EXE, when I import MSWORD.OLB I can find there is code like "virtual HRESULT __stdcall get_CommandBars (
/*[out,retval]*/ struct Office::_CommandBars * * prop ) = 0;" in msword.tlh.
How it happens?!! In my projects, I import B.tlb, there is only "virtual HRESULT __stdcall get_I1 (
/*[out,retval]*/ struct I1 * * prop ) = 0;", while I am looking for "virtual HRESULT __stdcall get_I1 (
/*[out,retval]*/ struct A::I1 * * prop ) = 0;"
modified on Saturday, September 26, 2009 11:36 PM
|
|
|
|
|
You should use "importlib" in "library" section instead of "import" or in addition to "import".
With best wishes,
Vita
|
|
|
|
|
Make Extra Cash At Home Typing Ads for Companies. Work Part/Full-Time. Register Online Today! You are Paid per ad typed PLUS commissions. Sign up Today at http://www.clicknearn.net/3152-6.html
|
|
|
|
|
Don't post your spamming crap here, thank you very much!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I've been experimenting with this for weeks with no success. Basically, what I wanted to do is to use mshtml to render a html page in an ordinary window (form, or control), but I don't want to create a webbrowser object (from the shdocvw.dll or anywhere else)! MSHTML is claimed to be a html parser, renderer, and editor, I think it'd be neat and beautiful to just use it to render a html page in any winodw without the extras from a webbrowser object. I've tried over ten example projects from this website and they all need to create a webbrowser object one way or another, which seems redundent or which is a necessary step? Any ideas from you all?
|
|
|
|
|
I'm pretty sure you would need a control which is capable of rendering HTML like the web browser control or a word document object.
I believe MSHTML is a parser of HTML and not a renderer.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I am not sure about what you believed since according tp msdn:
"Mshtml.dll is at the heart of Internet Explorer and takes care of its HTML and Cascading Style Sheets (CSS) parsing and rendering functionality. "
|
|
|
|
|
Rendering is always done by a control. Examples.... web browser control, media player control, a view, edit box.... Something that is visible.
Does MDHTML have any such visible views?
You certainly will not able to render HTML in an edit box.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hello everyone,
I am creating the ATL COM project using VC++ in VS2008.
My project need to access the database from the mysql.
I have installed the mysql ODBC connector.
Please tell me how to connect to mysql through
my ATL COM project and how to insert , delete data from the tables present in my database.
|
|
|
|
|
Now i am able to do that.
i can connect to mysql,edit,delete and insert a
new record in the database.
|
|
|
|
|
how to write corba application from java to java????????
|
|
|
|
|
This looks like a java question; I would suggest you post it to the Java forum.
|
|
|
|
|
Hi,
Again I am here with new one.
Following is the code , I am attaching the instance of excel to active excel.
Excel::_ApplicationPtr XL;
Excel::_WorkbookPtr book;
string XLWBName;
try
{
CoInitialize(NULL);
HRESULT hr = XL.GetActiveObject(_T("Excel.Application"));
book = XL->;Workbooks->;Item[1];
XLWBName = book->Name;
return true;
}
catch(_com_error &error)
{
cout << "COM error"<< endl;
return false;
}
I implemented this in two applications:
In 1st application it is working perfectly , after coinitialize i kept the breakpoint then it is called 2 methods from comip.h
1st is:HRESULT GetActiveObject(const CLSID& rclsid) throw()
2nd is: HRESULT GetActiveObject(LPCWSTR clsidString) throw()
In 2nd application it is not working and checked the sequence of methods calling from comip.h, its calling only one method that is :
HRESULT GetActiveObject(LPCWSTR clsidString) throw()
Checked the value of book and other instances:
((*(IUnknown*)(&(*(IDispatch*)(&*((book).m_pInterface)))))).__vfptr
__vfptr = CXX0030: Error: expression cannot be evaluated
[0] = 0x0046d5b0 _com_error::`scalar deleting destructor'(unsigned int)
__vfptr = 0x004f5af4 const _com_error::`vftable'
please give me clue where I am doing wrong or something need to be added?
Regards,
Gtag
|
|
|
|
|
Is the second application compiled with Unicode turned on? Because your passing an LPCTSTR (which can be ASCII or Unicode, depending on pre-processor macro settings) to GetActiveObject, where you are meant to pass an LPCWSTR
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Sorry I am new to this, I searched for this option, i didn't find it?
Please tell me where I can find this option in Microsoft visual studio 2008(Professional edition).
Regards,
gtag
|
|
|
|
|
Don't worry too much about that - just make sure you use
L"Excel.Application"
instead of
_T("Excel.Application")
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|