自己的程序里有个IE控件,把它的右键屏蔽了?

dsclub 2002-11-14 02:45:32
以下是我用VB来实现的:
'//////////////////Form1/////////////////////
Option Explicit
Dim hAimWnd As Long

Private Sub Form_Load()

WebBrowser1.Navigate "e:\bookmark.htm"
DoEvents
hAimWnd = 0&

Me.Show
DoEvents
FindWebPage Me.hWnd

If hAimWnd <> 0& Then
HookWind hAimWnd
Debug.Print hAimWnd
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
UnHookWind hAimWnd
End Sub

Public Sub FindWebPage(ByVal hParentWnd As Long)
Dim strClassName As String * 30
Dim hTempWnd As Long

hTempWnd = GetWindow(hParentWnd, GW_CHILD) '找找孩子
Do While (hTempWnd <> 0)
strClassName = ""
GetClassName hTempWnd, strClassName, 30
Debug.Print strClassName '给我报上姓名!!
If Left(strClassName, Len("Internet Explorer_Server")) = "Internet Explorer_Server" Then

hAimWnd = hTempWnd
Exit Sub
End If
FindWebPage hTempWnd ', lgAim

hTempWnd = GetWindow(hTempWnd, GW_HWNDNEXT) '找找同级兄弟
Loop

End Sub

'//////////Module1///////////////////////////
Option Explicit
'Api声明
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
'系统参数宏
Public Const GW_CHILD As Long = 5
Public Const GW_HWNDNEXT As Long = 2
Public Const GWL_WNDPROC As Long = -4
Public Const WM_RBUTTONDOWN As Long = &H204
Public Const WM_RBUTTONDBLCLK As Long = &H206
Public Const WM_RBUTTONUP As Long = &H205
'个人参数设定
Dim lpPrevWndFunc As Long


Public Function HookWind(ByVal hWnd As Long) As Long

lpPrevWndFunc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)

End Function


Public Function UnHookWind(ByVal hWnd As Long) As Long
SetWindowLong hWnd, GWL_WNDPROC, lpPrevWndFunc
End Function

Public Function WindowProc( _
ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Select Case uMsg
Case WM_RBUTTONUP, WM_RBUTTONDOWN, WM_RBUTTONDBLCLK
WindowProc = 1
Exit Function
Case Else
WindowProc = CallWindowProc(lpPrevWndFunc, hWnd, uMsg, wParam, lParam)
End Select

End Function



但是用VC怎么做呢?

还想请教一下,怎么知道一张网页已经全部加载完了,不同大小的网页,所要加载的时间也不一样呀,因为只有网页全加载完成了才能找到Internet Explorer_Server类。

我刚刚学VC,而东西要的很急,我不知道怎么从VB迅速找到VC的感觉呀。
比如SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)最后一个参数在VC里怎么用这个回调呢?AddressOf的代替是什么呢?还有像是:SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)这要在VC里放到哪个相应的地方?


******************网页全部加载完成的消息是什么呢?**********************



请各位帮忙了!!!!!!!!


最好给源码,讲详细些!!!!


我很想快速找到VC的感觉!!

...全文
92 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
hwonzor 2002-11-14
  • 打赏
  • 举报
回复
gs
dsclub 2002-11-14
  • 打赏
  • 举报
回复
我想问一下楼上的红星,用了鼠标钩子,会不会引起很多的麻烦:
在处理程序里的其它部分(不是IE控件里的部分)还要加以处理?因为我门现在是针对鼠标操作了
YP2002CN 2002-11-14
  • 打赏
  • 举报
回复
用zfive的不一定可以達到你的效果.
如果說你的IE裡面的html
有一個<iframe>..</iframe>構造的網頁.它是無法屏蔽的.譬如說在裡面加入word檔案.txt.這些都是沒有辦法.
最好的辦法就是用鼠標勾子.
你在google.com裡面搜索:鼠標勾子+vc.裡面可以得到代碼.記得在你捕獲的地方用
return 1;來返回就可以了.
dsclub 2002-11-14
  • 打赏
  • 举报
回复
哦,好谢谢zfive(醉码)了

这样我可以省了很多时间看书自己找答案了!

真的谢谢。


等结贴时定令开帖子给高分!
zfive 2002-11-14
  • 打赏
  • 举报
回复
控件变量.m_hWnd;

控件变量指针->m_hWnd;

你别说连控件变量或控件变量指针都没有吧?
dsclub 2002-11-14
  • 打赏
  • 举报
回复
hwnd==控件的句柄

在VC里用什么来取得控件的句柄?(我的意思是有没有现成的.hWnd)


也要用API:GetWindow 吗?

VC里用API是不是直接用就可以?还是要#include "windows.h"
zfive 2002-11-14
  • 打赏
  • 举报
回复
BOOL MainDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_RBUTTONUP&&pMsg->pMSG->hwnd==控件的句柄)
{
return TRUE;
}

return CFormView::PreTranslateMessage(pMsg);
}

}
dsclub 2002-11-14
  • 打赏
  • 举报
回复
有中文参考资料吗?


我这里教育网,出国的网站有困难呀!
用户 昵称 2002-11-14
  • 打赏
  • 举报
回复
哇,又一个五星级的人物,收藏
saucer 2002-11-14
  • 打赏
  • 举报
回复
>>右键屏蔽
HOWTO: Disable the Default Pop-up Menu for CHtmlView
http://support.microsoft.com/default.aspx?scid=KB;en-us;q236312

>>怎么知道一张网页已经全部加载完了
HOWTO: Determine When a Page Is Done Loading in WebBrowser Control
http://support.microsoft.com/default.aspx?scid=KB;en-us;q180366


>>AddressOf的代替是什么呢?
nothing, in C++, function name is a pointer, no need to use AddressOf

see references at

IE Programming
http://www.codeguru.com/ieprogram/index.shtml

Reusing the WebBrowser Control
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/webbrowser.asp
dsclub 2002-11-14
  • 打赏
  • 举报
回复
人呢?

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