Jiangsheng的CSDN Digest(March 4, 2006)(4)

王朝other·作者佚名  2006-03-10
窄屏简体版  字體: |||超大  

All services run in Terminal Services session 0. Therefore, if an interactive service displays a user interface, it is only visible to the user who connected to session 0. Because there is no way to guarantee that the interactive user is connected to session 0, do not configure a service to run as an interactive service on Terminal Services or Windows XP (fast user switching is implemented using Terminal Services).

If a service running on a multiuser system must interact with a user, the service should create a separate GUI application running within the context of the interactive user. The easiest way to run an application in each session is to add it to the following key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. This GUI application should be designed to communicate with the service through some method of IPC, for example, named pipes, as described in the previous section. By using named pipes, the server can distinguish between multiple user processes by giving each pipe a unique name based on the session ID.

Reference:

Interacting with Services

http://blogs.msdn.com/larryosterman/archive/2005/09/14/466175.aspx

Architecture of Fast User Switching

http://support.microsoft.com/kb/294737

为什么javascript只能收到控件的事件,而普通的COM不行呢(VC/MFC ATL/ActiveX/COM )

test2是用ATL建立的一个full control,Apartment模型,dual接口,支持连接点.

test是用ATL建立的一个simple object,Apartment模型,dual接口,支持连接点.

这两个对象都增加了事件OnTest,并且都在test方法中调用了Fire_OnTest();

但是网页运行的结果是只弹出对话框"test2".

http://groups.google.com/group/microsoft.public.vc.atl/browse_thread/thread/746df98b5c75f906/65cf79a77ad62795?lnk=st&q=%22simple+object%22+event+atl+internet+explorer&rnum=1&hl=en#65cf79a77ad62795

When using theATL, the following 'lite control' ATL objects do not implement the IProvideClassInfo2 interface by default:

You can easily add support for event handling by implementing the

IProvideClassInfo interfaces. This is done by deriving your control from the

default ATL implementation, IProvideClassInfo2Impl.

1. Add the following line to your class derivation list:

public IProvideClassInfo2Impl<&CLSID_<object_name>, NULL,

&LIBID_<project_name>Lib>

2. Add the following lines to your COM_MAP:

COM_INTERFACE_ENTRY(IProvideClassInfo)

COM_INTERFACE_ENTRY(IProvideClassInfo2)

Hope that helps. For additional information you can take a look at KB Q200839 http://support.microsoft.com/kb/200839

如何向richtextbox中插入flash影片(VB 基础类)

注意:是真正的插入对象,不是setparent之类的实现,要求不用剪贴板,不重新封装播放flash的控件,能实现多个影片同时播放

其实我这个想法是看了的文章后产生的,你可以看一下:

http://blog.csdn.net/dtianx/archive/2004/11/17/184949.aspx

//但多次粘贴时,只能有一个控件处于活动状态

怀疑这是由于Flash控件的刷新机制与Rich Edit的OLE接口存在冲突

所以很可能需要封装Flash控件,为Flash控件做好OLE接口

我也这么想过,但这样一来,通用性就降低了,所以要求,不重新封装播放flash的控件,就是想看看有没有办法从其它方面进行突破

Yes, Flash.ocx supports IOleObject. but it won't update its display like the QQ image lib ActiveX.

private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)

