Is it possible to make multilevel submenues with CB of the kind shown in attached picture?
Have tried several way to do it, but only achieves kind of nested submenues. Any suggestions??
Egil
I think yes...
I currently work on ABasic menus and use APi functions for menus....
Oups...i completly forget ::)
There is no need for Api just look into CBasic example draw.cba
under menu ->Option ->Line size -> checked
The problem with draw is that it only shows 1 level of sub menu, which is pretty straight forward once you know to use the "^".
I don't use CBasic but this is what I figured out.
There doesn't appear to be a clean way to return cleanly from 2 levels down (as your screenshot suggests).
The "^" moves you back up one level on and I couldn't find any way to move two levels at once and not display something.
The following example uses a separator in M8$ and m9$ to backup
If you change those two to "^I,,0,0" a blank area will be printed.
def win:window
run = 0
window win,0,0,640,400,@SIZE|@MINBOX|@MAXBOX,0,"submenu test",mainwindow
m1$="T,File,0,0"
m2$= "S,New,0,0"
m3$= "S,File,0,2"
m4$= "I,Type 1,0,20"
m5$= "S,Type 2,0,21"
m6$= "I,English,0,22"
m7$= "I,Spanish,0,23"
m8$= "^I,-,0,0"
m9$= "^I,-,0,0"
m10$= "^I,Open,0,8"
m11$= "I,Close,0,9"
m12$= "I,Save,0,11"
m13$= "I,Save As,0,12"
m14$= "I,-,0,0"
m15$= "I,Options,0,14"
m16$= "I,-,0,0"
m17$= "I,Exit,0,1"
MENU win,m1$,m2$,m3$,m4$,m5$,m6$,m7$,m8$,m9$,m10$,m11$,m12$,m13$,m14$,m15$,m16$,m17$
run = 1
waituntil run=0
closewindow win
end
sub mainwindow
select @CLASS
case @IDCLOSEWINDOW
run = 0
case @IDMENUPICK
select @MENUNUM
case 1
run = 0
endselect
case @IDCREATE
centerwindow win
endselect
return
I know it can be done with API's cleanly.
Looking at this makes me appreciate the available menu commands in IWBasic.
Both in syntax and capability.
LarryMc
Did some more looking.
You can do it by using resources.
From main menu pick Resources/Add
dialog pick menu
enter menu code that looks like this
QuoteBEGIN
POPUP "&File"
BEGIN
MENUITEM "&New\tCtrl+N", 2025
MENUITEM "&Open...\tCtrl+O", 2026
POPUP "&Test"
BEGIN
MENUITEM "&New\tCtrl+N", 2035
MENUITEM "&Open...\tCtrl+O", 2036
POPUP "&Test2"
BEGIN
MENUITEM "&New\tCtrl+N", 2035
MENUITEM "&Open...\tCtrl+O", 2036
END
END
MENUITEM SEPARATOR
MENUITEM "P&rint Setup...", 2027
MENUITEM SEPARATOR
MENUITEM "Recent File", 2028
MENUITEM SEPARATOR
MENUITEM "E&xit", 2029
END
POPUP "&Help"
BEGIN
MENUITEM "&About ChartCraft...", 2030
END
END
give it a number; I gave mine 42.
Save it.
In main code add this after window is created
LOADMENU(win, 42)in place of your menu command
then compile to exe file and run and your menu will appear.
KICKER - you can't run your program from the IDE and see the menu
That;s because the resource file is compiled into the exe file to be used.
LarryMc
Thanks a lot guys!
I hoped to avoid API calls, and I think LarryMc's example solves my problem. Cant remember to have seen that "^" trick anywhere before. I have tried several variations of the draw.cba example, but never got the result I want.
What I am trying to do, is producing an options menu for a simple communications program. There I need to have a second level of submenues to select comport number and baud rates etc. Think having Larry's example as a template, will solve my probldem. I'll post the complete code when I get a working program.
@LarryMc:
I quite agree on your thoughts about using IWB. But at the moment I use CB only, just to get aquainted with the Windows "blessings". And I frankly beleive that sticking to CB at present, will bring me faster to an understandig of the basics. As I already have found that by carefully declare and define my "masterpieces", I am able to use the same routines with only slight adjustments in IWB code. In addition my grandson downloaded the free version ov CB a while ago. And guess it gives us both a kick to play with the same tools... He just started out learning english in school, but I guess that at the end of this year he will take part in the discussions on this forum.... IF he still takes an interrest in programming. I really hope so! :D
The solution you came up with when I was writing this have to be studied before I can comment on it...
Thank again guys,
Egil
Wasn't suggesting you change from you CB. Was just stating a personal opinion.
Here's the structure you describe:
def win:window
run = 0
window win,0,0,640,400,@SIZE|@MINBOX|@MAXBOX,0,"submenu test",mainwindow
m1$="T,File,0,0"
m2$= "S,New,0,0"
m3$= "I,File,0,2"
m4$= "I,Project,0,3"
m5$= "^I,Open,0,4"
m6$= "S,Close,0,5"
m7$= "I,Save,0,6"
m8$= "I,No Save,0,7"
m9$= "^I,Save,0,8"
m10$= "I,Save As,0,9"
m11$= "I,-,0,0"
m12$= "S,Options,0,10"
m13$= "I,Opt 1,0,11"
m14$= "I,Opt 2,0,12"
m15$= "^I,-,0,0"
m16$= "I,Exit,0,1"
MENU win,m1$,m2$,m3$,m4$,m5$,m6$,m7$,m8$,m9$,m10$,m11$,m12$,m13$,m14$,m15$,m16$
run = 1
waituntil run=0
closewindow win
end
sub mainwindow
select @CLASS
case @IDCLOSEWINDOW
run = 0
case @IDMENUPICK
select @MENUNUM
case 1
run = 0
endselect
case @IDCREATE
centerwindow win
endselect
return
LarryMc
Your example did exactly what i wanted to do Larry.
I modified it slightly, and up came the menu I wanted. I'll finsih the program tomorrow or sunday as I am busy tonight.
This is how my menues will appear:
def win:window
run = 0
window win,0,0,640,400,@SIZE|@MINBOX|@MAXBOX,0,"submenu test",mainwindow
' File menu
m0$="T,File,0,0"
m1$= "I,Save setup,0,1"
m2$= "I,Exit,0,2"
' Setup menu
m3$="T,Setup,0,0"
m4$= "S,Select Port,0,0"
m5$= "I,Com1,0,5"
m6$= "I,Com2,0,6"
m7$= "I,Com3,0,7"
m8$= "I,Com4,0,8"
m9$= "I,Com5,0,9"
m10$= "I,Com6,0,10"
m11$= "I,Com7,0,11"
m12$= "I,Com8,0,12"
m13$= "^S,Select baudrate,0,0"
m14$= "I, 110,0,14"
m15$= "I, 300,0,15"
m16$= "I, 600,0,16"
m17$= "I, 1200,0,17"
m18$= "I, 2400,0,18"
m19$= "I, 4800,0,19"
m20$= "I, 9600,0,20"
m21$= "I, 14400,0,21"
m22$= "I, 19200,0,22"
m23$= "I, 28800,0,23"
m24$= "I, 38400,0,24"
m25$= "I, 57500,0,25"
m26$= "I,115200,0,26"
m27$= "^S,Select Bits,0,0"
m28$= "I,7,0,28"
m29$= "I,8,0,29"
m30$= "^S,Select Parity,0,0"
m31$= "I,No,0,31"
m32$= "I,Odd,0,32"
m33$= "I,Even,0,33"
m34$= "^S,Select Stopbits,0,0"
m35$= "I,1,0,35"
m36$= "I,2,0,36"
m37$= "^S,Local Echo,0,0"
m38$= "I,On,0,38"
m39$= "I,Off,0,39"
' Help menu
m40$="T,Help,0,0"
m41$= "I,About,0,41"
m42$= "I,User manual,0,42"
MENU win,m0$,m1$,m2$,m3$,m4$,m5$,m6$,m7$,m8$,m9$,m10$,m11$,m12$,m13$,m14$,m15$,m16$,m17$,m18$,m19$,m20$,m21$,m22$,m23$,m24$,m25$,m26$,m27$,m28$,m29$,m30$,m31$,m32$,m33$,m34$,m35$,m36$,m37$,m38$,m39$,m40$,m41$,m42$
run = 1
waituntil run=0
closewindow win
end
sub mainwindow
select @CLASS
case @IDCLOSEWINDOW
run = 0
case @IDMENUPICK
select @MENUNUM
case 2
run = 0
endselect
case @IDCREATE
centerwindow win
endselect
return
The complete code will not be posted till LarryS has posted the modified comlib, as I think the code needs slight adjustments.
You write faster than me Larry!
And you must be reading my mind, as you came up with your last example when I posted the code above. There was a typo in that code, but that is now corrected.
Thanks again!
Egil
Quote from: LarryMc on January 28, 2011, 10:51:44 AM
Wasn't suggesting you change from you CB. Was just stating a personal opinion.
I allways appreciate your oppionion Larry, and I did NOT misunderstand you.
Frankly, I have done more work with IWB (or EB) than with CB. But I have found that using CB for testing out ideas, brings me faster to a solution working the way I want. And most of the time converting to IWB is what you "over there" would call "a piece of cake".
There is also another aspect to it. I am a radio amateur, and even though I have very nice high powered, factory made equipment, I tend to use my homebrew equipment more than the other. And the homebrew radios all have low power transmitters (milliwatts instead of a kilowatt, which is the maximum legal power in Norway). And it is very satisfying to see that I achieve excactly the same "mileage" with my low power gear as with the expencive state of the art factory made equipment.
I have some problems to express this in english (which for me is a foreign language), but I think you understand what I mean. (At least Graham will.... ;D)
Now I am going to watch the norwegian skiing champion on the telly...
Have fun!
Glad that scheme works for you. My brain gets confused switching between the two but thats just me. ;D
BTW, although I have never been a ham operator, 36 years ago I passed the tests and obtained my lifetime government license to repair any radio/tv transmitter. Back then they called it a 1st Class FCC license. Even made a living working on transmitting equipment for a while. Never got a ham license because back then you had to pass a morse code test and I never took the time to be good enough at it. But I did work on quite a bit of 2-meter and 6-meter equipment.
Back then I had all the equipment at my house to fix equipment: o-scope, signal generator, watt meter, SWR meter, frequency counter, tube tester, etc... I even use to be able to whistle at exactly 1000hz.
Sorry, enough rambling.
LarryMc
I have a very similar background, but I became a radio amateur first. And that convinced me to study electronics. Many years of servicing military communications equipment, and later over to weapons control systems. When I quit there, I went back to school to get first a bathelor degree and then a master in electronics engineering. Between the two periods I worked with a company that serviced navigational equipment and "intelligent" sensors on LPG tankers, and finally for a company that constructed and built SCADA systems. When I gave my office, planning to retire, I was persuaded by an old buddy to start teaching at a local navigational school, teaching communications (including statcom) and use and maintenance of electronic navigation equipment.
And now, beeing a full time retiree, i enjoy amateur radio, photography, fishing and finally trying to learn these wonderful languages on a hobby basis. I have found that learning is not as easy as it was in my younger days. So when you an another string on the forum said you had a "senior moment", I knew exactly what you ment.... But I'm having a lot of fun, at that's very important.... hehe. ;D
I have most of the equipment you list, except the tube tester. And after I bought a 2m FM-transceiver in Houston some years ago, I even learned to whistle exactly 1750HZ. (Thats the tone that opens the european repeaters, and in USA they use subaudible tones instead...)
Egil
I worked weapsons control systems on brand new F4-C's, then retrained to work onautopilots and compass systems, then a tad bit of ECM, TACAN; then retrained to work on Inertial Navigation computers and Terrain Following/Avoidence radar.
When I got out of the service the only job I could find at the time was working on 2-way radios(no previous experience) and traffic signals for the state of Texas. Then on to a commerical 2-way radio shop folloed by 25 years in a chemical plant with process control computers, PLCs, and saftey shutdown systems.
LarryMc