#Include "window9.bi"

#Define BCM_SETSHIELD &h160C
#Define BS_SPLITBUTTON &hc
#Define BS_DEFSPLITBUTTON &hd
#Define BS_COMMANDLINK &he
#Define BCN_DROPDOWN -1248
#Define BCM_SETNOTE &h1609 

Dim Shared As HMENU hMessages
Dim As WString Ptr Uni
Dim As Integer ev
Type NMBCDROPDOWN
	hdr As NMHDR
	rcButton As RECT
End Type


Function windowp(hwnd As HWND,mesg As UINT,wParam As WPARAM,lParam As LPARAM) As Integer
	Dim pDropDown As NMBCDROPDOWN Ptr = Cast(NMBCDROPDOWN Ptr,lParam)
	Dim pt As Point
	If Mesg = WM_NOTIFY Then
		If lParam<> 0 Then
			If pDropDown->hdr.code = BCN_DROPDOWN Then
					pt.x = pDropDown->rcButton.left
					pt.y = pDropDown->rcButton.bottom
					ClientToScreen(GadgetID(wParam), @pt)
					If wParam = 2 Then
						DisplayPopupMenu(hMessages, pt.x, pt.y)
					EndIf
			EndIf
		EndIf
	EndIf
	Return 0
End Function

OpenWindow("",200,200,200,170)
ButtonGadget(1,95,5,80,20,"admin")
ButtonGadget(2,5,5,85,20,"1_кнопка",BS_SPLITBUTTON)
ButtonGadget(3,7,50,170,70,"2_кнопка",BS_COMMANDLINK)
Uni = ASCIITOUTF("Командная кнопка")
SendMessage(GadgetID(3),BCM_SETNOTE,0,Cast(LPARAM,Uni))
hMessages=CreatePopMenu()
MenuItem(1,hMessages,"1 меню")
MenuItem(2,hMessages,"2 меню")
SendMessage(GadgetID(1),BCM_SETSHIELD,0,1)
SetWindowCallback(Cast(Integer,@windowp))
Do:Loop Until WaitEvent()= EventClose
DeAllocate(Uni)