问题标签 [winapi]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
773 浏览

c - 虚拟 Listview 控件的(主)缓冲区中应该有多少行?

虚拟 Listview 控件的(主)缓冲区中应该有多少行?

我将纯“c”中的应用程序与 Win32 API 联系在一起。有一个到数据库的 ODBC 连接,它将检索项目(实际上是行)。

MSDN 示例代码暗示末端缓存有一个固定大小的 30 缓冲区(这几乎肯定不是最佳的)。我认为最终缓存和主缓存应该是相同的大小。

我的想法是缓冲区应该超过列表视图一次可以显示的最大项目数。我想这可以在每次调整 Listivew 大小时重新计算?

或者,使用较大的固定值是否更好。如果是这样,那价值是多少?

0 投票
2 回答
1825 浏览

c++ - 用于拖动拆分器的鼠标光标的 Win32 资源在哪里?

我正在构建一个自定义的 win32 控件/小部件,并希望在将光标悬停在控件中的特定垂直线上时将光标更改为水平“拆分器”符号。IE:我想左右拖动这条垂直线(分隔条)(WEST 和 EAST)。

在系统游标 (OCR_*) 中,唯一有意义的游标是 OCR_SIZEWE。不幸的是,这是系统在调整窗口大小时使用的又大又笨拙的光标。相反,我正在寻找大约 20 像素高、大约 3 或 4 像素宽的光标,两个小箭头指向左右。

我可以轻松地绘制它并将其作为资源包含在我的应用程序中,但光标本身非常普遍,我想确保它没有遗漏任何东西。

例如:当您使用 COM 拖放机制(CLSID_DragDropHelper、IDropTarget 等)时,您可以隐式访问“拖动”图标(指针下方的小框)。我没有看到这个人的显式 OCR_* 常量......同样,如果我不能完全找到这个拆分器光标,我想知道它是 COM 对象的一部分还是 win32 库中的其他东西。

0 投票
6 回答
10735 浏览

c# - 在不使用 windows 文件缓存的情况下复制文件

有人知道将文件从路径 A 复制到路径 B 并抑制 Windows 文件系统缓存的方法吗?
典型用途是将大文件从 USB 驱动器或服务器复制到本地计算机。如果文件非常大,例如 2GiB,Windows 似乎会交换所有内容。更喜欢 C# 中的示例,但我猜如果可能的话,这将是某种 Win32 调用。

0 投票
2 回答
8368 浏览

winapi - 如何以编程方式更改 Win32 对话框中的 Tab 键顺序?

在通过对话框模板和 CreateDialogIndirect 生成对话框后,我经常需要向对话框添加控件。在这些情况下,tab 顺序由对话框模板设置,并且没有明显的方法可以通过包含新创建的控件来更改 tab 顺序。

0 投票
3 回答
2698 浏览

windows - 在 Windows 上确定磁盘几何形状

我需要从 Windows XP 中以编程方式确定物理磁盘上有多少扇区、磁头和柱面。有谁知道用于确定这一点的 API?Windows 可能会在哪里公开此信息?

0 投票
5 回答
5726 浏览

winapi - Win32 List-View Control SubItem padding for custom-drawn SubItems?

When using custom-draw (NM_CUSTOMDRAW) to draw the entire contents of a ListView SubItem (in Report/Details view), it would be nice to be able to apply the same left and right padding in my custom paint method that is applied by the control itself for non-custom-drawn items.

Is there a way to programmatically retrieve this padding value? Is it related to the width of a particular character (" " or "w" or something?) or is it a fixed value (6px on left and 3px on right or something) or...?

EDIT: To clarify, I want to add the same padding to my NM_CUSTOMDRAWn SubItems that the control adds to items that it draws, and the metric that I'm looking for, for example, is the white space between the beginning of the 2nd column and the word "Siamese" in the following screenshot (Note: screenshot from MSDN added to help explain my question):

List View in Report View
(source: microsoft.com)

Note that the word "Siamese" is aligned with the header item ("Breed"). I would like to be able to guarantee the same alignment for custom-drawn items.

0 投票
2 回答
1957 浏览

windows - Win32 ToolTip disappears never to re-appear with Commctl 6

