While writing the subway stop program, I added the "&" character in front of letter or number in text to be printed on push buttons. When you run the program, you will see underlined letter or number on text printed on push buttons. In the short version that I posted here, choose "Far Rockaway" or "Rockaway Park" and click on "OK" button. Press the "N" key until you get a choice of two routes. Press "1" key then press "N" key until you get a choice of two routes. Try to press "1" or "2" key and the computer beeps. Here is the program:
Jeffrey.
Code:
#compile exe #register none #dim all #include "win32api.inc" #include "commctrl.inc" #include "richedit1.inc" %ctlcommand01=101 %ctlcommand02=102 %ctlcommand03=103 %ctlcommand04=104 %ctlcommand05=105 %ctlcommand06=106 %ctlcommand07=107 %ctlcommand08=108 %ctlcommand09=109 %ctlcommand10=110 %ctloption01=111 %ctloption02=112 %ctloption03=113 %ctloption04=114 %ctloption05=115 %ctloption06=116 %ctloption07=117 %ctloption08=118 %ctloption09=119 %ctloption10=120 %ctloption11=121 %ctloption12=122 %ctloption13=123 %ctloption14=124 %ctloption15=125 %ctloption16=126 %ctloption17=127 %ctloption18=128 %ctloption19=129 %ctloption20=130 %ctloption21=131 %ctloption22=132 %ctloption23=133 %ctloption24=134 %ctloption25=135 %ctloption26=136 %ctloption27=137 %ctloption28=138 %ctloption29=139 %ctloption30=140 %ctloption31=141 %ctloption32=142 %ctloption33=143 %ctloption34=144 %ctloption35=145 %ctloption36=146 %ctloption37=147 %ctloption38=148 %ctloption39=149 %ctloption40=150 %ctloption41=151 %ctloption42=152 %ctloption43=153 %ctloption44=154 %ctloption45=155 %ctloption46=156 %ctloption47=157 %ctloption48=158 %ctloption49=159 %ctloption50=160 %ctltextbox1=161 %ctltextbox2=162 %ctltextbox3=163 %ctltextbox4=164 %ctltextbox5=165 %ctltextbox6=166 global boolean as long global buttonid as long global controlid as long global hedit1 as long global hedit2 as long global hedit3 as long global hedit4 as long global hedit5 as long global hedit6 as long global hfont as long global hform1 as long global hform2 as long global buttonpressed as long global stopindex as long global string07 as string type charformat2 cbsize as long dwmask as dword dweffects as dword yheight as long yoffset as long crtextcolor as dword bcharset as byte bpitchandfamily as byte szfacename as asciiz * %lf_facesize szdummy as integer end type sub selectstation select case stopindex case 1 call text01("Stop at Beach 67th Street") case 2 call text01("Stop at Beach 60th Street") case 3 call text01("Stop at Beach 44th Street") case 4 call text01("Stop at Beach 36th Street") case 5 call text01("Stop at Beach 25th Street") case 6 call text01("Change Direction at Far Rockaway") case 7 call text01("Stop at Beach 25th Street") case 8 call text01("Stop at Beach 36th Street") case 9 call text01("Stop at Beach 44th Street") case 10 call text01("Stop at Beach 60th Street") case 11 call text01("Stop at Beach 67th Street") call text02("2 - To Broad Channel") call text03("3 - To Beach 90th Street") call command02 if buttonpressed=2 then call cleartext call command01 stopindex=18 control send hform2,%ctlcommand03,%bm_click,0,0 end if if buttonpressed=3 then call cleartext call command01 stopindex=11 control send hform2,%ctlcommand03,%bm_click,0,0 end if case 12 call text01("Stop at Beach 90th Street") case 13 call text01("Stop at Beach 98th Street") case 14 call text01("Stop at Beach 105th Street") case 15 call text01("Change Direction at Rockaway Park") case 16 call text01("Stop at Beach 105th Street") case 17 call text01("Stop at Beach 98th Street") case 18 call text01("Stop at Beach 90th Street") call text02("2 - To Broad Channel") call text03("3 - To Beach 67th Street") call command02 if buttonpressed=2 then call cleartext call command01 stopindex=18 control send hform2,%ctlcommand03,%bm_click,0,0 end if if buttonpressed=3 then call cleartext call command01 stopindex=0 control send hform2,%ctlcommand03,%bm_click,0,0 end if case 19 call text01("Stop at Broad Channel") call text02("2 - To Beach 67th Street") call text03("3 - To Beach 90th Street") call command02 if buttonpressed=2 then call cleartext call command01 stopindex=0 control send hform2,%ctlcommand03,%bm_click,0,0 end if if buttonpressed=3 then call cleartext call command01 stopindex=11 control send hform2,%ctlcommand03,%bm_click,0,0 end if end select end sub callback function evtcommand01() as long dialog show state hform1,%sw_hide call cleartext call command01 boolean=-1 string07="Skip " call text06("Express Stops") call selectstation call markall("Stop") dialog show modal hform2 end function callback function evtcommand02() as long deleteobject hfont dialog end hform1 dialog end hform2 end function callback function evtcommand03() as long buttonpressed=1 incr stopindex call selectstation call markall("Stop") end function callback function evtcommand04() as long buttonpressed=2 call selectstation end function callback function evtcommand05() as long buttonpressed=3 call selectstation end function callback function evtcommand06() as long buttonpressed=4 call selectstation end function callback function evtcommand07() as long buttonpressed=5 call selectstation end function callback function evtcommand08() as long boolean=isfalse(boolean) if boolean=-1 then string07="Skip " call text06("Express Stops") end if if boolean=0 then string07="Stop at " call text06("Local Stops") end if end function callback function evtcommand09() as long dialog show state hform2,%sw_hide dialog show modal hform1 end function callback function evtcommand10() as long deleteobject hfont dialog end hform1 dialog end hForm2 end function callback function evtoption01() as long stopindex=6 call selectstation end function callback function evtoption02() as long stopindex=15 call selectstation end function callback function evtoption03() as long stopindex=21 call selectstation end function callback function evtoption04() as long stopindex=536 call selectstation end function callback function evtoption05() as long stopindex=546 call selectstation end function callback function evtoption06() as long stopindex=276 call selectstation end function callback function evtoption07() as long stopindex=538 call selectstation end function callback function evtoption08() as long stopindex=537 call selectstation end function callback function evtoption09() as long stopindex=31 call selectstation end function callback function evtoption10() as long stopindex=49 call selectstation end function callback function evtoption11() as long stopindex=555 call selectstation end function callback function evtoption12() as long stopindex=545 call selectstation end function callback function evtoption13() as long stopindex=241 call selectstation end function callback function evtoption14() as long stopindex=229 call selectstation end function callback function evtoption15() as long stopindex=543 call selectstation end function callback function evtoption16() as long stopindex=329 call selectstation end function callback function evtoption17() as long stopindex=544 call selectstation end function callback function evtoption18() as long stopindex=72 call selectstation end function callback function evtoption19() as long stopindex=540 call selectstation end function callback function evtoption20() as long stopindex=541 call selectstation end function callback function evtoption21() as long stopindex=542 call selectstation end function callback function evtoption22() as long stopindex=539 call selectstation end function callback function evtoption23() as long stopindex=91 call selectstation end function callback function evtoption24() as long stopindex=554 call selectstation end function callback function evtoption25() as long stopindex=549 call selectstation end function callback function evtoption26() as long stopindex=535 call selectstation end function callback function evtoption27() as long stopindex=203 call selectstation end function callback function evtoption28() as long stopindex=501 call selectstation end function callback function evtoption29() as long stopindex=521 call selectstation end function callback function evtoption30() as long stopindex=548 call selectstation end function callback function evtoption31() as long stopindex=547 call selectstation end function callback function evtoption32() as long stopindex=556 call selectstation end function callback function evtoption33() as long stopindex=216 call selectstation end function callback function evtoption34() as long stopindex=285 call selectstation end function callback function evtoption35() as long stopindex=308 call selectstation end function callback function evtoption36() as long stopindex=355 call selectstation end function callback function evtoption37() as long stopindex=550 call selectstation end function callback function evtoption38() as long stopindex=339 call selectstation end function callback function evtoption39() as long stopindex=367 call selectstation end function callback function evtoption40() as long stopindex=386 call selectstation end function callback function evtoption41() as long stopindex=404 call selectstation end function callback function evtoption42() as long stopindex=557 call selectstation end function callback function evtoption43() as long stopindex=456 call selectstation end function callback function evtoption44() as long stopindex=442 call selectstation end function callback function evtoption45() as long stopindex=551 call selectstation end function callback function evtoption46() as long stopindex=552 call selectstation end function callback function evtoption47() as long stopindex=558 call selectstation end function callback function evtoption48() as long stopindex=419 call selectstation end function callback function evtoption49() as long stopindex=553 call selectstation end function callback function evtoption50() as long stopindex=478 call selectstation end function sub command01 control enable hform2,%ctlcommand03 control disable hform2,%ctlcommand04 control disable hform2,%ctlcommand05 control disable hform2,%ctlcommand06 control disable hform2,%ctlcommand07 end sub sub command02 control disable hform2,%ctlcommand03 control enable hform2,%ctlcommand04 control enable hform2,%ctlcommand05 control disable hform2,%ctlcommand06 control disable hform2,%ctlcommand07 end sub sub command03 control disable hform2,%ctlcommand03 control enable hform2,%ctlcommand04 control enable hform2,%ctlcommand05 control enable hform2,%ctlcommand06 control disable hform2,%ctlcommand07 end sub sub command04 control disable hform2,%ctlcommand03 control enable hform2,%ctlcommand04 control enable hform2,%ctlcommand05 control enable hform2,%ctlcommand06 control enable hform2,%ctlcommand07 end sub function setrichtextcolor(byval newcolor as long) as long local cf as charformat2 cf.cbsize=len(cf) cf.dwmask=%cfm_color cf.crtextcolor=newcolor call sendmessage(hedit1,%em_setcharformat,%scf_selection,varptr(cf)) end function sub markstring(byval alltext as string,byval mytext as string,byval ccol as long) local stoppos as long stoppos=instr(alltext,mytext) if stoppos then call sendmessage(hedit1,%em_setsel,stoppos-1,stoppos+len(mytext)-1) call setrichtextcolor(ccol) call sendmessage(hedit1,%em_setsel,stoppos+len(mytext)-1,stoppos+len(alltext)-1) call setrichtextcolor(0) end if end sub function markall(byval mytext as string) as long local alltext as string,tlen as long tlen=sendmessage(hedit1,%wm_gettextlength,0,0)+1 alltext=space$(tlen) call sendmessage(hedit1,%wm_gettext,tlen,strptr(alltext)) call sendmessage(hedit1,%wm_setredraw,0,0) call markstring(alltext,"Change",&h80) call markstring(alltext,"Stop",&h80) call markstring(alltext,"Skip",&h008000) call sendmessage(hedit1,%em_setsel,0,0) sendmessage hedit1,%wm_setredraw,1,0 invalidaterect hedit1,byval %null,0 updatewindow hedit1 end function sub text01(string01 as string) call sendmessage(hedit1,%wm_settext,0,strptr(string01)) end sub sub text02(string02 as string) call sendmessage(hedit2,%wm_settext,0,strptr(string02)) end sub sub text03(string03 as string) call sendmessage(hedit3,%wm_settext,0,strptr(string03)) end sub sub text04(string04 as string) call sendmessage(hedit4,%wm_settext,0,strptr(string04)) end sub sub text05(string05 as string) call sendmessage(hedit5,%wm_settext,0,strptr(string05)) end sub sub text06(string06 as string) call sendmessage(hedit6,%wm_settext,0,strptr(string06)) end sub sub cleartext local string01 as string string01="" call sendmessage(hedit2,%wm_settext,0,strptr(string01)) call sendmessage(hedit3,%wm_settext,0,strptr(string01)) call sendmessage(hedit4,%wm_settext,0,strptr(string01)) call sendmessage(hedit5,%wm_settext,0,strptr(string01)) end sub function pbmain() as long local hriched as long hriched=loadlibrary("riched32.dll") call initcommoncontrols dialog new 0,"NYCTA Subway Program",1,1,312,213,%ws_maximize + %ws_sysmenu to hform1 control add button,hform1,%ctlcommand02,"Cancel",340,250,100,15 call evtcommand02 control add button,hform1,%ctlcommand01,"OK",340,230,100,15 call evtcommand01 control add option,hform1,%ctloption50,"Pelham Bay Park",340,210,100,15 call evtoption50 control add option,hform1,%ctloption49,"East 177th Street",340,190,100,15 call evtoption49 control add option,hform1,%ctloption48,"Woodlawn",340,170,100,15 call evtoption48 control add option,hform1,%ctloption47,"125th Street",340,150,100,15 call evtoption47 control add option,hform1,%ctloption46,"Brooklyn Bridge",340,130,100,15 call evtoption46 control add option,hform1,%ctloption45,"Bowling Green",340,110,100,15 call evtoption45 control add option,hform1,%ctloption44,"241st Street",340,90,100,15 call evtoption44 control add option,hform1,%ctloption43,"Dyre Avenue",340,70,100,15 call evtoption43 control add option,hform1,%ctloption42,"East 180th Street",340,50,100,15 call evtoption42 control add option,hform1,%ctloption41,"148th Street",340,30,100,15 call evtoption41 control add option,hform1,%ctloption40,"242nd Street",340,10,100,15 call evtoption40 control add option,hform1,%ctloption39,"South Ferry",230,250,100,15 call evtoption39 control add option,hform1,%ctloption38,"Flatbush Avenue",230,230,100,15 call evtoption38 control add option,hform1,%ctloption37,"Utica Avenue",230,210,100,15 call evtoption37 control add option,hform1,%ctloption36,"New Lots Avenue",230,190,100,15 call evtoption36 control add option,hform1,%ctloption35,"8th Avenue",230,170,100,15 call evtoption35 control add option,hform1,%ctloption34,"Rockaway Parkway",230,150,100,15 call evtoption34 control add option,hform1,%ctloption33,"Metropolitan Avenue",230,130,100,15 call evtoption33 control add option,hform1,%ctloption32,"Myrtle Avenue",230,110,100,15 call evtoption32 control add option,hform1,%ctloption31,"Chambers Street",230,90,100,15 call evtoption31 control add option,hform1,%ctloption30,"Broad Street",230,70,100,15 call evtoption30 control add option,hform1,%ctloption29,"Main Street",230,50,100,15 call evtoption29 control add option,hform1,%ctloption28,"Times Square",230,30,100,15 call evtoption28 control add option,hform1,%ctloption27,"Ditmars Boulevard",230,10,100,15 call evtoption27 control add option,hform1,%ctloption26,"Lexington Avenue",120,250,100,15 call evtoption26 control add option,hform1,%ctloption25,"Whitehall Street",120,230,100,15 call evtoption25 control add option,hform1,%ctloption24,"36th Street",120,210,100,15 call evtoption24 control add option,hform1,%ctloption23,"95th Street",120,190,100,15 call evtoption23 control add option,hform1,%ctloption22,"Bay Parkway",120,170,100,15 call evtoption22 control add option,hform1,%ctloption21,"Kings Highway",120,150,100,15 call evtoption21 control add option,hform1,%ctloption20,"Church Avenue",120,130,100,15 call evtoption20 control add option,hform1,%ctloption19,"Smith Street",120,110,100,15 call evtoption19 control add option,hform1,%ctloption18,"Stillwell Avenue",120,90,100,15 call evtoption18 control add option,hform1,%ctloption17,"Brighton Beach",120,70,100,15 call evtoption17 control add option,hform1,%ctloption16,"Franklin Avenue",120,50,100,15 call evtoption16 control add option,hform1,%ctloption15,"Prospect Park",120,30,100,15 call evtoption15 control add option,hform1,%ctloption14,"179th Street",120,10,100,15 call evtoption14 control add option,hform1,%ctloption13,"Jamaica Center",10,250,100,15 call evtoption13 control add option,hform1,%ctloption12,"71st Avenue",10,230,100,15 call evtoption12 control add option,hform1,%ctloption11,"Queens Plaza",10,210,100,15 call evtoption11 control add option,hform1,%ctloption10,"205th Street",10,190,100,15 call evtoption10 control add option,hform1,%ctloption09,"207th Street",10,170,100,15 call evtoption09 control add option,hform1,%ctloption08,"168th Street",10,150,100,15 call evtoption08 control add option,hform1,%ctloption07,"145th Street",10,130,100,15 call evtoption07 control add option,hform1,%ctloption06,"21st Street",10,110,100,15 call evtoption06 control add option,hform1,%ctloption05,"World Trade Center",10,90,100,15 call evtoption05 control add option,hform1,%ctloption04,"Euclid Avenue",10,70,100,15 call evtoption04 control add option,hform1,%ctloption03,"Lefferts Boulevard",10,50,100,15 call evtoption03 control add option,hform1,%ctloption02,"Rockaway Park",10,30,100,15 call evtoption02 control add option,hform1,%ctloption01,"Far Rockaway",10,10,100,15 call evtoption01 dialog new 0,"NYCTA Subway Program",0,0,312,213,%ws_maximize + %ws_sysmenu to hform2 control add button, hform2,%ctlcommand10,"E&xit",70,320,50,20 call evtcommand10 control add button, hform2,%ctlcommand09,"New &Route",10,320,50,20 call evtcommand09 control add button, hform2,%ctlcommand08,"&Stop Type",10,270,50,20 call evtcommand08 control add button, hform2,%ctlcommand07,"Route &4",10,220,50,20 call evtcommand07 control add button, hform2,%ctlcommand06,"Route &3",10,170,50,20 call evtcommand06 control add button, hform2,%ctlcommand05,"Route &2",10,120,50,20 call evtcommand05 control add button, hform2,%ctlcommand04,"Route &1",10,70,50,20 call evtcommand04 control add button, hform2,%ctlcommand03,"&Next Station",10,20,50,20 call evtcommand03 control add "richedit",hform2,%ctltextbox6,"",70,260,450,40,%ws_visible or %ws_child control add "richedit",hform2,%ctltextbox5,"",70,210,450,40,%ws_visible or %ws_child control add "richedit",hform2,%ctltextbox4,"",70,160,450,40,%ws_visible or %ws_child control add "richedit",hform2,%ctltextbox3,"",70,110,450,40,%ws_visible or %ws_child control add "richedit",hform2,%ctltextbox2,"",70,60,450,40,%ws_visible or %ws_child control add "richedit",hform2,%ctltextbox1,"",70,10,450,40,%ws_visible or %ws_child hfont=createfont(60,30,0,0,0,0,0,0,0,0,0,0,0,"arial") control send hform2,%ctltextbox6,%wm_setfont,hfont,%true control send hform2,%ctltextbox5,%wm_setfont,hfont,%true control send hform2,%ctltextbox4,%wm_setfont,hfont,%true control send hform2,%ctltextbox3,%wm_setfont,hfont,%true control send hform2,%ctltextbox2,%wm_setfont,hfont,%true control send hform2,%ctltextbox1,%wm_setfont,hfont,%true control handle hform2,%ctltextbox6 to hedit6 control handle hform2,%ctltextbox5 to hedit5 control handle hform2,%ctltextbox4 to hedit4 control handle hform2,%ctltextbox3 to hedit3 control handle hform2,%ctltextbox2 to hedit2 control handle hform2,%ctltextbox1 to hedit1 dialog show modal hform1 end function
Comment