...{

HWND h=(HWND)richTextBox1->Handle.ToInt32();

LPRICHEDITOLElpRichEditOle=NULL;

LPOLEOBJECTlpObject=NULL;

LPSTORAGE lpStorage=NULL;

LPOLECLIENTSITElpClientSite=NULL;

LPLOCKBYTESlpLockBytes = NULL;

REOBJECT reobject;

ZeroMemory(&reobject, sizeof(REOBJECT));

reobject.cbStruct = sizeof(REOBJECT);

HRESULT hr=S_OK;

CLSID clsid=CLSID_NULL;

do...{

::SendMessage(h, EM_GETOLEINTERFACE, 0, (LPARAM)&lpRichEditOle);

if(lpRichEditOle==NULL)

break;

hr= ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);

if (hr != S_OK||lpLockBytes==NULL)

break;

hr= ::StgCreateDocfileOnILockBytes(lpLockBytes,

STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &lpStorage);

if (hr!= S_OK||lpStorage==NULL)

break;

hr=lpRichEditOle->GetClientSite(&lpClientSite);

if (hr!= S_OK||lpClientSite==NULL)

break;

try

...{

ShockwaveFlashObjects::IShockwaveFlashPtrpFlash;

hr = pFlash.CreateInstance(ShockwaveFlashObjects::CLSID_ShockwaveFlash);

if( FAILED(hr) )_com_issue_error(hr);

/**//*if(openFileDialog1->ShowDialog()==DialogResult::OK)*/...{

//__wchar_t * str = (__wchar_t *)(void*)Marshal::StringToHGlobalUni(openFileDialog1->FileName);

//_bstr_t bstrPath(str);

//Marshal::FreeHGlobal(str);

_bstr_t szMovie = "C:\\WINDOWS\\Help\\Tours\\mmTour\\intro.swf";

pFlash->PutMovie(szMovie);

if( FAILED(hr) )_com_issue_error(hr);

hr = pFlash.QueryInterface(IID_IOleObject, (void**)&lpObject);

if( FAILED(hr)||lpObject==NULL)_com_issue_error(hr);

hr=OleSetContainedObject(lpObject, TRUE);

if( FAILED(hr) )_com_issue_error(hr);

hr=lpObject->GetUserClassID(&clsid);

if( FAILED(hr) )_com_issue_error(hr);

reobject.clsid = clsid;

reobject.cp = REO_CP_SELECTION;

reobject.dvaspect = DVASPECT_CONTENT;

reobject.dwFlags = REO_BELOWBASELINE;

reobject.dwUser = 0;

reobject.poleobj = lpObject;

reobject.polesite = lpClientSite;

reobject.pstg = lpStorage;

SIZEL sizel=...{0,0};

reobject.sizel = sizel;

hr=lpRichEditOle->InsertObject(&reobject);

pFlash->Play();

}

}

catch( _com_error e )

...{

LPCTSTR lpszErrMessage=e.ErrorMessage();

}

}while(FALSE);

if(lpLockBytes)

lpObject->Release();

if(lpLockBytes)

lpLockBytes->Release();

if(lpClientSite)

lpClientSite->Release();

if(lpRichEditOle)

lpRichEditOle->Release();

}

刷新的问题倒是不大,可以这样:

public void UpdateObjects()

...{

int k = this.IRichEditOle.GetObjectCount();

for (int i = 0; i < k; i++)

...{

REOBJECT reoObject = new REOBJECT();

this.IRichEditOle.GetObject(i, reoObject,

GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);

if (reoObject.dwUser == 1)

...{

Point pt = this._richEdit.GetPositionFromCharIndex(reoObject.cp);

Rectangle rect = new Rectangle(pt, reoObject.sizel);

this._richEdit.Invalidate(rect, false); // repaint

}

}

}

然后加个timer调用UpdateObjects

现在主要的问题是在vb中没法使用QueryInterface语句,直接用set赋值又提示类型不符

找到一种richtextbox加入flash控件的方法。像这样:

' 需要 Command1 和 RichTextBox1。还需要 IOleObject 的 tlb

Private Sub Command1_Click()Sub Command1_Click()

Dim objOle As IOleObject, objFlash As Object

Set objOle = RichTextBox1.OLEObjects.Add(, , , "ShockwaveFlash.ShockwaveFlash")

Set objFlash = objOle

objFlash.Movie = "http://cardimg.163.com/mcards/1/big/3081.swf"

End Sub