I'm creating a ToolTip window and adding tools to it using the flags TTF_IDISHWND | TTF_SUBCLASS. (c++, win32)

I have a manifest file such that my program uses the new WindowsXP themes (comctrl32 version 6).

When I hover over a registered tool, the tip appears.
Good.
When I click the mouse, the tip disappears.
Ok.
However, moving away from the tool and back again does not make the tip re-appear. I need to hover over a different tool and then come back to my tool to get the tip to come back.

When I remove my manifest file (to use the older non-XP comctrl32), the problem goes away.

After doing some experimentation, I discovered the following differences between ToolTips in Comctl32 version 5 (old) and Comctl32 version 6 (new):

  • New TTF_TRANSPARENT ToolTips (when used In-Place) actually return HTCLIENT from WM_NCITTEST if a mouse button is down, thus getting WM_LBUTTONDOWN and stealing focus for a moment before vanishing. This causes the application's border to flash.

  • Old TTF_TRANSPARENT ToolTips always return HTTRANSPARENT from WM_NCHITTEST, and thus never get WM_LBUTTONDOWN themselves and never steal focus. (This seems to be just aesthetic, but may impact the next point...)

  • New ToolTips seem not to get WM_TIMER events after a mouse-click, and only resume getting (a bunch of) timer events after being de-activated and re-activated. Thus, they do not re-display their tip window after a mouse click and release.

  • Old ToolTips get a WM_TIMER message as soon as the mouse is moved again after click/release, so they are ready to re-display their tip.

Thus, as a comctl32 workaround, I had to:

  • subclass the TOOLTIPS_CLASS window and always return HTTRANSPARENT from WM_NCHITTEST if the tool asked for transparency.

  • avoid using TTF_SUBCLASS and rather process the mouse messages myself so I could de-activate/re-activate upon receiving WM_xBUTTONUP.

I assume that the change in internal behavior was to accommodate the new "clickable" features in ToolTips like hyperlinks, but the hover behavior appears to be thus broken.

Does anyone know of a better solution than my subclass workaround? Am I missing some other point?

0 投票
3 回答
3851 浏览

windows - Why does clicking a child window not always bring the application to the foreground?

When an application is behind another applications and I click on my application's taskbar icon, I expect the entire application to come to the top of the z-order, even if an app-modal, WS_POPUP dialog box is open.

However, some of the time, for some of my (and others') dialog boxes, only the dialog box comes to the front; the rest of the application stays behind.

I've looked at Spy++ and for the ones that work correctly, I can see WM_WINDOWPOSCHANGING being sent to the dialog's parent. For the ones that leave the rest of the application behind, WM_WINDOWPOSCHANGING is not being sent to the dialog's parent.

I have an example where one dialog usually brings the whole app with it and the other does not. Both the working dialog box and the non-working dialog box have the same window style, substyle, parent, owner, ontogeny.

In short, both are WS_POPUPWINDOW windows created with DialogBoxParam(), having passed in identical HWNDs as the third argument.

Has anyone else noticed this behavioral oddity in Windows programs? What messages does the TaskBar send to the application when I click its button? Who's responsibility is it to ensure that all of the application's windows come to the foreground?

In my case the base parentage is an MDI frame...does that factor in somehow?

0 投票
2 回答
3272 浏览

winapi - GDI 和 GDI+ 中的多边形填充模式

当前设备上下文中的系统默认多边形填充模式是ALTERNATE(正如我从 Petzold 关于 Windows 编程的书中了解到的那样),并且这个Polygon模式用于 Win32 函数,除非您使用SetPolyFillMode.

我的问题是:GDI+ Graphics::FillPolygonFillMode在其签名中没有参数)方法是否也使用当前设备上下文填充模式或设置众所周知的默认值,然后在调用它之前设置回模式集?

谢谢!

0 投票
5 回答
25894 浏览

winapi - Vista BEX 错误

最近,我在加载 jar 时(大概)让 IE7 在 Vista 上崩溃,并出现以下错误:

谷歌搜索发现这类问题在Vista中 常见 并且与Java有关(尽管 SUN否定了)。我也认为这与DEP有关。我没有找到官方的 Microsoft Kb。

所以,问题是:

  • BEX 代表什么?
  • 它是关于什么的?
  • 如何处理此类错误?