如何从 Perl 完全改变 Win32 标题栏的外观?
我正在学习使用 Win32::GUI 将 GUI 添加到我的 Perl 程序中。现在我可以使用以下内容更改 Win32 标题栏的图标:
$myicon = new Win32::GUI::Icon('myicon.ico');
$myclass=new Win32::GUI::Class(
-name=>'myclass',
-icon=>$myicon,
);
$mydialogbox = new Win32::GUI::DialogBox(
-name => 'mydialogbox',
-class => $myclass,
);
但是其他东西(例如背景颜色、最小化按钮的外观和感觉)又如何呢?
我用谷歌搜索了这个主题,发现了几篇可能相关的文章。他们谈论诸如非客户区绘画等内容,但代码片段似乎都是用 C 编写的,我对此不太熟悉。
我想知道这里是否有人可以分享一些用 Perl 编写的处理类似情况的代码片段?或者,是否有一个 Perl 模块可以帮助完成这项任务?
感谢您的任何指导:)
****更新1****
我可以先让标题栏消失,然后在原始标题栏所在的位置添加一个标签,然后添加一些其他按钮来最小化和关闭对象吗?
现在的问题是:当鼠标位于标签上时,如何移动 Window 对象?
****UPDATE2****
我发现了一些 VB 代码片段,它们应该能够完成我想要在 Perl 中完成的工作。有人可以帮我用 Win32::GUI 重写它们吗? 以下 VB 代码来自此处:
Option Explicit
' API functions
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
' Constants for above API calls
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Form_Load()
Dim retVal As Long
retVal = SetWindowText(Me.hwnd, Label1)
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
I'm learning to add GUI to my Perl program using Win32::GUI. Now I can change the icon of a Win32 title bar using something like:
$myicon = new Win32::GUI::Icon('myicon.ico');
$myclass=new Win32::GUI::Class(
-name=>'myclass',
-icon=>$myicon,
);
$mydialogbox = new Win32::GUI::DialogBox(
-name => 'mydialogbox',
-class => $myclass,
);
But what about the other stuff, say, the background color, the look and feel of the minimize button?
I googled the subject and found several possibly relevant articles. They talk about stuff like non client area paiting etc etc. but the code snippets seem to be all written in C, with which I don't have a good familiarity.
I was wondering if someone here could kindly share some code snippets written in Perl that deals with the similar situation? Or, is there, hopefully, a Perl module that can facilitate the task?
Thanks for any guidance :)
****UPDATE1****
Can I first make the title bar disappear and then add a label where the original title bar was and then add some other buttons to minimize and close the object?
Now the problem is: how can I move the Window object when my mouse is on the label?
****UPDATE2****
I've found some VB code snippets that are supposed to do the job I want to accomplish in Perl. Can someone kindly help me rewrite them in Win32::GUI?
The following VB code is from here:
Option Explicit
' API functions
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
' Constants for above API calls
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Form_Load()
Dim retVal As Long
retVal = SetWindowText(Me.hwnd, Label1)
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
窗口装饰由操作系统根据用户的喜好绘制。它们(理想情况下)在所有应用程序中都是标准化的,并且可以快速轻松地学习新应用程序。
此外,一些用户调整窗户装饰的外观以弥补视力不佳或旧设备等问题。
有一篇关于 UI 耻辱堂的 QuickTime 4.0 的优秀且非常重要的文章其中涉及一些细节,解释了为什么覆盖默认操作系统的外观和感觉很糟糕,以及它可能导致什么样的问题。
Window decorations are drawn by the operating system in accordance with the user's preferences. They are (ideally) standardised across all applications, and make it quick and easy to learn new applications.
Moreover, some users adjust the appearance of window decorations to compensate for problems including poor eyesight or old devices.
There is an excellent and remarkably critical writeup of QuickTime 4.0 on the UI Hall of Shame that goes into some detail, explaining why overriding the default operating system look and feel is bad, and what sort of problems it can cause.