句柄问题!高手请进!100分送上!

kwxx 2002-03-29 08:46:11
使用WebBrowser控件时
调用Hwnd属性时,出现"HWND"的"IWebBrowser2"方法错误
这是怎么回事?
高手赐教!!!
...全文
49 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
kwxx 2002-03-30
  • 打赏
  • 举报
回复
TO:LOU_DF(ldf)
有效吗?
WindowFromPoint是API
还是VB自带函语句?
lou_df 2002-03-30
  • 打赏
  • 举报
回复
x = Screen.Width / Screen.TwipsPerPixelX \ 2
y = (Screen.Height / Screen.TwipsPerPixelX) \ 2
SetCursorPos x, y '把鼠标移到WEBBROWSER上
GetCursorPos point
hwnd = WindowFromPoint(point.x, point.y) '获得鼠标下面的窗体的句柄
TechnoFantasy 2002-03-30
  • 打赏
  • 举报
回复
你说的是IE内的工具栏这样控件还是页面里面的控件,如果是后者可能无法获得,如果是前者,理论上获得窗口局柄就可以获得里面的控件的局柄,不过我没有试过在IE中的编程
kwxx 2002-03-30
  • 打赏
  • 举报
回复
可以取得窗口内的一个控件的HWND是吗??

谢谢了
TechnoFantasy 2002-03-30
  • 打赏
  • 举报
回复
sonicdater(发呆呆(我答问题*不吵架*因为我呆))
已经提供解决方法了:

Visual Basic developers can use the following code, which takes the HWND of the hosting form and examines all its children until it finds the window with a window class of "Shell Embedding". This is the topmost window of the WebBrowser control.

CAUTION: The Internet Explorer window class name may change in future browser versions. Use this workaround with care.
Option Explicit

Public Const GW_HWNDNEXT = 2
Public Const GW_CHILD = 5
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 Function GetBrowserWindow(hwndBrowserContainer As Long) As Long
Dim RetVal As Long
Dim Result As Long
Dim hwndChild, hwndPeer As Long
Dim ClassString As String * 256


hwndPeer = GetWindow(hwndBrowserContainer, GW_CHILD)
While (Result = 0) And (hwndPeer <> 0)
hwndPeer = GetWindow(hwndPeer, GW_HWNDNEXT)
RetVal = GetClassName(hwndPeer, ClassString, 256)
If hwndPeer <> 0 Then
RetVal = GetClassName(hwndPeer, ClassString, 256)
If Left$(ClassString, InStr(ClassString, Chr$(0)) - 1) = "Shell Embedding" Then
Result = 1
End If
End If
Wend

GetBrowserWindow = hwndChild
End Function
Please note that neither of these techniques are needed when you automate Internet Explorer. For automation, C++ and Visual Basic users can both use the HWND property of the InternetExplorer object.
kwxx 2002-03-30
  • 打赏
  • 举报
回复
那怎么办???

我需要HWND属性啊!!!
sonicdater 2002-03-30
  • 打赏
  • 举报
回复
WindowFromPoint
SetCursorPos
GetCursorPos
都是 win32 api .

你还是 照着 微软的 方法做吧
TechnoFantasy 2002-03-29
  • 打赏
  • 举报
回复
HWND是InternetExplorer对象属性
sonicdater 2002-03-29
  • 打赏
  • 举报
回复
Webbrowser Control 没有 Hwnd 属性 !!!
请看:
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reflist_vb.asp

另外, MSDN 上已有 这个问题的说明:

PRB: Obtaining the HWND for the WebBrowser Control (Q244310)
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q244310
TechnoFantasy 2002-03-29
  • 打赏
  • 举报
回复
你的IE版本是什么
happybeyond 2002-03-29
  • 打赏
  • 举报
回复
关注!
kwxx 2002-03-29
  • 打赏
  • 举报
回复
有什么代码???

一有关于它句柄的代码无论什么就出错啊!!!

例如a=WebBrowser1.Hwnd就OVER
sonicdater 2002-03-29
  • 打赏
  • 举报
回复
能把 代码帖出来吗?
zyl910 2002-03-29
  • 打赏
  • 举报
回复
关注!
内容概要:本文研究了基于多元宇宙优化算法(Multi-Verse Optimizer, MVO)在配电网与微电网中考虑价格型需求响应的优化调度问题。通过构建综合考虑电价引导下用户用电行为调整的数学模型,利用MVO算法对系统运行成本、负荷峰谷差、可再生能源消纳等多目标进行优化求解,有效提升了电网运行的经济性与稳定性。文中详细阐述了价格型需求响应机制的建模方法及其在负荷转移中的作用,并结合IEEE标准测试系统进行了仿真验证,结果表明所提方法能够显著改善负荷曲线,降低系统运行成本,提高能源利用效率。; 适合人群:具备一定电力系统基础知识和MATLAB编程能力,从事微电网优化、需求响应、智能配电网等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于含分布式能源的主动配电网与微电网协同优化调度;②实现基于电价信号的需求侧管理与负荷调控;③为电力系统经济调度、削峰填谷、提高新能源消纳能力提供算法支持与仿真验证方案; 阅读建议:本资源以Matlab代码实现为核心,建议读者结合算法原理与代码实现同步学习,重点关注目标函数构建、约束条件处理及MVO算法在电力系统优化中的具体应用方式,宜通过修改参数或拓展模型结构进行二次开发与创新研究。

743

社区成员

发帖
与我相关
我的任务
社区描述
VB 版八卦、闲侃,联络感情地盘,禁广告帖、作业帖
社区管理员
  • 非技术类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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