Page 1 of 1

TitleBarButton Library

Posted: Fri Dec 31, 2004 8:44 pm
by Dräc
Hi everybody,

You can find here the first version of a library called >TitleBarButton<, which offers adding and managing easily a new button to a window caption.
You can create your own button or use one of the two preset button functions available:
Rull-Up and Stay On Top functions

The actual big limitation of the library takes on than only one button can by add to the same window.

Nevertheless, source code is included and any suggestions, code advices and efforts are welcome.

The actual code version takes its inspiration into the jaPBe and TailBite source codes.
Thanks to their authors to have put them.

Thanks to the French forum too, for the beta test (One bug known on XPpro: button can disappear!! :? ).

Enjoy it!

Dräc.

Posted: Fri Dec 31, 2004 10:59 pm
by Wolf
Very nice thanks Dräc :D

Re: TitleBarButton Library

Posted: Sat Jan 01, 2005 12:05 am
by PB
Looks good, thanks Dräc! :)

Posted: Mon Jan 10, 2005 2:40 pm
by ebs
Drac,

That is really cool!

I found a problem with Windows XP (Home/Pro): The tooltips are not displayed on the new button. Has anyone else seen this?

Regards,
Eric

Posted: Mon Jan 10, 2005 8:08 pm
by Manne
Under WIN XP SP2 i get nor result for "GetTitleBarButtonState".
Anybody else with this problem?

greetz

Manne

Posted: Mon Jan 10, 2005 10:30 pm
by Dräc
@ebs: Normally it’s fixed with the new updated version 1.2.
You can download at the same address: >TitleBarButton v1.2<

@Manne: I’m surprised!
What does the following test code displayed on your debug window ?
Normally, you can check that the button state is well return by the GetTitleBarButtonState() function…

Code: Select all

