Coding

Welcome, Guest. Please login or register.
Did you miss your activation email?
August 19, 2017, 11:53:41 AM

Login with username, password and session length

Menu

Members
Stats
  • Total Posts: 12135
  • Total Topics: 1730
  • Online Today: 66
  • Online Ever: 195
  • (February 11, 2014, 12:46:08 PM)
Users Online
Users: 0
Guests: 35
Total: 55
Yahoo!
Sogou
Google
Baidu (17)

Recent Topics

Pages: [1]   Go Down

Author Topic: Menu Separator?  (Read 3405 times)

0 Members and 1 Guest are viewing this topic.

Pablo S

  • Newbie
  • *
  • Bananas: 0
  • Offline Offline
  • Gender: Male
  • Posts: 3
  • I haven't set any personal text yet
Menu Separator?
« on: January 29, 2015, 09:38:41 PM »

How using MENU and INSERTMENU statements can I add a menu separator?

Regards,

- Pablo
Logged

GWS

  • Moderator
  • Sr. Member
  • *****
  • Bananas: 14
  • Offline Offline
  • Posts: 342
Re: Menu Separator?
« Reply #1 on: January 30, 2015, 12:23:48 PM »

Hi Pablo,

Nice to see someone using Creative Basic - still one of the best languages. :)

For a separator, when you write your Insertmenu statement, just insert a minus sign ..
Code: [Select]
"I,-,0,0" in the string as in ..

Code: [Select]
insertmenu win,1,"T,Preferences,0,0","I,Speed,0,1","I,Tone,0,2","I,-,0,0","I,Morse Format,0,3"

Best wishes, :)

Graham

« Last Edit: January 30, 2015, 12:24:29 PM by GWS »
Logged
Tomorrow may be too late ...

Pablo S

  • Newbie
  • *
  • Bananas: 0
  • Offline Offline
  • Gender: Male
  • Posts: 3
  • I haven't set any personal text yet
Re: Menu Separator?
« Reply #2 on: January 30, 2015, 04:43:04 PM »

Hello,

Thanks for the info!.

Also how can I add a hotkey or shortcuts like so: "&New\tCtrl+N"?

What I want is to add Ctrl+N after New in the menu. I am using Windows 8.0 .

Best regards,

- Pablo
Logged

GWS

  • Moderator
  • Sr. Member
  • *****
  • Bananas: 14
  • Offline Offline
  • Posts: 342
Re: Menu Separator?
« Reply #3 on: January 30, 2015, 09:37:04 PM »

Hi Pablo,

Probably best to use an auxiliary statement in order to keep the statement lines short, such as :

Code: [Select]
a$ = "I,Speed..." + chr$(9) + "Ctrl S" + ",0,1"
insertmenu win,1,"T,Preferences,0,0",a$,"I,Tone,0,2","I,-,0,0","I,Morse Format,0,3"

or in your example :

Code: [Select]
a$ = "I,New..." + chr$(9) + "Ctrl N" + ",0,1"
menu win,"T,File,0,0",a$,"I,Exit,0,100"

Just remember that all command statements are processed as strings of characters, and can be manipulated as you would any strings in Basic.  :)

Best wishes, :)

Graham
« Last Edit: January 31, 2015, 08:22:23 PM by GWS »
Logged
Tomorrow may be too late ...

Pablo S

  • Newbie
  • *
  • Bananas: 0
  • Offline Offline
  • Gender: Male
  • Posts: 3
  • I haven't set any personal text yet
Re: Menu Separator?
« Reply #4 on: January 31, 2015, 08:42:35 PM »

Hello Graham,

Thank you very much for your help. Creative BASIC is a wonderful tool!

Have a nice day ;D,

- Pablo
Logged

GWS

  • Moderator
  • Sr. Member
  • *****
  • Bananas: 14
  • Offline Offline
  • Posts: 342
Re: Menu Separator?
« Reply #5 on: February 16, 2015, 07:42:25 PM »

You're welcome ..  :)

I'm surprised how many views this discussion has received, so here's a small example program using a menu separator ..

Code: [Select]
' Menu Separator Example ..
'
def w:window
def textWidth, textHeight, run : int
def a$ : string

autodefine "off"

window w,0,0,600,450,0,0," Menu Separator Example",messages
setwindowcolor w, rgb(60,130,90)
centerwindow w

control w, "B, Exit, (600 - 60) / 2, 350, 60, 30, 0, 1"
setcontrolcolor w,1,0,rgb(100,150,200)

' menu ..
menu w,"T,File,0,0","I,Open,0,1","I,Close,0,2","I,-1,0,0","I,Exit,0,100"

setfont w,"Times",25,600,@SFITALIC
frontpen w, RGB(210,210,210) :' light grey

a$ = "Welcome to Creative Basic"
gettextsize w, a$, textWidth, textHeight
move w,(600 - textwidth) / 2,150
print w,a$

run = 1
waituntil run = 0
closewindow w
end

sub messages
select @CLASS
case @IDCLOSEWINDOW
' close the window
run = 0
case @IDCHAR
' ESC(ape) key pressed will close the program ...
key = @CODE
if key = 27 then run = 0
case @IDCONTROL
select @CONTROLID
' Window Exit button ID 1 clicked ...
case 1
run = 0
endselect
case @idmenupick
select @menunum
case 100 :' Menu Exit button ID 100 clicked ...
run = 0
endselect
endselect
return


Sorry if the code formatting gets a bit squiffed by the SMF system  ::)

Best wishes, :)

Graham

Logged
Tomorrow may be too late ...

docmann

  • Newbie
  • *
  • Bananas: 3
  • Offline Offline
  • Gender: Male
  • Posts: 49
  • Yippeee! (Whew! ...sure glad I got over that)
Re: Menu Separator?
« Reply #6 on: February 18, 2015, 09:47:00 PM »

Hi Graham!
Thought I'd mention that CB and your code, both still work just fine on Windows 8.1
...been quite awhile since I played around with CB, but your sample code always seems to inspire me to take it for a spin.  Wish I could find the old joy I had in programming and especially in using CB in particular, but I'm afraid that it might be done for good. No worries though... I'll continue to test all that you post if nothing else.

Take care friend!

-Doc-
« Last Edit: February 18, 2015, 09:54:14 PM by docmann »
Logged
-Doc-

-----------------------------------------------
I'm just about as good as I never was.

GWS

  • Moderator
  • Sr. Member
  • *****
  • Bananas: 14
  • Offline Offline
  • Posts: 342
Re: Menu Separator?
« Reply #7 on: February 19, 2015, 03:40:40 AM »

Hello Doc,  :) .. so nice to hear from you.

It's nice to know CB is still working on the newer implementations of Windows.  I hope it goes on forever.  :P

I'm still with XP on my working machine, but I've got Win7 on my leisure machine which I bought for Christmas.  I've got it hooked up via an HDMI cable to my TV, so I get large screen viewing of lots of stuff off the Web. ;D

Sounds like you may have gone through a bad time -  I can relate to that, having lost my wife last year, my creative work nosedived.

I'm sort of recovering with the strange view that past life is a sort of dream - much of my life, schools, workplaces, people, are no longer there.  But they remain clear as day in my head.

I still love the simple CB implementation of Basic - it's like an old friend you can always rely on.

I hope you keep well ..  :)

Graham



Logged
Tomorrow may be too late ...
Pages: [1]   Go Up
 

To link to us use this code/button on your site

http://www.codingmonkeys.com/images/cm_link.gif