Post by ernie on Jul 22, 2020 16:45:13 GMT -5
Hello,
I've placed a graphic box to the right of a toolbar, used "flush", and half the graphic disappears on resize (moving it out of sight or minimize + maximize). The half of the graphic that disappears is on the same level as the toolbar; the part that remains is below the toolbar. The code is below.
I would really appreciate some help with this.
Thank you.
I've placed a graphic box to the right of a toolbar, used "flush", and half the graphic disappears on resize (moving it out of sight or minimize + maximize). The half of the graphic that disappears is on the same level as the toolbar; the part that remains is below the toolbar. The code is below.
I would really appreciate some help with this.
Thank you.
nomainwin
'Begin Toolbar Code ==============================================================
true = 1: false = 0
dim btnID(7)
Button #main.tbBtn0, "", [open], UL, 0, 0, 0, 0
Button #main.tbBtn1, "", [save], UL, 0, 0, 0, 0
Button #main.tbBtn2, "", [wipeAll], UL, 0, 0, 0, 0
Button #main.tbBtn3, "", [report], UL, 0, 0, 0, 0
Button #main.tbBtn4, "", [settings], UL, 0, 0, 0, 0
Button #main.tbBtn5, "", [manual], UL, 0, 0, 0, 0
Stylebits #main,0,_WS_VISIBLE,0,0 'Start with an invisible window
'End Toolbar Code ================================================================
Menu #main, "File", "New", [wipeAll], "Open", [open], "Save", [save], "Save As", [saveAs], "Open Data Directory", [openDataDirectory], "Exit", [quit]
Menu #main, "Report", "Create Report", [report]
Menu #main, "Settings", "Specify Settings", [settings]
Menu #main, "Help", "Manual", [manual], "Terms of Service", [termsOfService], "support", [support], "About", [about]
headingStyle$ = "!font arial 18"
subHeadingStyle$ = "!font arial 15"
'constants:
TCIF.TEXT = 1
TCIF.IMAGE = 2
TCS.MULTILINE = 512
TCM.INSERTITEMA = 4871
TCM.GETCURSEL = 4875
TCM.SETCURSEL = 4876
tabID = 1 'current tab
oldTab = 0 'previously selected tab
struct TCITEM,_
mask as ulong,_
dwState as ulong,_
dwStateMask as ulong,_
pszText$ as ptr,_
txtMax as long,_
iImage as long,_
lParam as long
calldll #comctl32, "InitCommonControls", ret as void 'initialize DLL
graphicbox #main.logo 1148, 4, 52, 52
stylebits #main.logo, 0,_WS_BORDER,0,0
stylebits #CurrentWindow$, 0, 0, _WS_EX_TOPMOST, 0
WindowWidth = 1356 'PLACE 1366 x 768
WindowHeight = 758 'PLACE
width = 1356 'area inside window
height = 758 'area inside window
UpperLeftX=int((DisplayWidth-WindowWidth)/2) + 35
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
open "Program" for window_nf as #main '_nf means window cannot be maximized
#main, "trapclose [quit]"
'START TOOLBAR CODE
if CreateImageGroup(hImgNormal, "IconsHot4.bmp", hImgHot, "hot.bmp", hImgDis, "IconsDial_134_disab.bmp", 22, 16) then 'orig 32 32
'Create toolbar
SeparatorPositions$ = "" 'no separators
TBSTYLE.FLAT = 2048
TBSTYLE.LIST = 4096
style = _WS_VISIBLE Or TBSTYLE.FLAT OR TBSTYLE.LIST 'no line beneath toolbar
hToolBar = CreateToolbar(Hwnd(#main), style, 6, SeparatorPositions$, _
Hwnd(#main.tbBtn0), 22, 16, hImgNormal, hImgHot, hImgDis) '<< toolbar icon w, icon h ? orig 32 32
If hToolBar Then
lbl$ = "Open" + chr$(0) + "Save" + chr$(0) + "Clear" + chr$(0) + "Report" + chr$(0) + "Settings" + chr$(0) + "Help"
Call AddTBlabels hToolBar, lbl$
End If
end if
#main, "Show" 'Show the window and trigger the resize event
'Store the 3 hidden button IDs to use with the TB.ENABLEBUTTON message.
'These were already assigned to the toolbar buttons in function CreateToolbar.
btn1.ID = Hwnd(#main.tbBtn0)
Calldll #user32, "GetWindowLongA", btn1.ID As Ulong, _GWL_ID As Long, IDX As Long
btnID(1) = IDX
btnID(2) = btnID(2) + 1
btnID(3) = btnID(3) + 1
btnID(4) = btnID(4) + 1
btnID(5) = btnID(5) + 1
btnID(6) = btnID(6) + 1
btnID(7) = btnID(7) + 1
'END TOOLBAR CODE
loadbmp "logo", "logo6.bmp"
#main.logo "\setfocus"
#main.logo, "down"
#main.logo, "drawbmp logo 0 0"
#main.logo, "flush"
#main.logo, "up"
#main, "resizehandler [ResizeStatus]"
wait
[ResizeStatus] 'Resize Main Window controls
#main "refresh" 'ret=SendMessage(hTB, TB.AUTOSIZE,0,0)
wait
[manual]
wait
[support]
wait
[about]'
wait
[waitHere] 'inactive switch
wait
[save]
wait
[saveAs]
wait
[quit]
close #main
end
[open]
wait
[wipeAll]
wait
sub DeleteObject hObject
calldll #gdi32, "DeleteObject",_
hObject as long,_
resultDO as long
end sub
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'TOOLBAR SUBS AND FUNCTIONS
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
[TOOLBAR_FUNCTIONS] 'TOOLBAR FUNCTIONS
Function CreateToolbar(hPar,style,btnCount,sep$,hFirstBtn,BtnWidth,BtnHeight,hILn,hILh,hILd)
Struct TBcodeRect,_
left As Long,_
top As Long,_
right As Long,_
bottom As Long
Struct TBcodeTBBUTTON,_
bmpID As Long,_
cID As Long,_
StateStyle As Word,_
pad12 As Word,_
dwData As Long,_
StrIdx As Long
TB.ADDBUTTONS = 1044
TBSTYLE.BUTN = 0
TBSTYLE.SEP = 1
TB.ENABLEBUTTON = 1025
TB.ADDBITMAP = 1043
TB.BUTTONCOUNT = 1048
TB.GETBUTTON = 1047
TB.GETITEMRECT = 1053
TBSTYLE.WRAPABLE = 512
TBSTYLE.FLAT = 2048
TB.AUTOSIZE = 1057
TBcodeTBBUTTON.dwData.struct = 0
TBcodeTBBUTTON.StrIdx.struct = 0
Calldll #comctl32, "InitCommonControls", r As Void
uStructSize = Len(TBcodeTBBUTTON.struct)
Calldll #comctl32, "CreateToolbarEx", hPar As Ulong, style As Long, _
0 As Long, 0 As Long, 0 As Long, 0 As Long, 0 As Long, 0 As Long, _
0 As Long, 0 As Long, BtnWidth As Long, BtnHeight As Long, _
uStructSize As Long, hTB As Ulong
'Add the image list(s) to the toolbar.
TB.SETIMAGELIST = _WM_USER + 48
Calldll #user32, "SendMessageA", hTB As Ulong, TB.SETIMAGELIST As Long, 0 As Long, _
hILn As Ulong, r As Long
TB.SETHOTIMAGELIST = _WM_USER + 52
Calldll #user32, "SendMessageA", hTB As Ulong, TB.SETHOTIMAGELIST As Long, 0 As Long, _
hILh As Ulong, r As Long
TB.SETDISABLEDIMAGELIST = _WM_USER + 54
Calldll #user32, "SendMessageA", hTB As Ulong, TB.SETDISABLEDIMAGELIST As Long, 0 As Long, _
hILd As Ulong, r As Long
'This is optional. Indent the toolbar 3 pixels from the left.
TB.SETINDENT = _WM_USER + 47
Calldll #user32, "SendMessageA", hTB As Ulong, TB.SETINDENT As Long, 3 As Long, _
0 As Long, r As Long
'Add the buttons.
Calldll #user32, "GetWindowLongA", hFirstBtn As Ulong, _GWL_ID As Long, hID0 As Long
For i = 0 To btnCount-1
TBcodeTBBUTTON.bmpID.struct = i
TBcodeTBBUTTON.StrIdx.struct = i
id2 = hID0 + i
TBcodeTBBUTTON.cID.struct = id2
Calldll #user32, "SendMessageA", hTB As Ulong, _
1044 As Long, 1 As Long, TBcodeTBBUTTON As Struct, r As Long
Next i
'Add any separators.
TBcodeTBBUTTON.bmpID.struct = 8 '= 8 pixels wide
TBcodeTBBUTTON.cID.struct = 0
TBcodeTBBUTTON.StateStyle.struct = 256 '( 0 + (1*256) ) State=0, Style=TBSTYLE.SEP=1
pos = -1
While pos <> 0
idx = idx + 1
pos = Val(Word$(sep$,idx))
If pos Then
Calldll #user32, "SendMessageA", hTB As Ulong, _
1045 As Long, pos As Long, TBcodeTBBUTTON As Struct, r As Long
end if
Wend
'Enable all of the buttons by default.
For ID = hID0 To hID0+btnCount-1
Calldll #user32, "SendMessageA", hTB As Ulong, _
TB.ENABLEBUTTON As Long, ID As Long, 1 As Long, r As Long
Next ID
CreateToolbar = hTB
End Function
Sub AddTBlabels hTB, labels$
Calldll #user32, "SendMessageA", hTB As Ulong, _
1052 As Long, 0 As Long, labels$ as ptr, r As Long
end sub
Function CreateImageGroup(byref hImgNormal, bmpNormal$, byref hImgHot, bmpHot$, byref hImgDis, bmpDis$, width, height)
'Creates up to 3 24-bit bitmap image lists for a toolbar
'Normal, hot, and disabled. Bitmaps must be files.
'A bitmap for the normal view is required. Hot and disabled bitmaps are optional.
for i = 1 to 3
select case i
case 1
if bmpNormal$ <> "" then
hImgNormal = ImageListCreate(bmpNormal$, width, height)
if not(hImgNormal) then exit function
end if
case 2
if bmpHot$ <> "" then
hImgHot = ImageListCreate(bmpHot$, width, height)
end if
case 3
if bmpDis$ <> "" then
hImgDis = ImageListCreate(bmpDis$, width, height)
end if
end select
next i
CreateImageGroup = 1
end function
function ImageListCreate(bmp$, wide, high)
'Create an image list for a 24 bit bitmap with a mask.
'The mask will be created for you by the image list and the number of button
'images will be inferred by the actual width of the bitmap.
Calldll #user32, "LoadImageA", 0 As Long, bmp$ As Ptr, _IMAGE_BITMAP As Ulong,_
0 As Long, 0 As Long, _LR_LOADFROMFILE As Long, hBmp As Ulong
If not(hBmp) then exit function
'(ILC_COLOR24 Or ILC_MASK) = 25
Calldll #comctl32, "ImageList_Create", wide As Long, high As Long, _
25 As Long, 0 As Long, 0 As Long, ImageListCreate As Ulong
if ImageListCreate then
'Specify the color to be masked.
mask = 1 'RGB(1,0,0). Not RGB(192,192,192)
' Add the bitmap to the imagelist.
Calldll #comctl32, "ImageList_AddMasked", ImageListCreate As Ulong, hBmp As Ulong, _
mask As Ulong, r As Long
Calldll #gdi32, "DeleteObject", hBmp As Ulong, r As Boolean
end if
end function