Hello
Happy holidays to you...
Newcomer here and havin problem, sorry if this goes out to wrong message area. Reading and learning from here.
Well my problem is. Searching for WndProc menubar code. Found one but it puts error out in my system. Hopefully I got it here right.
Message area was so old it was not possible post it there.
ErrrorMessage from DBP is:
EXITFUNCTION and ENDFUNCTION must return the same data type at line 244.
I Put mark there in code if you like take a look
Thank you for an answer
Happy new year 2011
isse
ps. This is my first message here, sorry if this doubles out, but first one was gone out... and i don't know where
sync on
Global m_numberOfMenus as integer : m_numberOfMenus = 0
Global m_numberOfMenuItems as integer : m_numberOfMenuItems = 0
Global m_activeDropDownMenu as integer : m_activeDropDownMenu = 0
Global m_mouse_flag as integer : m_mouse_flag = 0
Global MENUCOLOR as dword
MENUCOLOR = rgb(180,180,180)
Global TEXTCOLOR as dword
TEXTCOLOR = rgb(0,0,0)
type dropDownMenuItemObject
menuNumber as integer
priority as integer
title as string
x1 as integer
y1 as integer
x2 as integer
y2 as integer
endtype
type dropDownMenuObject
number as integer
title as string
numberOfItems as integer
`dim item(0) as string
x1 as integer
y1 as integer
x2 as integer
y2 as integer
hide as boolean
width as integer
endtype
Global dim dropDownMenu(0) as dropDownMenuObject
Global dim dropDownMenuItem(0) as dropDownMenuItemObject
makeDropDownMenu(1, "File") : positionDropDownMenu(1, 100, 100)
makeDropDownMenu(2, "Edit") : positionDropDownMenu(2, 135, 200)
makeDropDownMenu(3, "Search") : positionDropDownMenu(3, 135, 250)
makeDropDownMenu(4, "View") : positionDropDownMenu(4, 35, 200)
makeDropDownMenu(5, "Compile"): positionDropDownMenu(5, 15, 250)
makeDropDownMenu(6, "Tools") :
rem ignores the positionDropDownMenu() and aligns all menus at
rem the top of the screen as any application would do
alignDropDownMenus(1,1)
`setDropDownMenuColor(1, rgb(155,0,0))
`setDropDownMenuColor(2, rgb(0,0,200))
`setDropDownMenuTextColor(2, rgb(255,255,255))
`hideDropDownMenu(5)
`showDropDownMenu(5)
addDropDownMenuItem(1, "New Project" , 1)
addDropDownMenuItem(1, "Open Project" , 2)
addDropDownMenuItem(1, "Open Source" , 3)
addDropDownMenuItem(1, "Reopen >" , 4)
addDropDownMenuItem(1, "Save Project" , 5)
addDropDownMenuItem(1, "Save Project As..." , 6)
addDropDownMenuItem(1, "Save Source" , 7)
addDropDownMenuItem(1, "Save Source As..." , 8)
addDropDownMenuItem(1, "Save all" , 9)
addDropDownMenuItem(1, "Close", 10)
addDropDownMenuItem(1, "Close All" , 11)
addDropDownMenuItem(1, "Print..." , 12)
addDropDownMenuItem(1, "Exit" , 13)
addDropDownMenuItem(2, "Undo " , 1)
addDropDownMenuItem(2, "Redo" , 2)
addDropDownMenuItem(2, "Cut" , 3)
addDropDownMenuItem(2, "Copy" , 4)
addDropDownMenuItem(2, "Paste" , 5)
addDropDownMenuItem(2, "Delete Block" , 6)
addDropDownMenuItem(2, "Select All" , 7)
addDropDownMenuItem(2, "Toggle Breakpoint" , 8)
addDropDownMenuItem(2, "Set Bookmark >" , 9)
thing$ = "Click a menu"
do
cls
`drawDropDownMenu(1)
`drawDropDownMenu(2)
`drawDropDownMenu(3)
`drawDropDownMenu(4)
`drawDropDownMenu(5)
drawDropDownMenus()
`if dropDownMenuListener() = 1 then thing$ = "File"
`if dropDownMenuListener() = 2 then thing$ = "Edit"
menuItem$ = dropDownMenuListener()
if menuItem$ <> "" then result$ = menuItem$
set cursor 0,420
ink rgb(255,255,255),0
print result$
print m_activeDropDownMenu
sync
loop
REM public function
REM Creates a new drop-down menu object
function makeDropdownMenu(menu_number as integer, menu_title$ as string)
array insert at bottom dropDownMenu(0)
inc m_numberOfMenus
dropDownMenu(m_numberOfMenus).title = menu_title$
dropDownMenu(m_numberOfMenus).number = menu_number
endfunction
REM public function
REM Adds an item to a drop-down menu
function addDropDownMenuItem(menu_number as integer, item_name$ as string, priority as integer)
inc m_numberOfMenuItems
index = getArrayElement(menu_number)
dropDownMenu(index).numberOfItems = dropDownMenu(index).numberOfItems + 1
array insert at bottom dropDownMenuItem(0)
dropDownMenuItem(m_numberOfMenuItems).menuNumber = menu_number
dropDownMenuItem(m_numberOfMenuItems).title = item_name$
dropDownMenuItem(m_numberOfMenuItems).priority = priority
dropDownMenuItem(m_numberOfMenuItems).x1 = dropDownMenu(index).x1
dropDownMenuItem(m_numberOfMenuItems).y1 = dropDownMenu(index).y1 + 14 * priority
dropDownMenuItem(m_numberOfMenuItems).x2 = dropDownMenu(index).x1 + (len(item_name$) * 8 + 3)
dropDownMenuItem(m_numberOfMenuItems).y2 = dropDownMenu(index).y2 + 14 * priority
if (dropDownMenuItem(m_numberOfMenuItems).x2 - dropDownMenuItem(m_numberOfMenuItems).x1) > dropDownMenu(index).width
dropDownMenu(index).width = dropDownMenuItem(m_numberOfMenuItems).x2 - dropDownMenuItem(m_numberOfMenuItems).x1
endif
endfunction
REM public function
REM Defines location of a drop-down menu
function positionDropDownMenu(menu_number as integer, x as integer, y as integer)
index = getArrayElement(menu_number)
dropDownMenu(index).x1 = x
dropDownMenu(index).y1 = y
dropDownMenu(index).x2 = x + (len(dropDownMenu(index).title) * 8 + 3)
dropDownMenu(index).y2 = y+14
endfunction
REM public function
REM Returns clicked menu item title
function dropDownMenuListener()
if mouseclick() = 0 then m_mouse_flag = 0
if m_activeDropDownMenu = 0 and m_mouse_flag = 0
index = 0
clickedItem$ = ""
while (index <= m_numberOfMenus)
inc index
if dropDownMenu(index).hide = 0
x1 = dropDownMenu(index).x1
y1 = dropDownMenu(index).y1
x2 = dropDownMenu(index).x2
y2 = dropDownMenu(index).y2
if mouseWithIn(x1, y1, x2, y2)
drawOutlineBox(x1, y1, x2, y2)
`setDropDownMenuColor(dropDownMenu(index).number, rgb(0,0,155))
if mouseclick() = 1 and dropDownMenu(index).numberOfItems > 0
m_activeDropDownMenu = dropDownMenu(index).number
m_mouse_flag = 1
`m_dropDownMenuActive = 1
exit
endif
else
`setDropDownMenuColor(dropDownMenu(index).number, rgb(200,200,200))
endif
endif
endwhile
else
clickedItem$ = ActiveDropDownMenuListener()
endif
endfunction clickedItem$
REM private function
REM handles active drop-down menu item list
REM Returns title of clicked menu item
function ActiveDropDownMenuListener()
if mouseclick() = 0 then m_mouse_flag = 0
if m_activeDropDownMenu > 0
index = 0
while (index <= m_numberOfMenus)
inc index
if dropDownMenu(index).hide = 0
x1 = dropDownMenu(index).x1
y1 = dropDownMenu(index).y1
x2 = dropDownMenu(index).x2
y2 = dropDownMenu(index).y2
if mouseWithIn(x1, y1, x2, y2)
if dropDownMenu(index).numberOfItems > 0
m_activeDropDownMenu = dropDownMenu(index).number
else
m_activeDropDownMenu = 0
endif
endif
if dropDownMenu(index).number = m_activeDropDownMenu then drawIndentedOutlineBox(x1, y1, x2, y2)
endif
endwhile
if m_activeDropDownMenu > 0
index = 0
while (index <= m_numberOfMenuItems)
inc index
if dropDownMenuitem(index).menuNumber = m_activeDropDownMenu
x1 = dropDownMenuItem(index).x1
y1 = dropDownMenuItem(index).y1
x2 = dropDownMenuItem(index).x2
y2 = dropDownMenuItem(index).y2
drawDropDownMenuItem(index)
if mouseWithIn(x1, y1, x2, y2)
drawIndentedOutlineBox(x1, y1, x2, y2)
if mouseclick()=1 and m_mouse_flag = 0
m_mouse_flag = 1
m_activeDropDownMenu = 0
exitfunction dropDownMenuitem(index).title
endif
endif
endif
endwhile
endif
if mouseclick()=1 and m_mouse_flag = 0
m_mouse_flag = 1
m_activeDropDownMenu = 0
endif
endif
endfunction ""
`MESSAGE HERE EXITFUNCTION and ENDFUNCTION must return the same data type at line 244.
REM public function
REM Draws all unhidden menus
function drawDropDownMenus()
index = 0
while (index <= m_numberOfMenus)
inc index
if dropDownMenu(index).hide = 0
drawDropDownMenu(dropDownMenu(index).number)
if dropDownMenu(index).number = m_activeDropDownMenu
rem draw menu item list
endif
endif
endwhile
endfunction
REM public function
REM Hides the drop-down menu from drawing procedures and actions
function hideDropDownMenu(menu_number as integer)
index = getArrayElement(menu_number)
dropDownMenu(index).hide = 1
endfunction
REM public function
REM Shows the drop-down menu for drawing procedures and actions
function showDropDownMenu(menu_number as integer)
index = getArrayElement(menu_number)
dropDownMenu(index).hide = 0
endfunction
REM public function
REM Sets the background color of the menu
function setDropDownMenuColor(menu_number as integer, color as dword)
index = getArrayElement(menu_number)
`dropDownMenu(index).backColor = color
endfunction
REM public function
REM Sets the text color of the menu
function setDropDownMenuTextColor(menu_number as integer, color as dword)
index = getArrayElement(menu_number)
`dropDownMenu(index).textColor = color
endfunction
REM public function
REM Aligns all drop-down menus on the given y-coordinate, and starting
REM at the given x-coordinate placing them one after another to the right
function alignDropDownMenus(x as integer, y as integer)
index = 0
y2 = y + 14
while (index <= m_numberOfMenus)
inc index
dropDownMenu(index).x1 = x
dropDownMenu(index).y1 = y
x = x + (len(dropDownMenu(index).title) * 8 + 3)
dropDownMenu(index).x2 = x
dropDownMenu(index).y2 = y2
inc x
endwhile
endfunction
REM public function
REM Same thing as alignDropDownMenus(), but centers the row of menus at the
REM x-coordinate given
function centerDropDownMenus(x as integer, y as integer)
endfunction
REM public function
REM Returns the given menu number's title as a string
function getDropDownMenuName(menu_number as integer)
index = getArrayElement(menu_number)
name$ = dropDownMenu(index).title
endfunction name$
REM private function
REM Returns the proper index number associated with the given menu number
function getArrayElement(menu_number as integer)
i = 0
menu_index = 0
while (i <= m_numberOfMenus)
if dropDownMenu(i).number = menu_number
menu_index = i
i = m_numberOfMenus+1
else
inc i
endif
endwhile
endfunction menu_index
REM private function
REM Draws a drop-down menu item
function drawDropDownMenuItem(iIndex as integer)
index = getArrayElement(dropDownMenuItem(iIndex).menuNumber)
x1 = dropDownMenuItem(iIndex).x1
y1 = dropDownMenuItem(iIndex).y1
x2 = dropDownMenuItem(iIndex).x2
y2 = dropDownMenuItem(iIndex).y2
ink MENUCOLOR, 0
box x1, y1, x1+dropDownMenu(index).width, y2
ink TEXTCOLOR, 0
text x1+1, y1, dropDownMenuItem(iIndex).title
endfunction
REM private function
REM Draws a drop-down menu object
function drawDropDownMenu(menu_number as integer)
index = getArrayElement(menu_number)
x1 = dropDownMenu(index).x1
y1 = dropDownMenu(index).y1
x2 = dropDownMenu(index).x2
y2 = dropDownMenu(index).y2
ink MENUCOLOR, 0
box x1, y1, x2, y2
ink TEXTCOLOR, 0
text x1+1, y1, dropDownMenu(index).title
endfunction
REM private function
REM Returns true if mouse is within the defined area
function mouseWithIn(x1 as integer, y1 as integer,x2 as integer, y2 as integer)
if mousex() > x1 and mousex() < x2 and mousey() > y1 and mousey() < y2 then exitfunction 1
endfunction 0
REM private function
REM draws a box outline
function drawOutlineBox(x1 as integer, y1 as integer, x2 as integer, y2 as integer)
ink rgb(255,255,255), 0
line x1,y1,x2,y1
line x1,y1,x1,y2
ink rgb(0,0,0), 0
line x1,y2-1,x2,y2-1
line x2-1,y1,x2-1,y2
endfunction
REM private function
REM draws an indented box outline
function drawIndentedOutlineBox(x1 as integer, y1 as integer, x2 as integer, y2 as integer)
ink rgb(0,0,0), 0
line x1,y1,x2,y1
line x1,y1,x1,y2
ink rgb(255,255,255), 0
line x1,y2-1,x2,y2-1
line x2-1,y1,x2-1,y2
endfunction
What a wonderful world this is for the newcomer