File: w_toolbar.srw
Size: 3549
Date: Fri, 05 Feb 2021 19:49:34 +0100
$PBExportHeader$w_toolbar.srw
forward
global type w_toolbar from window
end type
type cbx_bigbuttons from checkbox within w_toolbar
end type
end forward

global type w_toolbar from window
integer width = 402
integer height = 92
boolean border = false
windowtype windowtype = child!
long backcolor = 67108864
cbx_bigbuttons cbx_bigbuttons
end type
global w_toolbar w_toolbar

type prototypes
Function long GetClassName ( &
   longptr hWnd, &
   Ref string lpClassName, &
   long nMaxCount &
   ) Library "user32.dll" Alias For "GetClassNameW"

Function longptr GetWindow ( &
   longptr hWnd, &
   ulong uCmd &
   ) Library "user32.dll"

Function longptr SetParent ( &
   longptr hWndChild, &
   longptr hWndNewParent &
   ) Library "user32.dll"

Function long GetSystemMetrics ( &
   long nIndex &
   ) Library "user32.dll"

end prototypes

type variables
String is_classname

end variables

forward prototypes
public subroutine wf_reposition ()
public subroutine wf_setparent ()
end prototypes

public subroutine wf_reposition ();CONSTANT Integer SM_CXBORDER = 5
Integer li_pixels, li_pbunits, li_offset

choose case gw_frame.ToolbarAlignment
   case AlignAtTop!, AlignAtBottom!
      li_pixels  = GetSystemMetrics(SM_CXBORDER)
      li_pbunits = PixelsToUnits(li_pixels, XPixelsToUnits!)
      li_offset  = 60 + li_pbunits
      this.x = gw_frame.width - (this.width + li_offset)
      this.y = 8
   case AlignAtLeft!, AlignAtRight!
      this.x = 6
      this.y = gw_frame.height - (this.height + 300)
end choose

end subroutine

public subroutine wf_setparent ();String ls_name
LongPtr ll_hWnd
Integer li_rc

// find the microhelp handle
ll_hWnd = GetWindow(Handle(gw_frame), 5)
DO UNTIL ll_hWnd = 0
   ls_name = Space(25)
   li_rc = GetClassName(ll_hWnd, ls_name, Len(ls_name))
   If ls_name = is_classname Then
      ll_hWnd = SetParent(Handle(this), ll_hWnd)
      ll_hWnd = 0
   Else
      ll_hWnd = GetWindow(ll_hWnd, 2)
   End If
LOOP

end subroutine

on w_toolbar.create
this.cbx_bigbuttons=create cbx_bigbuttons
this.Control[]={this.cbx_bigbuttons}
end on

on w_toolbar.destroy
destroy(this.cbx_bigbuttons)
end on

event open;Environment le_env
Application la_app

GetEnvironment(le_env)
la_app = GetApplication()

this.height = 90
cbx_bigbuttons.checked = la_app.ToolbarText

// set object class name
choose case le_env.PBMajorRevision
   case 10, 11, 12, 17
      choose case le_env.PBMinorRevision
         case 5
            is_classname = "FNFIXEDBAR" + &
               String(le_env.PBMajorRevision) + "5"
         case 6
            is_classname = "FNFIXEDBAR" + &
               String(le_env.PBMajorRevision) + "6"
         case else
            is_classname = "FNFIXEDBAR" + String(le_env.PBMajorRevision * 10)
      end choose
   case 19
      If le_env.PBMinorRevision < 2 Then
         is_classname = "FNFIXEDBAR190"
      Else
         is_classname = "FNFIXEDBAR"
      End If
   case else
      is_classname = "FNFIXEDBAR"
end choose

// set parenthood
this.wf_setparent()

// position the window
this.wf_reposition()

end event

type cbx_bigbuttons from checkbox within w_toolbar
integer x = 9
integer y = 12
integer width = 370
integer height = 64
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "Big Buttons"
boolean lefttext = true
end type

event clicked;Application la_app

la_app = GetApplication()
la_app.ToolbarText = this.checked


end event