不过大概因为用的是 OLE 静态嵌入,还是只能一次激活单个控件。用 spy++ 看的话只有激活的控件才有 MacromediaFlashPlayerActiveX 类的窗口。 :(

其实就我的提问的问题而言,问题已经基本解决了,不过费了很大的力气声明了对应IShockwaveFlash接口的结构体,总想把他用上,另外,对于这个结构体声明的是否正确,心里还不敢肯定,所以有上面的一问,我声明的结构体,哪位帮我看看,对还是不对:

Private Type IShockwaveFlashVB

' IUnknown

mQueryInterface As Long 'Function,offset 0

AddRef As Long 'Function,offset 4

mRelease As Long 'Function,offset 8

'IDispatch

GetTypeInfoCount As Long 'Function,offset 12

GetTypeInfo As Long 'Function,offset 16

GetIDsOfNames As Long 'Function,offset 20

Invoke As Long 'Function,offset 24

'IShockwaveFlash

GetReadyState As Long 'property get,offset 28

GetTotalFrames As Long 'property get,offset 32

GetPlaying As Long 'property get,offset 36

SetPlaying As Long 'property let,offset 40

GetQuality As Long 'property get,offset 44

SetQuality As Long 'property let,offset 48

GetScaleMode As Long 'property get,offset 52

SetScaleMode As Long 'property let,offset 56

GetAlignMode As Long 'property get,offset 60

SetAlignMode As Long 'property let,offset 64

GetBackgroundColor As Long 'property get,offset 68

SetBackgroundColor As Long 'property let,offset 72

GetLoop As Long 'property get,offset 76

SetLoop As Long 'property let,offset 80

GetMovie As Long 'property get,offset 84

SetMovie As Long 'property let,offset 88

GetFrameNum As Long 'property get,offset 92

SetFrameNum As Long 'property let,offset 96

SetZoomRect As Long 'Function,offset 100

Zoom As Long 'Function,offset 104

Pan As Long 'Function,offset 108

Play As Long 'Function,offset 112

Stop As Long 'Function,offset 116

Back As Long 'Function,offset 120

Forward As Long 'Function,offset 124

Rewind As Long 'Function,offset 128

StopPlay As Long 'Function,offset 132

GotoFrame As Long 'Function,offset 136

CurrentFrame As Long 'Function,offset 140

IsPlaying As Long 'Function,offset 144

PercentLoaded As Long 'Function,offset 148

FrameLoaded As Long 'Function,offset 152

FlashVersion As Long 'Function,offset 156

GetWMode As Long 'property get,offset 160

SetWMode As Long 'property let,offset 164

GetSAlign As Long 'property get,offset 168

SetSAlign As Long 'property let,offset 172

GetMenu As Long 'property get,offset 176

SetMenu As Long 'property let,offset 180

GetBase As Long 'property get,offset 184

SetBase As Long 'property let,offset 188

GetScale As Long 'property get,offset 192

SetScale As Long 'property let,offset 196

GetDeviceFont As Long 'property get,offset 200

SetDeviceFont As Long 'property let,offset 204

GetEmbedMovie As Long 'property get,offset 208

SetEmbedMovie As Long 'property let,offset 212

GetBGColor As Long 'property get,offset 216

SetBGColor As Long 'property let,offset 220

GetQuality2 As Long 'property get,offset 224

SetQuality2 As Long 'property let,offset 228

LoadMovie As Long 'Function,offset 232

TGotoFrame As Long 'Function,offset 236

TGotoLabel As Long 'Function,offset 240

TCurrentFrame As Long 'Function,offset 244

TCurrentLabel As Long 'Function,offset 248

TPlay As Long 'Function,offset 252

TStopPlay As Long 'Function,offset 256

SetVariable As Long 'Function,offset 260

GetVariable As Long 'Function,offset 264

TSetProperty As Long 'Function,offset 268

TGetProperty As Long 'Function,offset 272

TCallFrame As Long 'Function,offset 276

TCallLabel As Long 'Function,offset 280

TSetPropertyNum As Long 'Function,offset 284

TGetPropertyNum As Long 'Function,offset 288

TGetPropertyAsNumber As Long 'Function,offset 292

GetSWRemote As Long 'property get,offset 296

SetSWRemote As Long 'property let,offset 300

GetFlashVars As Long 'property get,offset 304

SetFlashVars As Long 'property let,offset 308

GetAllowScriptAccess As Long 'property get,offset 312

SetAllowScriptAccess As Long 'property let,offset 316

GetMovieData As Long 'property get,offset 320

SetMovieData As Long 'property let,offset 324

GetInlineData As Long 'property get,offset 328

SetInlineData As Long 'property let,offset 332

GetSeamlessTabbing As Long 'property get,offset 332

SetSeamlessTabbing As Long 'property let,offset 332

End Type

第一頁    上一頁    第4頁/共8頁    下一頁    最後頁
第01頁 第02頁 第03頁 第04頁 第05頁 第06頁 第07頁 第08頁 
 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航