Post by wexhammer on Nov 25, 2019 15:12:06 GMT -5
Hello again, i have managed to make a bitmap toolbar, but i want to put my text box in the tool bar on the right hand side. Also my toolbar doesn't resize when my window is expanding, were am i going wrong in my code? I have been trying to get around this for over 3 hours now, and i'm having no luck. Please help!
[Initialize]
Nomainwin
GoSub [InitToolbar]
[GUI]
Stylebits #main.memo, _WS_VSCROLL, _ES_AUTOHSCROLL, _ES_MULTILINE, 0 '
Stylebits #main, 0,_WS_MAXIMIZEBOX,0,0
WindowWidth = 605 '595 695 795
WindowHeight = 600
UpperLeftX=Int((DisplayWidth-WindowWidth)/2)
UpperLeftY=Int((DisplayHeight-WindowHeight)/2)
'open the main window
textbox #main.filter, -400, 75, 285, 50
Open "Toolbar" For Window As #main
GoSub [MakeToolbar]
hMain=hwnd(#main)
CallDLL #user32, "GetMenu",hMain as uLong,hMenu as uLong
CallDLL #user32, "GetSubMenu",hMenu as uLong, 0 As Long, hSubMenu as uLong
flag = _MF_BYPOSITION OR _MF_DISABLED OR _MF_GRAYED
CallDLL #user32, "EnableMenuItem",hSubMenu as uLong, 1 As Long, flag As Long, re As Boolean
CallDLL #user32, "EnableMenuItem",hSubMenu as uLong, 2 As Long, flag As Long, re As Boolean
[Code]
[inputLoop]
Wait
[quit]
end
Sub combo1Click handle$
#handle$ "selection? Selected$"
End Sub
[InitToolbar]
'call this sub before opening window like this:
'GoSub [InitToolbar]
'hidden buttons used by toolbar code:
Button #main.hide0, "", addRecord, UL, -400, -400, 0, 0
Button #main.hide1, "", acceptEntry, UL, -400, -400, 0, 0
Button #main.hide2, "", [history], UL, -400, -400, 0, 0
Button #main.hide3, "", [refresh], UL, -400, -400, 0, 0
Button #main.hide4, "", [home], UL, -400, -400, 0, 0
Button #main.hide5, "", [separator5], UL, -400, -400, 0, 0
Button #main.hide6, "", [showfavorites], UL, -400, -400, 0, 0
Button #main.hide7, "", [history], UL, -400, -400, 0, 0
Button #main.hide8, "", [search], UL, -400, -400, 0, 0
Button #main.hide9, "", [separator9], UL, -400, -400, 0, 0
Button #main.hide10, "", [email], UL, -400, -400, 0, 0
'Combobox #main.filter, stage$(, loadNamesFiltered, -400, -400, 0, 0
textbox #main.filter, -400, 75, 285, 50
RETURN
[MakeToolbar]
hMain = Hwnd(#main) 'get window handle
struct TBADDBITMAP, hInst as long, nID As Long
struct TBBUTTON,_
bmpID as long,_ 'index of bitmap
cID as long,_ 'command ID
StateStyle as word,_ 'button state + style
dwData as long,_ 'not used
Str As Long 'not used
struct rect, left as long, top as long, right as long, bottom As Long
struct toolinfo, cbSize as long,_
uFlags as long, hwnd as long,_
uId as long, left as long, top as long,_
right as long, bottom as long, _
hInst as long, lpstrText$ as ptr
TB.ADDBUTTONS = 1044 : TB.AUTOSIZE = 1057
TB.SETTOOLTIPS = 1060 : TBSTYLE.BUTN = 0
TBSTYLE.SEP = 1 : TBSTYLE.FLAT = 2048
TBSTYLE.TOOLTIPS = 256: TBSTYLE.WRAPABLE = 512
TB.ADDBITMAP = 1043 : TB.BUTTONCOUNT = 1048
TB.GETBUTTON = 1047 : TB.GETITEMRECT = 1053
TBSTATE.ENABLED = 4 : TBSTATE.INDETERMINATE = 16
calldll #comctl32, "InitCommonControls", r As void
hbmpTools=LoadBitmapSystemColors("menu.bmp")
if hbmpTools=0 then
notice "Error loading bitmap!"
Return
end if
hID0 = GetWindowLong(hWnd(#main.hide0),_GWL_ID)
hID1 = GetWindowLong(hWnd(#main.hide1),_GWL_ID)
hID2 = GetWindowLong(hWnd(#main.hide2),_GWL_ID)
hID3 = GetWindowLong(hWnd(#main.hide3),_GWL_ID)
hID4 = GetWindowLong(hWnd(#main.hide4),_GWL_ID)
hID5 = GetWindowLong(hWnd(#main.hide5),_GWL_ID)
hID6 = GetWindowLong(hWnd(#main.hide6),_GWL_ID)
hID7 = GetWindowLong(hWnd(#main.hide7),_GWL_ID)
hID8 = GetWindowLong(hWnd(#main.hide8),_GWL_ID)
hID9 = GetWindowLong(hWnd(#main.hide9),_GWL_ID)
hID10 = GetWindowLong(hWnd(#main.hide10),_GWL_ID)
hID11 = GetWindowLong(hWnd(#main.filter),_GWL_ID)
style=_WS_CHILD Or _WS_VISIBLE Or TBSTYLE.TOOLTIPS Or TBSTYLE.WRAPABLE _
Or TBSTYLE.FLAT Or _WS_BORDER
uStructSize = Len(TBBUTTON.struct)
CallDLL #comctl32, "CreateToolbarEx",_
hMain As long,_ 'parent handle
style As long,_ 'window style flags
0 As long,_ 'ID
0 As long,_ 'number of Bitmaps
0 As long,_ 'hBMInst-not used
0 As long,_ 'bitmap handle
0 As long,_ 'toolbar button struct
0 As long,_ 'number of buttons to start
0 As long,_ 'width buttons
0 As long,_ 'height buttons
0 As long,_ 'width bitmaps for buttons - Can use 0 for default of 16.
0 As long,_ 'height bitmaps for buttons - Can use 0 for default of 16.
uStructSize As long,_
hTB As uLong 'handle to toolbar
'add the bitmap to the toolbar
TBADDBITMAP.hInst.struct = 0
TBADDBITMAP.nID.struct = hbmpTools
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBITMAP as long, 1 as long, TBADDBITMAP as struct, TBaddbmp as long
'add the buttons
'add button
TBBUTTON.cID.struct = hID0 'button ID
TBBUTTON.bmpID.struct = 0 'index of image on bitmap
TBBUTTON.StateStyle.struct = TBSTATE.ENABLED + (256 * TBSTYLE.BUTN)'disable back button to start
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add button
TBBUTTON.cID.struct = hID1 'button ID
TBBUTTON.bmpID.struct = 1 'index of image on bitmap
TBBUTTON.StateStyle.struct = TBSTATE.ENABLED + (256 * TBSTYLE.BUTN)'disable forward button to start
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add button
TBBUTTON.cID.struct = hID2 'button ID
TBBUTTON.bmpID.struct = 2 'index of image on bitmap
TBBUTTON.StateStyle.struct = TBSTATE.ENABLED + (256 * TBSTYLE.BUTN)
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add button
TBBUTTON.cID.struct = hID3 'button ID
TBBUTTON.bmpID.struct = 3 'index of image on bitmap
TBBUTTON.StateStyle.struct = 0 + (256 * TBSTYLE.BUTN)
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add button
TBBUTTON.cID.struct = hID4 'button ID
TBBUTTON.bmpID.struct = 4 'index of image on bitmap
TBBUTTON.StateStyle.struct = 0 + (256 * TBSTYLE.BUTN)
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add separator
TBBUTTON.cID.struct = 0 'ID = 0 for separator
TBBUTTON.bmpID.struct = 8 '8 pixels wide
TBBUTTON.StateStyle.struct = TBSTATE.INDETERMINATE + (256 * TBSTYLE.SEP )
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add button
TBBUTTON.cID.struct = hID6 'button ID
TBBUTTON.bmpID.struct = 6 'index of image on bitmap
TBBUTTON.StateStyle.struct = TBSTATE.ENABLED + (256 * TBSTYLE.BUTN)
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add button
TBBUTTON.cID.struct = hID7 'button ID
TBBUTTON.bmpID.struct = 7 'index of image on bitmap
TBBUTTON.StateStyle.struct = TBSTATE.ENABLED + (256 * TBSTYLE.BUTN)
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add separator
TBBUTTON.cID.struct = 0 'ID = 0 for separator
TBBUTTON.bmpID.struct = 8 '8 pixels wide
TBBUTTON.StateStyle.struct = TBSTATE.INDETERMINATE + (256 * TBSTYLE.SEP )
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add button
TBBUTTON.cID.struct = hID8 'button ID
TBBUTTON.bmpID.struct = 8 'index of image on bitmap
TBBUTTON.StateStyle.struct = TBSTATE.ENABLED + (256 * TBSTYLE.BUTN)
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add separator
TBBUTTON.cID.struct = 0 'ID = 0 for separator
TBBUTTON.bmpID.struct = 8 '8 pixels wide
TBBUTTON.StateStyle.struct = TBSTATE.INDETERMINATE + (256 * TBSTYLE.SEP )
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
'add button
TBBUTTON.cID.struct = hID10 'button ID
TBBUTTON.bmpID.struct = 10 'index of image on bitmap
TBBUTTON.StateStyle.struct = 0 + (256 * TBSTYLE.BUTN)
calldll #user32, "SendMessageA", hTB as uLong, _
TB.ADDBUTTONS as long, 1 as long, TBBUTTON as struct, r as long
gosub [AddTooltips]
RETURN
[AddTooltips]
TTS.ALWAYSTIP = 1 : TTS.NOPREFIX = 2
TTF.SUBCLASS = 16 : TTM.ADDTOOL = 1028
style = _WS_POPUP or TTS.NOPREFIX or TTS.ALWAYSTIP
hInstance = GetWindowLong(hMain,_GWL_HINSTANCE)
calldll #user32, "CreateWindowExA",_
_WS_EX_TOPMOST as long,_
"TOOLTIPS_CLASS32" as ptr,_
"" as ptr, style as long,_
_CW_USEDEFAULT as long,_CW_USEDEFAULT as long,_
_CW_USEDEFAULT as long,_CW_USEDEFAULT as long,_
hMain as long, 0 as long, hInstance as long,_
0 as long,hwndTip as uLong
toolinfo.cbSize.struct = Len(toolinfo.struct)
toolinfo.uFlags.struct = TTF.SUBCLASS
toolinfo.hwnd.struct = hTB
'tooltip for button index 0
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 0 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "A"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
'tooltip for button index 1
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 1 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "B"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
'tooltip for button index 2
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 2 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "C"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
'tooltip for button index 3
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 3 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "D"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
'tooltip for button index 4
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 4 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "E"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
'tooltip for button index 6
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 6 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "F"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
'tooltip for button index 7
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 7 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "G"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
'tooltip for button index 8
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 8 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "H"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
'tooltip for button index 10
calldll #user32, "SendMessageA", hTB as uLong, _
TB.GETITEMRECT as long, 10 as long, rect as struct, r as long
gosub [assignTooltipRect]
toolinfo.lpstrText$.struct = "I"
calldll #user32, "SendMessageA", hwndTip as uLong, _
TTM.ADDTOOL as long, 0 as long, toolinfo as struct, r as long
RETURN
[assignTooltipRect]
toolinfo.left.struct = rect.left.struct
toolinfo.top.struct = rect.top.struct
toolinfo.right.struct = rect.right.struct
toolinfo.bottom.struct = rect.bottom.struct
Return
Function SendMessage(hWin, msg, wParam, lParam)
calldll #user32, "SendMessageA", hWin As uLong, msg As long, _
wParam As long, lParam As long, SendMessage As long
End Function
Function GetWindowLong(hWin, type)
calldll #user32, "GetWindowLongA",_
hWin As uLong,type As long,_
GetWindowLong As Long
End Function
Function LoadBitmapSystemColors(bmp$)
flags=_LR_LOADFROMFILE or _LR_LOADMAP3DCOLORS
calldll #user32, "LoadImageA",_
0 as long, bmp$ as ptr, _IMAGE_BITMAP as ulong,_
0 as long, 0 as long, flags as long,_
LoadBitmapSystemColors As ulong
End Function