Event ID: 10003

BUG: Word 2000 Version Key Doesn't Match Its Type Library Version

Article ID:249626
Last Review:March 14, 2001
Revision:1.0
This article was previously published under Q249626

SYMPTOMS

Traditionally, clients that support Object Linking and Embedding (OLE) can use both the TypeLib key and Version key in the registry (under the CLSID for an embeddable object) to locate the type library that describes the object and its methods.

In Word 2000, the value for the Version key does not match the version number of its type library. Consequently, clients that rely on this behavior may fail to identify the correct type library for Word 2000 when using the registry.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

The Word 2000 type library is an enhanced version of the 8.0 type library that shipped with Word 97. It has a version number of 8.1, and its location can be found in the registry under the key:
HKEY_CLASSES_ROOT/TypeLib/{00020905-0000-0000-C000-000000000046}/8.1
				
However, the Word Document object lists the TypeLib and Version as:
HKEY_CLASSES_ROOT/CLSID/{00020906-0000-0000-C000-000000000046}
...
TypeLib = "{00020905-0000-0000-C000-000000000046}"
Version = "9"
...
				
So, if you use these keys to to locate the type library in the registry, and/or use these keys to call the LoadRegTypeLib API, it will fail to find the library since the code will be asking for a non-existent registry key:
  HKEY_CLASSES_ROOT/TypeLib/{00020905-0000-0000-C000-000000000046}/9
				
Clients are advised to handle any missing entry in the registry as an unregistered type library. To get the type information for an OLE object that is not registered in the type library, clients can create an instance of the object and ask for its ITypeInfo using IDispatch::GetTypeInfo() or IProvideClassInfo::GetClassInfo().
从你的日志来看,问题已经不再是“事件不触发”,而是: ``` Mouse event triggered: 5.337708163502968 681.0617949703111 Mouse event triggered: 5.583661348550132 775.9095770171151 Mouse event triggered: 5.850110632351227 881.7013339154736 Mouse event triggered: 6.085815768021426 972.9011243450929 Mouse event triggered: None None Mouse outside axes ``` 说明: - **鼠标事件正常触发**; - **但有时 `event.xdata` 和 `event.ydata` 为 `None`,且 `event.inaxes` 为 `None`**; - **有时又正常有值**; - **tooltip 无法显示**。 --- ## ✅ 问题定位 ### ❌ 1. `event.xdata` 有时为 `None` 这是因为在 matplotlib 中,**当鼠标不在任何 axes 范围内时,`xdata` 和 `ydata` 为 `None`**。 ### ❌ 2. `event.inaxes is not self.ax` 判断成功 说明鼠标虽然在图表窗口内,但不在 `self.ax` 的绘图区域内(可能是坐标轴、边框、空白区域)。 --- ## ✅ 解决方案 ### ✅ 1. 优化 `event.inaxes` 判断逻辑 你可以: - **放宽判断**,允许鼠标在图表窗口内即可; - 或者 **获取当前所有 axes 并判断是否在其中**; - 或者 **只使用 `event.xdata` 和 `event.ydata` 是否为 None 来判断是否在图表区域内**。 ### ✅ 修改判断逻辑如下: ```python def on_mouse_move(self, event): print("Mouse event triggered:", event.xdata, event.ydata) # 如果 event.xdata 或 event.ydata 为 None,说明鼠标不在绘图区域 if event.xdata is None or event.ydata is None: print("Mouse not in plot area") if hasattr(self, 'tooltip') and self.tooltip is not None: self.tooltip.remove() self.tooltip = None self.canvas.draw_idle() return # 如果 self.line 不存在,直接返回 if self.line is None: print("self.line is None") return try: xdata = self.line.get_xdata() ydata = self.line.get_ydata() if len(xdata) == 0 or len(ydata) == 0: return # 计算距离 distances = [(x - event.xdata)**2 + (y - event.ydata)**2 for x, y in zip(xdata, ydata)] min_index = np.argmin(distances) min_distance = distances[min_index] threshold = 0.05 if min_distance < threshold: x = xdata[min_index] y = ydata[min_index] train_id = self.train_ids[min_index] selected_process = process_names[self.process_combo.currentIndex()] if selected_process == "发车总时间": total = sum(self.data[train_id]) text = f"车次: {train_id}\n总时间: {total:.0f} 分钟" else: selected_index = process_names.index(selected_process) value = self.data[train_id][selected_index] total = sum(self.data[train_id]) text = f"车次: {train_id}\n时间: {value:.0f} 分钟\n总时间: {total:.0f} 分钟" xlim = self.ax.get_xlim() ylim = self.ax.get_ylim() offset_x = 0.2 offset_y = 5 tooltip_x = event.xdata + offset_x tooltip_y = event.ydata + offset_y if tooltip_x > xlim[1]: tooltip_x = event.xdata - offset_x if tooltip_y > ylim[1]: tooltip_y = event.ydata - offset_y if hasattr(self, 'tooltip') and self.tooltip is not None: self.tooltip.remove() self.tooltip = self.ax.text( tooltip_x, tooltip_y, text, fontsize=10, verticalalignment='top', horizontalalignment='left', bbox=dict(boxstyle="round", facecolor="white", edgecolor="black", alpha=0.9), zorder=1000, clip_on=False ) self.canvas.draw_idle() else: if hasattr(self, 'tooltip') and self.tooltip is not None: self.tooltip.remove() self.tooltip = None self.canvas.draw_idle() except Exception as e: print("悬停提示出错:", e) ``` --- ## ✅ 补充建议 ### ✅ 打印所有 axes 查看结构 ```python print("All axes:", self.figure.axes) ``` ### ✅ 检查 `self.ax` 是否被多次创建 每次调用 `plot_selected()` 都会调用: ```python self.ax = self.figure.add_subplot(111) ``` 这会导致每次绘图都新建一个 axes,而旧的 axes 仍然存在,可能导致事件绑定错乱。 ### ✅ 修改建议:确保每次只保留一个 axes ```python self.figure.clear() self.ax = self.figure.add_subplot(111) ``` 这样每次绘图都会清空 figure,确保只有一个 axes。 --- ## ✅ 总结 | 问题 | 原因 | 解决方案 | |------|------|----------| | `event.xdata` 有时为 `None` | 鼠标不在绘图区域 | 用 `if event.xdata is None` 提前返回 | | `event.inaxes is not self.ax` | axes 对象不一致 | 改为基于 `xdata` 是否为 `None` 判断 | | 多个 axes 被创建 | 多次调用 `add_subplot` | 每次绘图前 `self.figure.clear()` | | tooltip 不显示 | 上述原因导致未进入 tooltip 创建逻辑 | 综合修复即可 | --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值