Jiangsheng的CSDN Digest(March 4, 2006)(6)
Option Explicit
Private Const RDW_ERASE = &H4
Private Const RDW_FRAME = &H400
Private Const RDW_INTERNALPAINT = &H2
Private Const RDW_INVALIDATE = &H1
Private Const RDW_ERASENOW = &H200
Private Const RDW_ALLCHILDREN = &H80
Private Const WM_USER = &H400
Private Const EM_GETOLEINTERFACE = WM_USER + 60
Private Const EM_POSFROMCHAR = (WM_USER + 38)
Private Const WM_LBUTTONDBLCLK = &H203
Private Declare Function InvalidateRect()Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
Private Declare Function SendMessage()Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub ZeroMemory()Sub ZeroMemory Lib "KERNEL32" Alias "RtlZeroMemory" (dest As Any, ByVal numBytes As Long)
Private Declare Function RedrawWindow()Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As Any, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Private Declare Function IIDFromString()Function IIDFromString Lib "ole32" (ByVal lpszIID As Long, iid As Any) As Long
Private Declare Function LockWindowUpdate()Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function CoCreateGuid()Function CoCreateGuid Lib "ole32.dll" (lpGUID As Any) As Long
Private Declare Function StringFromGUID2()Function StringFromGUID2 Lib "ole32" (lpGUID As Any, ByVal lpStr As String, ByVal lSize As Long) As Long
Const ProgID_Flash = "ShockwaveFlash.ShockwaveFlash.1"
Dim mIRichEditOle As IRichEditOle
'实现这个函数的目的是为了产生不重复的字串,为controls.add服务
Private Function GetGuidID()Function GetGuidID() As String
Dim pGuid(16) As Byte
Dim s As String
s = String(255, " ")
CoCreateGuid pGuid(0)
StringFromGUID2 pGuid(0), s, 255
s = Trim(s)
s = StrConv(s, vbFromUnicode)
s = Replace(s, "{", "")
s = Replace(s, "}", "")
s = Replace(s, "-", "")
GetGuidID = s
End Function
Private Sub Command1_Click()Sub Command1_Click()
RichTextBoxInsertFlash RichTextBox1.hwnd, "e:\MC\11.SWF"
End Sub
'在richtextbox的当前光标处插入flash,flash的movie为mFile
Private Sub RichTextBoxInsertFlash()Sub RichTextBoxInsertFlash(ByVal mHwnd As Long, ByVal mFile As String)
Dim mILockBytes As ILockBytes
Dim mIStorage As IStorage
Dim mIOleClientSite As IOleClientSite
Dim mIOleObject As IOleObject
Dim mReObject As REOBJECT
Dim mUUID As UUID
'创建Global Heap,实例化mILockBytes
Set mILockBytes = CreateILockBytesOnHGlobal(0&, True)
If ObjPtr(mILockBytes) = 0 Then
MsgBox "Error to create Global Heap"
Exit Sub
End If
'创建storage,实例化mIStorage
Set mIStorage = StgCreateDocfileOnILockBytes(mILockBytes, STGM_SHARE_EXCLUSIVE _
Or STGM_CREATE Or STGM_READWRITE, 0)
If ObjPtr(mIStorage) = 0 Then
MsgBox "Error to create storage"
Exit Sub
End If
'向richtextbox发送EM_GETOLEINTERFACE消息获得IRichEditOle接口,实例化mIRichEditOle
SendMessage mHwnd, EM_GETOLEINTERFACE, 0, mIRichEditOle
If ObjPtr(mIRichEditOle) = 0 Then
MsgBox "Error to get IRichEditOle"
Exit Sub
End If
'调用GetClientSite函数,实例化mIOleClientSite
Set mIOleClientSite = mIRichEditOle.GetClientSite
If ObjPtr(mIOleClientSite) = 0 Then
MsgBox "Error to get ClientSite"
Exit Sub
End If
'动态添加flash控件,用于解决插入多个影片的问题
Dim mFlash As ShockwaveFlashObjectsCtl.ShockwaveFlash
Set mFlash = Controls.Add(ProgID_Flash, "mc" + GetGuidID)
mFlash.Movie = mFile
'查询IOleObject接口
Set mIOleObject = mFlash.Object
OleSetContainedObject mIOleObject, True
mIOleObject.GetUserClassID mUUID
'填充mReObject
With mReObject
.cbStruct = LenB(mReObject)
.clsid = mUUID
.cp = REO_CP_SELECTION
.DVASPECT = DVASPECT_CONTENT
.dwFlags = REO_BELOWBASELINE ' Or REO_RESIZABLE
.sizel.cx = 0
.sizel.cy = 0
.dwUser = 0
Set .poleobj = mIOleObject
Set .polesite = mIOleClientSite
Set .pStg = mIStorage
End With
'在richtextbox的当前光标处插入flash
mIRichEditOle.InsertObject mReObject
' '释放资源
ZeroMemory mReObject, LenB(mReObject)
ZeroMemory mUUID, LenB(mUUID)
Set mIOleClientSite = Nothing
Set mIStorage = Nothing
Set mILockBytes = Nothing
Set mIOleObject = Nothing
End Sub
Private Sub UpdateObjects()Sub UpdateObjects()
Dim i As Long, RE As REOBJECT
If ObjPtr(mIRichEditOle) = 0 Then Exit Sub
i = mIRichEditOle.GetObjectCount
Dim PT As olelib.Point
Dim k As Long, mSIZE As SIZE, RT As RECT
For k = 0 To i - 1
RE.cbStruct = LenB(RE)
mIRichEditOle.GetObject k, RE, REO_GETOBJ_ALL_INTERFACES
SendMessage RichTextBox1.hwnd, EM_POSFROMCHAR, VarPtr(PT), ByVal RE.cp
mSIZE = RE.sizel
With RT
.Left = PT.x
.Top = PT.y
.Right = mSIZE.cx * 192 / 5080 + PT.x
.Bottom = PT.y + mSIZE.cy * 192 / 5080
End With
InvalidateRect Me.RichTextBox1.hwnd, RT, False
Next
End Sub
Private Sub Form_Load()Sub Form_Load()
Timer1.Interval = 80 '数值越小,闪烁的越厉害
Timer1.Enabled = True
End Sub
Private Sub Form_QueryUnload()Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim obj As Object
For Each obj In Me.Controls
If TypeName(obj) = "shockwaveflash" And Left(obj.Name, 2) = "mc" Then
Controls.Remove obj
End If
Next
Set mIRichEditOle = Nothing
RichTextBox1.TextRTF = "" '关键代码,释放richtextbox占用的资源,否则程序不能正确退出
End Sub
Private Sub Form_Resize()Sub Form_Resize()
RichTextBox1.Move 0, 0, Me.ScaleWidth
End Sub
Private Sub Timer1_Timer()Sub Timer1_Timer()
UpdateObjects
End Sub
目前存在的问题,刷新的时候闪烁的很厉害
http://blog.csdn.net/rainstormmaster/archive/2006/02/09/595210.aspx
估计flash是故意不面向桌面程序的……插入对象需要容器和控件都支持一系列特定的接口
在mfc activex控件中怎么得到网页中的参数? (VC/MFC ATL/ActiveX/COM )
参数是网页中的类似 <PARAM NAME...... 格式的
通过IPropertyBag等接口。不过用MFC的话,重载DoPropExchange就可以了
vc++ 使用oracle ole db访问oracle stored procedure (Oracle 开发)
schemaRS = adoConnection->OpenSchema (adSchemaProcedureParameters, vtCriteria);
发现返回的schemaRs的size=4(按照道理似乎应该是1) adoCommand->CommandText应该写怎样的sql语句来执行它。
http://www.oracle.com/technology/sample_code/tech/windows/ole_db/oledb8/index.html
如何向超星阅读器那样可以获取IE中选中或全部的内容(图文混合),然后可以像FrontPage一样可以编辑? (VB 基础类 )
Private Sub GetElementUnderInsertionPoint()Sub GetElementUnderInsertionPoint()
Dim rg As IHTMLTxtRange
Dim ctlRg As IHTMLControlRange
'
branch on the type of selection and
' get the element under the caret or the site selected object
' print its outerHTML
Select Case DHTMLEdit1.DOM.selection.Type
Case "None", "Text"
Set rg = DHTMLEdit1.DOM.selection.createRange
' collapse the range so that the scope of the
' range of the selection is the caret. That way the
' parentElement method will return the element directly
' under the caret. If you don't want to change the state of the
' selection, then duplicate the range and collapse it
rg.collapse
MsgBox rg.parentElement.outerHTML
Case "Control"
' an element is site selected
Set ctlRg = DHTMLEdit1.DOM.selection.createRange
' there can only be one site selected element at a time so the
' commonParentElement will return the site selected element
MsgBox ctlRg.commonParentElement.outerHTML
End Select
End Sub
CFileDialog的记忆路径如何在选择文件前得到(VC/MFC 界面 )
CFileDialog每次选文件后路径都会记忆下来,下次再调用,会缺省在该目录下,怎么得到这个这个目录(当然不能选择文件,然后再计算).
问题的由来:
我的程序有两个地方调用CFileDialog,它们的路径不同(都不在程序文件夹,GetCrrentDirectory()不能使),设两个位置为A和B,一般情况都使用B,偶尔会使用A,我想在调用A时,先把B的路径保存起来,在A完后再恢复,现在的问题就是如何取得B的目录.(用一个变量在没次调B时都记一下有点蠢)
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxstructures/openfilename.asp
lpstrInitialDir
如何设置当前输入法?(.NET技术 C# )
[DllImport("imm32.dll")] public static extern int ImmGetContext(int hWnd);
[DllImport("imm32.dll")] public static extern int ImmReleaseContext(int hWnd,int hIMC);
[DllImport("imm32.dll")] public static extern int ImmSetOpenStatus(int hIMC,int fOpen);
private static void imeOnOff(int bOnOff)
...{int hIMC=ImmGetContext(GetFocus());
if(hIMC!=0)
...{ImmSetOpenStatus(hIMC,bOnOff);
ImmReleaseContext(GetFocus(),hIMC);
}
}
warning C4995: 'CDaoDatabase': name was marked as #pragma deprecated(C/C++ C++ 语言 )
.net2002(项目限制), ARX2006, AUTODESK MAP 3D 2006,XP操作系统
现在我们的一个工程需要进行数据库方面的操作,但是加上创建数据库的函数后,编译会出现4个waring,这样将导致CAD加载ARX程序时,不能加载,由于这个是公司保密要求,不能贴出源代码,所以请原谅,现在只能将这四个waring贴出,希望有经验的指点一下:
warning C4995: 'CDaoDatabase': name was marked as #pragma deprecated
warning C4995: 'CDaoTableDef': name was marked as #pragma deprecated
warning C4995: 'CDaoTableDef': name was marked as #pragma deprecated
warning C4995: 'CDaoRecordset': name was marked as #pragma deprecated
#pragma warning(disable : 4995)
请问InstallShield如何做一个多语言选择安装的对话框,其脚本如何写(VC/MFC 非技术类 )
我现在的程序要求支持多语言版本,现在只是装那个语言的把那个动态库(资源库)一起打包到相应的语言版本中,这样,给维护造成很的不便。请问能否把所有资源放在一起,由用户安装时选择安装那个语言
http://blog.joycode.com/hopeq/archive/2004/07/26/28460.aspx
能不能用asp.net调用vc++编译好的exe文件(VC/MFC 基础类 )
http://msdn2.microsoft.com/en-us/library/0w4h05yb.aspx
ASP.NET Web page and server control code executes in the context of the ASP.NET worker process on the Web server. If you use the Start method in an ASP.NET Web page or server control, the new process executes on the Web server with restricted permissions. The process does not start in the same context as the client browser, and does not have access to the user desktop.
怎样给已连接的某个特定客户开一个共享目录(VC/MFC 网络编程)
http://msdn.microsoft.com/library/en-us/netmgmt/netmgmt/netshareadd_sample_windows_95_98_me_.asp
NT always uses user-level security. shi2_permissions structure member will
be ignored on a server running user-level security. To setup a share that
allows Everyone only "Read" access, you have to setup a security descriptor
with level 502 and set shi502_security_descriptor structure member with a
security descriptor that allows Everyone only read access.
try
...{
//initialize the
SecurityDescriptor---------------------------------------------
SECURITY_DESCRIPTOR sd;
PACL pDacl = NULL;
DWORD dwAclSize ;
PSID pSid = NULL;
DWORD cbSid;
TCHAR RefDomain[DNLEN + 1];
DWORD cchDomain = DNLEN + 1;
SID_NAME_USE peUse;
cbSid = 96;
pSid = (PSID)HeapAlloc(GetProcessHeap(), 0, cbSid);
if(pSid == NULL) Memo1->Lines->Add("HeapAlloc error!");
String Username = "Everyone"; //or any other existing
username in your system...
wchar_t* userbuf = new wchar_t[(Username.Length() + 1)];
Username.WideChar(userbuf, Username.WideCharBufSize());
if(!LookupAccountName(NULL, userbuf, pSid, &cbSid, RefDomain,
&cchDomain, &peUse ))
...{
if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) // try again
...{
pSid = (PSID)HeapReAlloc(GetProcessHeap(), 0, pSid, cbSid);
if(pSid == NULL) Memo1->Lines->Add("HeapReAlloc error!");
cchDomain = DNLEN + 1;
if(!LookupAccountName(NULL, userbuf, pSid, &cbSid,
RefDomain, &cchDomain, &peUse))
...{
wchar_t* lpMsgBuf = new wchar_t[100];
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (wchar_t *) &lpMsgBuf, 0,
NULL);
Memo1->Lines->Add("LookupAccountName error! " +
AnsiString(lpMsgBuf));
delete lpMsgBuf;
}
}
else
...{
wchar_t* lpMsgBuf = new wchar_t[100];
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (wchar_t *) &lpMsgBuf, 0,
NULL);
Memo1->Lines->Add("LookupAccountName error! " +
AnsiString(lpMsgBuf));
delete lpMsgBuf;
}
}
delete userbuf;
}
dwAclSize = sizeof(ACL) + 1 * ( sizeof(ACCESS_ALLOWED_ACE) -
sizeof(DWORD)) GetLengthSid(pSid);
pDacl = (PACL)HeapAlloc(GetProcessHeap(), 0, dwAclSize);
if(pDacl == NULL) return;
InitializeAcl(pDacl, dwAclSize, ACL_REVISION);
AddAccessAllowedAce(pDacl,ACL_REVISION, GENERIC_READ | ACCESS_ATRIB,
pSid]); //use both GENERIC_READ and ACCESS_ATRIB or else windows won't
recognize the share as read only...
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION) ;
SetSecurityDescriptorDacl(&sd, TRUE, pDacl, FALSE);
//Initialize all other share variables-----------------
temp.shi502_security_descriptor = &sd;
// Add the shares-----------------
}
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。