; Title Bar Labrary validation test
Result=AddTitleBarButton(0,#True,  -1, -1, "BtnState1", "BtnState2")
Debug "AddTitleBarButton:" +Str(Result)
Result=GetTitleBarButtonState(0)
Debug "GetTitleBarButtonState:" +Str(Result)
Result=SetTitleBarButtonState(0,#True)
Debug "SetTitleBarButtonState:" +Str(Result)

; Test de get et set
#ToolWind_WIDTH = 150
#ToolWind_HEIGHT = 100
#ToolWindow=1

Procedure test(Param.l)
  state = GetTitleBarButtonState(Param)
  Repeat
  If GetTitleBarButtonState(Param)<>state
    state = GetTitleBarButtonState(Param)
    Debug state
  EndIf
  ForEver
EndProcedure

ToolWindowId= OpenWindow(#ToolWindow,10,20,#ToolWind_WIDTH,#ToolWind_HEIGHT, #PB_Window_SystemMenu | #PB_Window_SizeGadget |#PB_Window_ScreenCentered  , "ToolWindow", WindowId)
Result=AddStayOnTopButton(#ToolWindow, #False, -1, -1, "BtnState1", "BtnState2")
Debug "AddTitleBarButton:" +Str(Result)


SetTitleBarButtonState(#ToolWindow, #True)
Debug GetTitleBarButtonState(#ToolWindow)

Quit=#False
Repeat
  WndEvent = WaitWindowEvent()
  If WndEvent = #PB_Event_CloseWindow
    Select EventWindowID()
      Case #ToolWindow
        Quit =#True
    EndSelect
  EndIf

Until Quit

SetTitleBarButtonState(#ToolWindow, #False)
Debug GetTitleBarButtonState(#ToolWindow)

CreateThread(@test(), #ToolWindow)

 Quit=#False
  Repeat
    WndEvent = WaitWindowEvent()
    If WndEvent = #PB_Event_CloseWindow
      Select EventWindowID()
        Case #ToolWindow
          Quit =#True
      EndSelect
    EndIf
Until Quit

Posted: Tue Jan 11, 2005 2:35 am
by Manne
@Dräc

As of your code i get the following output.
AddTitleBarButton:0
GetTitleBarButtonState:-1
SetTitleBarButtonState:0
AddTitleBarButton:1
1
But if i click on the button during runtime the event would not be recognized and the result is still 1.
I'm using the latest PB 3.92 and WIN XP Pro SP2.

greetz

Manne

Posted: Tue Jan 11, 2005 2:31 pm
by ebs
Drac,

Thanks for the fast response. Version 1.2 fixes the tooltip problem.

I noticed one other odd thing: All titlebar buttons, even one that's supposed to be blank, have a small rectangular outline near the bottom. I don't have a place to post an image, but the buttons have a small rectangular outline just above the bottom edge, similar to the Windows Minimize button. This is in addition to any image that is supposed to be on the button.

Can you (or anyone else) reproduce this?

Regards,
Eric

Posted: Tue Jan 11, 2005 7:59 pm
by Dräc
@Manne: I forgot to inform you: The result you have is normal, you need to close the window once to pass at the following of the code, or take this one directly (where I’ve set lines into comments):

Code: Select all

; Title Bar Labrary validation test 
Result=AddTitleBarButton(0,#True,  -1, -1, "BtnState1", "BtnState2") 
Debug "AddTitleBarButton:" +Str(Result) 
Result=GetTitleBarButtonState(0) 
Debug "GetTitleBarButtonState:" +Str(Result) 
Result=SetTitleBarButtonState(0,#True) 
Debug "SetTitleBarButtonState:" +Str(Result) 

; Test de get et set 
#ToolWind_WIDTH = 150 
#ToolWind_HEIGHT = 100 
#ToolWindow=1 

Procedure test(Param.l) 
  state = GetTitleBarButtonState(Param) 
  Repeat 
    If GetTitleBarButtonState(Param)<>state 
      state = GetTitleBarButtonState(Param) 
      Debug state 
    EndIf 
  ForEver 
EndProcedure 

ToolWindowId= OpenWindow(#ToolWindow,10,20,#ToolWind_WIDTH,#ToolWind_HEIGHT, #PB_Window_SystemMenu | #PB_Window_SizeGadget |#PB_Window_ScreenCentered  , "ToolWindow", WindowId) 
Result=AddStayOnTopButton(#ToolWindow, #False, -1, -1, "BtnState1", "BtnState2") 
Debug "AddTitleBarButton:" +Str(Result) 


SetTitleBarButtonState(#ToolWindow, #True) 
Debug GetTitleBarButtonState(#ToolWindow) 

;Quit=#False 
;Repeat 
;  WndEvent = WaitWindowEvent() 
;  If WndEvent = #PB_Event_CloseWindow 
;    Select EventWindowID() 
;      Case #ToolWindow 
;        Quit =#True 
;    EndSelect 
;  EndIf 
  
;Until Quit 

SetTitleBarButtonState(#ToolWindow, #False) 
Debug GetTitleBarButtonState(#ToolWindow) 

CreateThread(@test(), #ToolWindow) 

Quit=#False 
Repeat 
  WndEvent = WaitWindowEvent() 
  If WndEvent = #PB_Event_CloseWindow 
    Select EventWindowID() 
      Case #ToolWindow 
        Quit =#True 
    EndSelect 
  EndIf 
Until Quit 

Posted: Tue Jan 11, 2005 8:23 pm
by Dräc
ebs wrote:Drac,

Thanks for the fast response. Version 1.2 fixes the tooltip problem.

I noticed one other odd thing: All titlebar buttons, even one that's supposed to be blank, have a small rectangular outline near the bottom. I don't have a place to post an image, but the buttons have a small rectangular outline just above the bottom edge, similar to the Windows Minimize button. This is in addition to any image that is supposed to be on the button.

Can you (or anyone else) reproduce this?

Regards,
Eric
This is completely nominal for the moment!
In fact, it’s because I build the blank button by erasing the Windows Minimize one, this to have a new button similar to the others.
If the copied button color is not equal to the background color referenced into system configuration settings, you can see the ruse.
I don’t know if a button template already exists into windows system but if someone knows, tell me!

Posted: Tue Jan 11, 2005 8:58 pm
by Dräc
I have found a way to improve the button building according to DrawFrameControl API function.
I’m afraid that will limit the appearance of the button to the only standard format…

Posted: Tue Jan 11, 2005 10:17 pm
by dracflamloc
NOOOOOOOOOOO, someone stoled my nickname!!! 8O

hehehe

Posted: Wed Jan 12, 2005 7:30 pm
by Dräc
@ebs : I improve the way of painting the button :)
You can download this at the same address (it’s still v1.2).

Does the results is correct on XP ?

Posted: Thu Jan 13, 2005 3:12 pm
by ebs
Drac,

The button paints correctly with the new version (no horizontal bar).

However, when a window is moved by dragging the titlebar, the standard buttons (minimize, maximize/restore, and close)
will change from the XP style back to the older "classic" windows style.

Is that what you were referring to in your earlier message?

Regards,
Eric

Posted: Fri Jan 14, 2005 8:26 pm
by Dräc
Actually, the library doesn’t manage the Windows XP theme and if you disable it (come back to windows standard look), all works well…