怎样改变VB程序的窗口风格

怎样改变VB程序的窗口风格,第1张

想让VB拥有XP那样的视觉样式,先打迹行开记事本,把以下内容粘贴其中:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<assemblyIdentity

version="1.0.0.0"

processorArchitecture="X86"

name="vb"

type="win32"

/>

<description>VB</description>

<dependency>

<dependentAssembly>

<assemblyIdentity

type="win32"

name="Microsoft.Windows.Common-Controls"

version="6.0.0.0"

processorArchitecture="X86"

publicKeyToken="6595b64144ccf1df"

language="*"

/>

</dependentAssembly>

</dependency>

</assembly>

并将其保存在程序同目录下,保存为“你的程序名字.exe.Manifest”,启动后即可启动视觉样式。将此文件改名为vb6.exe.manifest,即可让VB实现视觉模式。

注意:如果是Vista系统必须在程序第一次启动前把该Manifest文件放到程序目录下,如果已经运行过此程序,则无效。

方法2:如何让程序不带 manifest 且 使用 XP 风格:

下载 类橘弊似 PE EXPLORER 、 ExeScope 的资源编辑类程序。

打圆州族开 PE EXPLORER,点击文件 -- 载入文件。选择你的EXE载入后,单击资源编辑器,也就是那个那个四个格子菱形的图标,再按下组合键 Shift+Ctrl+W 会出现XP风格向导。完成后,最后保存。

望采纳

桌面属性----外观------下拉菜单拦码选择轮御windows xp 样式

如还是不可以,

我的电脑右键-----属性------高级-----性能腊衡岩-----设置------调整为最佳外观

      private const int GWL_STYLE = (-16)

      private const int GWL_EXSTYLE = (-20)

      private const uint WS_EX_LAYERED = 0x80000

      private const uint WS_EX_TRANSPARENT = 0x20

      private const uint WS_THICKFRAME = 262144

      private const uint WS_BORDER = 8388608

    

/// <summary>使指定 「 <see cref="IntPtr"/>句柄窗体 边框样式变为无边框。</summary>

      public static uint 无边框窗体(IntPtr 句柄) {

          uint style = API_窗口.GetWindowLong(句柄, GWL_STYLE)

          style &= ~WS_BORDER

          style &= ~WS_THICKFRAME

          return API_窗口.SetWindowLong(句柄, GWL_STYLE, style)

      }

API窗口静态类

 游世     [DllImport("user32", EntryPoint = "SetWindowLong")]

      public static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong)

      [DllImport("user32", EntryPoint = "GetWindowLong")]

      public static extern uint GetWindowLong(IntPtr hwnd, int nIndex)

修改窗口位置

/// <summary>

      /// 设置窗体的位置和大小。

      /// </summary>

      /// <param name="hWnd"></param>

      /// <param name="hWndInsertAfter">用于标识在z-顺序的此 CWnd 对象之前的 CWnd 对象。

      /// <para></para>如果uFlags参数中设置了SWP_NOZORDER标记则本参数将被忽略。可为下列值之一:

      /// <para></para>HWND_BOTTOM:值为1,将窗体置于Z序的底部。如果参数hWnd标识了一个顶层窗体,则窗神丛肢体失去顶级位置,并且被置在其他窗体的底部。

      /// <para></para>HWND_NOTOPMOST:值为-2,将窗体置于所有非顶层窗体之上(即在所有顶层窗体之后)。如果窗体已经是非顶层窗体则该标志不起作用。

      /// <para></para>HWND_TOP:值为0,将窗体置于Z序的顶部。

      /// <para></para>HWND_TOPMOST:值为-1,将窗体置于所有非顶层窗体之上。即使窗体未被激活窗体也将保持顶级位置。</param>

      /// <param name="x">窗体新的x坐标。如hwnd是一个子窗体郑升,则x用父窗体的客户区坐标表示</param>

      /// <param name="y">窗体新的y坐标。如hwnd是一个子窗体,则y用父窗体的客户区坐标表示</param>

/// <param name="Width">指定新的窗体宽度</param>

/// <param name="Height">指定新的窗体高度</param>

      /// <param name="wFlags"></param>

      /// <returns></returns>

      [DllImport("user32.dll", CharSet = CharSet.Ansi, EntryPoint = "SetWindowPos")]

      public static extern int SetWindowPos(IntPtr hWnd, hWndInsertAfter hWndInsertAfter, int x, int y, int Width, int Height, wFlags wFlags)

      /// <summary>

      /// 调整指定 「 <see cref="IntPtr"/>句柄」 窗体的位置和尺寸。

      /// </summary>

      /// <param name="句柄">指定 「 <see cref="IntPtr"/>句柄」 窗体</param>

      /// <param name="x">横坐标</param>

      /// <param name="y">纵坐标</param>

      /// <param name="w">宽</param>

      /// <param name="h">高</param>

      public static int 调整窗体(IntPtr 句柄, int x, int y, int w, int h) {

          return API_窗口.SetWindowPos(句柄, 0, x, y, w, h, wFlags.SWP_NOZORDER)

      }

      /// <summary>

      /// 调整指定 「 <see cref="IntPtr"/>句柄」 窗体的位置。

      /// </summary>

      /// <param name="句柄">指定 「 <see cref="IntPtr"/>句柄」 窗体</param>

      /// <param name="x">横坐标</param>

      /// <param name="y">纵坐标</param>

      public static int 调整窗体位置(IntPtr 句柄, int x, int y) {

          return API_窗口.SetWindowPos(句柄, 0, x, y, 0, 0, wFlags.SWP_NOSIZE | wFlags.SWP_NOZORDER)

      }


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12416103.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存