|
I have an unmanged MFC project, in which we plan to add a MS Visio control.
Now, I can bring Visio out, set its properties. But I cannot find a way to add events?
Can anyone help me?
By investigation of Visio SDK, we found something like:
vaoGetObjectWrap(app)
app.EventList(eList)
eList.AddAdvise(....)
Seems there is a way to do it. But I cannot find any code samples that actually work.
Can anyone help, please.
|
|
|
|
|
hi all,
I have a series of JPEG file coming from a source. I have to create a MPEG file from the series of JPEG file, which can be played in Media Player. How can I do this. What algorith i have to use or else i have to use COM and ActiveX control for the same. Can u give any idea regarding this.
Thanks and Regards
Yudhisthira Attry
|
|
|
|
|
Hello!
How I can create COM+ application in Component Services->Computers->My omputer->COM+ Application->[My COM+ App] from my own program?
How I can run commands 'Shutdown', 'Start' and 'Disable' for my COM + Application?
Is it possible?
Please, help me if somebody know..
Thanks..
-- modified at 5:49 Tuesday 27th March, 2007
|
|
|
|
|
Is there a way to access a COM component without knowing it's ClassID?
----------------------------
286? WOWW!
|
|
|
|
|
This is not the case: a CLSID is just one object discovery/creation mechanism. As another poster pointed out, another mechanism is the ProgID. Another is monikers (see the IMoniker interface). There are more, not counting ones you invent yourself.
-- modified at 1:28 Tuesday 27th March, 2007
It seems the post this was a reply to has been deleted; this was not a response to _8086’s post as looks like is the case. I must say it’s a little weak to delete a post just because someone replies and corrects you, especially when it destroys the flow of the thread.
Steve
|
|
|
|
|
Depends on what you mean with "access a COM component without knowing its ClassID".
You have to know something about it, if you want to create an instance of it...
If you know the ProgID you can get the ClassID with ::CLSIDFromProgID() .
It could be a component that is registered as a member of a component category, which means that it expose interfaces that components of that category have to expose. Enumerating the members of a category will get you the ClassID for each component in that category.
But if don't want to create an instance of the component, you would only need to know one of the interfaces it exposes and get an interface pointer from another client of that instance.
Probably a confusing answer to a somewhat confusing question... :->
Post again and describe what you mean more clearly if the above doesn't help.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi,
I am using the MS Word 9 object library and I would like to convert a Word document into html format using the code below. However, my .Net application does not recognise the wdFormatHTML file format.
I just don't know what to do about this and would really really appreciate any help on this.
Please help.
Kind regards,
Polly Anna
Dim strFileName As String
Dim objWordApplication As New Word.Application
Dim objDocument As New Word.Document
strFileName = pstrPathName & "\" & pstrDocumentName
objDocument = objWordApplication.Documents.Open(strFileName)
objDocument.Activate()
objDocument.Bookmarks.Add("TestBookmark2")
objDocument.SaveAs (FileName:="DOCUMENTNAMEHERE.htm",FileFormat:=wdFormatHTML, EmbedTrueTypeFonts:=False)
|
|
|
|
|
is word k.document
k.html inverted to html
////////////////////////
string filePath = "D:\\k.doc";
Word.ApplicationClass wordApplication = new Word.ApplicationClass();
// Opening a Word doc requires many parameters, but we leave most of them blank...
object o_nullobject = System.Reflection.Missing.Value;
object o_filePath = filePath;
Word.Document doc = wordApplication.Documents.Open(ref o_filePath,
ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject);
// Here we save it in html format...
// This assumes it was called "something.doc"
string newfilename = "k.html";
object o_newfilename = newfilename;
object o_format = Word.WdSaveFormat.wdFormatHTML;
object o_encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
object o_endings = Word.WdLineEndingType.wdCRLF;
// Once again, we leave many of the parameters blank.
// See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbawd11/html/womthSaveAs1_HV05213080.asp
// for full list of parameters.
wordApplication.ActiveDocument.SaveAs(ref o_newfilename, ref o_format, ref o_nullobject,
ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
ref o_nullobject, ref o_nullobject, ref o_encoding, ref o_nullobject,
ref o_nullobject, ref o_endings, ref o_nullobject);
// Report success...
// Finally, close original...
doc.Close(ref o_nullobject, ref o_nullobject, ref o_nullobject);
tkml
|
|
|
|
|
Hi Tklem,
yes, that worked a treat.
Thank you very much indeed.
Kind regards,
Polly Anna
|
|
|
|
|
I made a program used mingw to play wave by direct sound.
it's compled but can work ( no sound ).
can any one give me an example of direct sound ? thanks in advance !
here is my program :
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <windows.h>
#include <dsound.h>
static const char* getSndErr(HRESULT hr){
char *p;
switch(hr){
case DSERR_ALLOCATED :
p=" DSERR_ALLOCATED";
break;
case DSERR_CONTROLUNAVAIL :
p=" DSERR_CONTROLUNAVAIL";
break;
case DSERR_BADFORMAT :
p=" DSERR_BADFORMAT";
break;
case DSERR_INVALIDPARAM:
p=" DSERR_INVALIDPARAM";
break;
case DSERR_NOAGGREGATION :
p=" DSERR_NOAGGREGATION";
break;
case DSERR_OUTOFMEMORY :
p=" DSERR_OUTOFMEMORY";
break;
case DSERR_UNINITIALIZED :
p=" DSERR_UNINITIALIZED";
break;
case DSERR_UNSUPPORTED :
p=" DSERR_UNSUPPORTED";
break;
default :
p="Unknown";
break;
}
return p;
}
static LPGUID snd_guid=NULL;
static BOOL OnDSoundDev(
LPGUID lpGuid,
LPCSTR lpDesp,
LPCSTR lpModule,
LPVOID lpContext ){
static int i;
//fprintf(stderr, "Get DSound: %s\t%s\n", lpDesp, lpModule);
fprintf(stderr, "Get DSound device\n");
if( i ) snd_guid= lpGuid;
return i++ == 0;
}
int main(int argc ,char** argv){
if( argc!= 2) return 0;
LPVOID lpPtr1=NULL;//指针1;
LPVOID lpPtr2=NULL;//指针2;
HRESULT hResult;
DWORD dwLen1,dwLen2;
char* m_pMemory=NULL;//内存指针;
LPWAVEFORMATEX m_pFormat=NULL;//LPWAVEFORMATEX变量;
LPVOID m_pData;//指向语音数据块的指针;
DWORD m_dwSize;//WAVE文件中语音数据块的长度;
int file;//Cfile对象;
DWORD dwSize;//存放WAV文件长度;
//~ if(FAILED( CoInitialize(NULL) )) return 0;
//打开sound.wav文件;
file= _open (argv[1],_O_RDONLY | _O_BINARY);
if(file<0) return 0 ;
//get size
dwSize= _lseek (file ,0,SEEK_END);
//为m_pMemory分配内存,类型为LPVOID,用来存放WAVE文件中的数据;
m_pMemory =(char*) GlobalAlloc (GMEM_FIXED, dwSize);
dwLen1=0;
_lseek (file, 0,SEEK_SET);//定位到打开的WAVE文件头;
while( !_eof(file)){
dwLen2=_read(file, &m_pMemory[dwLen1] , dwSize- dwLen1) ;
if( dwLen2<0) return 0;
dwLen1+= dwLen2;
} //while
fprintf(stderr, "Read %d bytes, acturally has %d bytes\n", dwLen1, dwSize);
if( dwLen1!=dwSize) perror("");
_close(file);
LPDWORD pdw=NULL,pdwEnd=NULL;
DWORD dwRiff,dwType, dwLength;
//if (m_pFormat) //格式块指针
m_pFormat = NULL;
//if (m_pData) //数据块指针,类型:LPBYTE
m_pData = NULL;
//if (m_dwSize) //数据长度,类型:DWORD
m_dwSize = 0;
pdw = (DWORD *) m_pMemory;
dwRiff = *pdw++;
dwLength = *pdw++;
dwType = *pdw++;
if (dwRiff != mmioFOURCC ('R', 'I', 'F', 'F'))
return 0 ;//判断文件头是否为"RIFF"字符;
if (dwType != mmioFOURCC ('W', 'A', 'V', 'E'))
return 0 ;//判断文件格式是否为"WAVE";
//寻找格式块,数据块位置及数据长度
pdwEnd = (DWORD *)((BYTE *) m_pMemory+dwLength -4);
bool m_bend=false;
//~ DirectSoundEnumerate( (LPDSENUMCALLBACK )OnDSoundDev, NULL);
//~ do Sleep(100); while( snd_guid ==NULL);
while ((pdw < pdwEnd)&&(!m_bend))
//pdw文件没有指到文件末尾并且没有获取到声音数据时继续;
{
dwType = *pdw++;
dwLength = *pdw++;
switch (dwType)
{
case mmioFOURCC('f', 'm', 't', ' ')://如果为"fmt"标志;
if (!m_pFormat)//获取LPWAVEFORMATEX结构数据;
{
if (dwLength < sizeof (WAVEFORMAT)) return 0 ;
m_pFormat = (LPWAVEFORMATEX) pdw;
}
break;
case mmioFOURCC('d', 'a', 't', 'a')://如果为"data"标志;
if (!m_pData || !m_dwSize)
{
m_pData = (LPBYTE) pdw;//得到指向声音数据块的指针;
m_dwSize = dwLength;//获取声音数据块的长度;
if (m_pFormat)m_bend=TRUE;
}
break;
}
pdw = (DWORD *)((BYTE *) pdw + ((dwLength + 1)&~1));//修改pdw指针,继续循环;
}
DSBUFFERDESC BufferDesc;//定义DSUBUFFERDESC结构对象;
memset (&BufferDesc, 0, sizeof (BufferDesc));
BufferDesc.lpwfxFormat = (LPWAVEFORMATEX)m_pFormat;
BufferDesc.dwSize = sizeof (DSBUFFERDESC);
BufferDesc.dwBufferBytes = m_dwSize;
BufferDesc.dwFlags = 0;
HRESULT hRes;
LPDIRECTSOUND m_lpDirectSound;
hRes = ::DirectSoundCreate(0, &m_lpDirectSound, 0);//创建DirectSound对象;
if( hRes != DS_OK ) return 0;
//~ DirectSoundEnumerate((LPDSENUMCALLBACK)OnDSoundDev, 0);
if( DS_OK !=m_lpDirectSound->SetCooperativeLevel(
GetDesktopWindow(),
DSSCL_EXCLUSIVE
//DSSCL_NORMAL
)){
fprintf(stderr," SetCooperativeLevel err: %s\n", getSndErr(hRes));
return 0;
}
//设置声音设备优先级别为"NORMAL";
//创建声音数据缓冲;
LPDIRECTSOUNDBUFFER m_pDSoundBuffer;
if ( (hRes=m_lpDirectSound->CreateSoundBuffer (&BufferDesc, &m_pDSoundBuffer, 0)) != DS_OK) {
fprintf(stderr," CreateSoundBuffer err: %s\n", getSndErr(hRes));
return 0;
}
//载入声音数据,这里使用两个指针lpPtr1,lpPtr2来指向DirectSoundBuffer缓冲区的数据,这是为了处理大型WAVE文件而设计的。dwLen1,dwLen2分别对应这两个指针所指向的缓冲区的长度。
hResult=m_pDSoundBuffer->Lock(0,m_dwSize,&lpPtr1,&dwLen1,&lpPtr2,&dwLen2,0);
if (hResult == DS_OK){
memcpy (lpPtr1, m_pData, dwLen1);
if(dwLen2>0){
BYTE *m_pData1=(BYTE*)m_pData+dwLen1;
m_pData=(void *)m_pData1;
memcpy(lpPtr2,m_pData, dwLen2);
}
if( DS_OK!=m_pDSoundBuffer->Unlock (lpPtr1, dwLen1, lpPtr2, dwLen2))
fprintf(stderr," unlock err: %s\n", getSndErr(hRes));
else if( DS_OK!= m_pDSoundBuffer->Play (0, 0, 0)) //播放WAVE声音数据;
fprintf(stderr," play err: %s\n", getSndErr(hRes));
} else fprintf(stderr," Lock err: %s\n", getSndErr(hRes));
out:
if(m_pMemory) GlobalFree(m_pMemory);
//~ CoUninitialize();
}
|
|
|
|
|
A question:
running IIS in Windows 2004 64 bit, using COM+ 32 bit components instanced by ASP scripts, is the 3/4 GB limit for EVERY single COM+ component or for the full set of COM+ components?
Does those COM+ components share the same 4GB of global memory?
thanks in advance
Stefano
|
|
|
|
|
I use redemption.dll to work with outlook. When I trying to create any object from this library
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast(&pIUnknown));
In hr i have 0x80040154 Class not registered. But in register, class with this CLSID exists.
What the problem is?
|
|
|
|
|
What values do 'pOuter' and 'dwClsContext' have?
Bear in mind that if dwClsContext is too restrictive, you can't launch the server.
Steve S
Developer for hire
|
|
|
|
|
dwClsContext=CLSCTX_LOCAL_SERVER
(I use com object from the local computer, in another proccess, and it seems that this parameter have right value)
pOuter = NULL (?maybe in this problem)
|
|
|
|
|
The redemption stuff is packaged in a DLL, so you might want to try CLSCTX_SERVER (or even CLSCTX_INPROC_SERVER explicitly) and see what happens.
It's unlikely that pOuter = NULL is your issue, unless Redemption insists on being an aggregated object, which I doubt.
Steve S
Developer for hire
|
|
|
|
|
I tried with all this flags also, but nothing good happens.
I have solved my problem with MapiEx. Thanks for help.
|
|
|
|
|
Hi,
I want some instructions in converting existing C# Windows Application to C# Web Application..
Please post your replies as soon as possible.
|
|
|
|
|
If the application has been properly architected it should just be a matter of rewriting the presentation (UI) layer - perhaps with the odd addition elsewhere to support a stateless model of working. If it hasn't been well architected then you are looking at rewriting the whole application.
|
|
|
|
|
Spamming different 10 forums with the same question is very rude and totally unnecessary.
And i fail to see what rewriting an application under Windows Forms has anything to do with COM.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi there.
I am working on developing a geobase scientific application. I need a control/component that I could put on a form view and use as map for a user to create watersheds and retrieve GIS information from it. While searching for such control I came across the MapWindow ActiveX control developed by a group of scientists at Idaho State University. On their website they also posted several sample projects, form-based VS2003 .NET included with manual/tutorial [^]. I was able to register the control and run the sample project. Everything worked fine and it did display the maps flawlessly. The problem begins with the MFC type project. And that's exactly the type of application I am working on.
I am a newbie to the COM and ActiveX controls under the MFC. I used excellent Michael Dunn's article[^] as a guide to getting the MapWindow ActiveX control to work. I realize or at least I think that MapWindow.ocx file is a COM object and we need to get a pointer to the objects within that control using the wrapper interface classes and so on, but for example when I try to get an access to the IShapefile interface the compiler says that there is no interface.
I tried to get help from their forum but noone responded yet.
Have someone had an experience in hosting the MapWindow ActiveX control in the MFC project? I'd really appreciate any help?
Thanks in advance,
Alex
P.S. Here are the snippets of the code that I wrote within CFormView class in order to get an access to the IShapefile interface that is of a coclass Shapefile in the MapWindow Control:
if( FAILED(CoInitialize(NULL)) ){
::AfxMessageBox( "COM Library Init Failed" );
::AfxAbort();
}
IShapefile* m_pShapefile = new IShapefile;
CLSID CLSID_Shapefile;
::CLSIDFromProgID( L"MapWinGIS.Shapefile.1", &CLSID_Shapefile );
IID IID_Shapefile;
hr = ::CoCreateInstance ( CLSID_Shapefile,
NULL,
CLSCTX_INPROC_SERVER,
IID_Shapefile,
(void**) &m_pShapefile );
if( SUCCEEDED( hr ) ){
CString s = "world_adm0.shp";
m_pShapefile->Open( s, NULL );
}
|
|
|
|
|
Hi All,
i have an interface which exposes 2 methods.
The coclass has a member variable of type
X *p;
from my applicationi call method 1.
in method 1
i do
p = new (class y); // class y inherits from X.
again after call to method 1 i call method 2
in method 2
i do
if(p)
delete p;
i get an exception when i try to delete.
i do coinitialize etc..only once and then release, couninitialize after method 2.
please help
Thanks & Regards,
Dhana
|
|
|
|
|
Since you're deleting a pointer of base class type, it's imperative that the destructor is declared virtual . If not you'll probably get an exception.
If you have declared your destructors as virtual , I suggest you post some code that shows the destructor definitions and how your p variable is declared.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I already have the base class destructor set to virtual.
Thanks
Thanks & Regards,
Dhana
|
|
|
|
|
jana_dhana wrote: I already have the base class destructor set to virtual.
Ok, so where's the code snippets I asked for?
From what you have described in your first post neither prasad nor I can find anything wrong, so we're just guessing at this point.
My guess was that you could have forgotten to declare the destructor as virtual, but I also suggested that if you've already done that you should post some code. Since you haven't posted any code at least I don't have any better guess.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
To add to roger's suggestion,
jana_dhana wrote: if(p)
delete p;
It is good practice to set pointer to NULL , after deletion, and no need to check pointer for NULL . It is safe to call delete on NULL pointer.
you can modify your code to,
delete p;
p = NULL;
And obviously, its needed some more code to see, to track down the problem.
|
|
|
|
|