views:

289

answers:

2

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 
+6  A: 

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.

The decision to eschew the existing interface controls provided by the operating system creates a variety of problems. The decision not to provide a title bar, for example, resulted in the loss of the standard window management controls. Windows users will find the the player offers no visual indication as to how to move, minimize, or maximize the player window ...

Duncan Bayne
@Duncan, thanks for leaving the comment :) Well, I know it's not necessary to customize the title bar. But there're good tutorials on how to do it in C or C# etc. I was hoping there're also some Perl tutorials:)
Mike
@Mike - it's not just that it's *not necessary* - it's a *bad idea*. Look at it from the customer's perspective. Why is your choice of style for window decorations more important than their choice of OS, window manager, and theme?When I come across an app that behaves in a 'custom' fashion I actually feel an emotional reaction ... as though the developer is being rude to me.
Duncan Bayne
@Duncan, your explanation makes very good sense to me. Thanks! I'm beginning to be convinced that I'd better leave window decorations as they are. But I think I still should learn some Win32 API stuff. Maybe I don't have to do something but it's good to know how to do it, even for the pure fun :)
Mike
Duncan Bayne
A: 

so a guy asks how a title bar can be modified and your answer is that it shouldn't be modified to start with? give him a break... lol

mister shmister
A break? I thought I'd give him some sound advice instead.
Duncan Bayne