ShowWindow vs SWP_SHOWWINDOW vs WS_VISIBLE [英] ShowWindow vs SWP_SHOWWINDOW vs WS_VISIBLE

查看:32
本文介绍了ShowWindow vs SWP_SHOWWINDOW vs WS_VISIBLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下显示窗口的方法有什么区别:

What is the difference between the following methods of showing a window:

  • ShowWindow 函数.
  • 带有 SWP_SHOWWINDOW 标志的 SetWindowPos 函数.
  • SetWindowLong 函数和 WS_VISIBLE 添加到 GWL_STYLE.

还有其他方法吗?

推荐答案

我认为它们大致相同,但每个都有额外的功能:

I think that they are mostly the same, but with additional capabilities for each one:

  1. SetWindowLongWS_VISIBLE 添加到 GWL_STYLE 可能是最不有趣的:如果有一个函数可以完全执行什么操作,为什么还要搞乱样式位你需要.
  2. SetWindowPosSWP_SHOWWINDOW 可以让你在显示窗口的同时设置它的位置和大小,用一个原子操作,让没人-程序或用户 - 可能会看到可见-未移动或移动-不可见的窗口.
  3. ShowWindow 函数涉及很多魔法,尤其是在程序中第一次调用时.此外,它具有 SW_SHOWDEFAULT 标志,该标志很少使用,但不适用于任何其他方法,AFAIK.
  1. SetWindowLong with WS_VISIBLE added to GWL_STYLE is proably the least interesting: why mess with style bits if there is a function that does exactly what you need.
  2. SetWindowPos with SWP_SHOWWINDOW allows you to show the window and set its location and size at the same time, with a single atomic operation, so that no-one - program or user - may see the visible-unmoved or moved-invisible window.
  3. The ShowWindow function has a lot of magic involved, particularly the very first time it is called in a program. Additionaly, it has the SW_SHOWDEFAULT flag that is little used but not available to any other method, AFAIK.

还有其他方法可以使窗口可见.在我的脑海中:

There are other ways to make a window visible. From the top of my mind:

  1. 使用 WS_VISIBLE 标志集创建它.
  2. DeferWindowPosSetWindowPos 具有相同的标志.
  1. Create it with the WS_VISIBLE flag set.
  2. DeferWindowPos has the same flags than SetWindowPos.

这篇关于ShowWindow vs SWP_SHOWWINDOW vs WS_VISIBLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