Author |
Topic: * key 1 "è" in textedit.bbc (Read 1156 times) |
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #15 on: Nov 27th, 2009, 08:21am » |
|
Code:SYS "CreateFile", filename$, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0 TO hFile% I'm surprised that you didn't use OPENIN here; is it because you found FILE_FLAG_SEQUENTIAL_SCAN to be necessary? Although that flag may occasionally improve performance, I've never actually found it to be essential.
Or was it simply because you'd forgotten about @hfile%() ?
I'd be a little concerned if you became so enamoured of the Windows API that you started using it even when there's a perfectly suitable BBC BASIC equivalent. Although if that means you're thinking about abandoning BBC BASIC for another language altogether I'd be delighted!!
Richard.
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #16 on: Nov 27th, 2009, 11:00am » |
|
Quote:I'm surprised that you didn't use OPENIN here; is it because you found FILE_FLAG_SEQUENTIAL_SCAN to be necessary? Although that flag may occasionally improve performance, I've never actually found it to be essential. |
|
No, it was a literal translation of the C++ code in the SDK. No other reason.
Quote:| Or was it simply because you'd forgotten about @hfile%() |
|
No, same again, I was just trying to make sure I got it working first.
Quote:I'd be a little concerned if you became so enamoured of the Windows API that you started using it even when there's a perfectly suitable BBC BASIC equivalent. Although if that means you're thinking about abandoning BBC BASIC for another language altogether I'd be delighted!! |
|
Poo to you too! Unfortunately for you BB4W is the only way I have found to communicate effectively with my computer. Please remember that this is a hobby for me.
I am definitely not arrogant enough to assume that I could give up my six figure day job to become a computer programmer. I hope my mistakes can be helpful to someone else reading them.
Michael
|
|
Logged
|
|
|
|
Danny72
New Member
member is offline


Posts: 20
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #17 on: Nov 30th, 2009, 1:47pm » |
|
Hello
Ive implemented the additions including the
Hedit% = FN_createwindow("EDIT", "", 0, 0, @vdu%!208, @vdu%!212, 0, &200044, 0) PROC_setfocus(Hedit%)
It seems to work for a while, then the cursor is sent back to the beginning whilst editing a larger amount. Could anyone suggest how this could work better.
Also, to access the French or Spanish chars from using the Alt key seems to sometimes work, and sometimes not work.
Thanks for the help. I have pasted the whole code below.
rem. A simple text editor in BBC BASIC for Windows, 19-Aug-2007 install @lib$+"WINLIB5" rem. Set up menus: AM$ = "AppendMenu" sys "CreatePopupMenu" to char% sys "AppendMenu", char%, 0, 232, "è" sys "AppendMenu", char%, 0, 200, "È" sys "AppendMenu", char%, 0, 233, "é" sys "AppendMenu", char%, 0, 201, "É" sys "AppendMenu", char%, 0, 226, "â" sys "AppendMenu", char%, 0, 194, "Â" sys "AppendMenu", char%, 0, 234, "ê" sys "AppendMenu", char%, 0, 202, "Ê" sys "AppendMenu", char%, 0, 251, "û" sys "AppendMenu", char%, 0, 217, "Û" sys "AppendMenu", char%, 0, 231, "ç" sys "AppendMenu", char%, 0, 199, "Ç" sys "AppendMenu", char%, 0, 239, "ï" sys "AppendMenu", char%, 0, 207, "Ï" sys "AppendMenu", char%, 0, 244, "ô" sys "AppendMenu", char%, 0, 212, "Ô" sys "AppendMenu", char%, 0, 235, "ë" sys "AppendMenu", char%, 0, 203, "Ë" sys "AppendMenu", char%, 0, 249, "ù" sys "AppendMenu", char%, 0, 217, "Ù" rem spanish characters sys "CreatePopupMenu" to charv% sys "AppendMenu", charv%, 0, 225, "á" sys "AppendMenu", charv%, 0, 193, "Á" sys "AppendMenu", charv%, 0, 233, "é" sys "AppendMenu", charv%, 0, 201, "É" sys "AppendMenu", charv%, 0, 237, "í" sys "AppendMenu", charv%, 0, 205, "Í" sys "AppendMenu", charv%, 0, 241, "ñ" sys "AppendMenu", charv%, 0, 209, "Ñ" sys "AppendMenu", charv%, 0, 243, "ó" sys "AppendMenu", charv%, 0, 211, "Ó" sys "AppendMenu", charv%, 0, 250, "ú" sys "AppendMenu", charv%, 0, 218, "Ú" sys "AppendMenu", charv%, 0, 252, "ü" sys "AppendMenu", charv%, 0, 220, "Ü" sys "AppendMenu", charv%, 0, 191, "¿" sys "AppendMenu", charv%, 0, 161, "¡" sys "AppendMenu", charv%, 0, 171, "«" sys "AppendMenu", charv%, 0, 187, "»" rem sys "AppendMenu", charv%, 0, 249, "ù" rem sys "AppendMenu", charv%, 0, 217, "Ù" rem"Ç" rem"ï" rem"Ï" rem"ô" rem"Ô" rem"ë" rem"Ë" rem"ù" rem"Ù" sys "CreatePopupMenu" to H% sys AM$, H%, 0, 20, "&New" sys AM$, H%, 0, 21, "&Open" sys AM$, H%, 0, 22, "&Save" sys AM$, H%, 0, 23, "Save &As" sys AM$, H%, &800, 0, 0 sys AM$, H%, 0, 24, "E&xit" sys "CreatePopupMenu" to E% sys AM$, E%, 0, 30, "&Undo" sys AM$, E%, &800, 0, 0 sys AM$, E%, 0, 31, "Cu&t" sys AM$, E%, 0, 32, "&Copy" sys AM$, E%, 0, 33, "&Paste" sys AM$, E%, 0, 34, "De&lete" sys AM$, E%, &800, 0, 0 sys AM$, E%, 0, 35, "Select &All" sys "CreatePopupMenu" to O% sys AM$, O%, 0, 40, "Set &Font" sys "CreateMenu" to M% sys "SetMenu", @hwnd%, M% sys AM$, M%, 16, H%, "&File" sys AM$, M%, 16, E%, "&Edit" sys AM$, M%, 16, O%, "&Options" sys "AppendMenu", M%, 16, char%, "F&rench Accents" sys "AppendMenu", M%, 16, charv%, "&Spanish Accents" sys "DrawMenuBar", @hwnd% rem. Create edit window: Hedit% = fn_createwindow("EDIT", "", 0, 0, @vdu%!208, @vdu%!212, 0, &200044, 0) Hedit% = fn_createwindow("EDIT", "", 0, 0, @vdu%!208, @vdu%!212, 0, &200044, 0) proc_setfocus(Hedit%) rem. Create and initialise data structures for dialogue boxes: dim Fn% 255, Lf% 59 dim fs{lStructSize%, hwndOwner%, hInstance%, lpstrFilter%, \ \ lpstrCustomFilter%, nMaxCustFilter%, nFilterIndex%, \ \ lpstrFile%, nMaxFile%, lpstrFileTitle%, \ \ nMaxFileTitle%, lpstrInitialDir%, lpstrTitle%, \ \ flags%, nFileOffset{l&,h&}, nFileExtension{l&,h&}, \ \ lpstrDefExt%, lCustData%, lpfnHook%, lpTemplateName%} ff$ = "TXT files"+chr$0+"*.TXT"+chr$0+"All files"+chr$0+"*.*"+chr$0+chr$0 ex$ = "txt" fs.lStructSize% = dim(fs{}) fs.hwndOwner% = @hwnd% fs.lpstrFilter% = !^ff$ fs.lpstrDefExt% = !^ex$ fs.lpstrFile% = Fn% fs.nMaxFile% = 256 fs.flags% = 6 dim cf{lStructSize%, hwndOwner%, hdc%, lpLogFont%, \ \ iPointSize%, flags%, rgbColors%, lCustData%, \ \ lpfnHook%, lpTemplateName%, hInstance%, lpszStyle%, \ \ nFontType{l&,h&}, pad{l&,h&}, nSizeMin%, nSizeMax%} cf.lStructSize% = dim(cf{}) cf.hwndOwner% = @hwnd% cf.lpLogFont% = Lf% cf.flags% = 1 rem. Set up 'interrupts': Menu% = 0 on close if fnchanged procexit else return on move procmove(@msg%, @wparam%, @lparam%) : return on sys Menu% = @wparam% : return on error sys "MessageBox", @hwnd%, report$, 0, 48 rem. Main loop: repeat K% = 0 : swap K%, Menu% F% = true case K% of when 20: if fnchanged procnew when 21: if fnchanged procload when 22: if fnsave procunchanged when 23: if fnsaveas procunchanged when 24: if fnchanged procexit when 30: sys "SendMessage", Hedit%, &C7, 0, 0 when 31: sys "SendMessage", Hedit%, &300, 0, 0 when 32: sys "SendMessage", Hedit%, &301, 0, 0 when 33: sys "SendMessage", Hedit%, &302, 0, 0 when 34: sys "SendMessage", Hedit%, &303, 0, 0 when 35: sys "SendMessage", Hedit%, &B1, 0, -1 when 232,200,233,201,226,194,234,202,251,217,231,199,239,207,244,212,235,203,249,217,225,193,237,205,241,209,243,211,250,218,252,220,191,161,171,187: sys "SendMessage", Hedit%, &102, K%, 0 when 40: procfont otherwise: F% = false endcase if F% sys "SetForegroundWindow", Hedit% wait 1 until false end def procexit proc_closewindow(Hedit%) quit def procmove(M%, W%, L%) if M%=5 sys "MoveWindow", Hedit%, 0, 0, L% and &FFFF, L% >> 16, 1 endproc def procfont : local F%, R% sys "ChooseFont", cf{} to R% if R% then sys "SendMessage", Hedit%, &31, 0, 0 to F% if F% sys "DeleteObject", F% sys "CreateFontIndirect", cf.lpLogFont% to F% sys "SendMessage", Hedit%, &30, F%, 1 endif endproc def procnew : local F% ?Fn% = 0 : proctitle sys "SendMessage", Hedit%, &C, 0, ^F% endproc def procload : local F%, L% sys "GetOpenFileName", fs{} to F% if F% proctitle else endproc F% = openin$$Fn% if F% then L% = ext#F% : close #F% sys "GlobalAlloc", 0, L%+1 to F% oscli "LOAD """+$$Fn%+""" "+str$~F%+"+"+str$~L% F%?L% = 0 sys "SendMessage", Hedit%, &C, 0, F% to L% sys "GlobalFree", F% if L% = 0 error 100, "File "+$$Fn%+" too big" else error 101, "Can't open file "+$$Fn% endif endproc def fnsaveas : local F%, L% sys "GetSaveFileName", fs{} to F% if F% proctitle else = false def fnsave : local F%, L% : if ?Fn% = 0 then = fnsaveas sys "SendMessage", Hedit%, &E, 0, 0 to L% sys "GlobalAlloc", 0, L%+1 to F% sys "SendMessage", Hedit%, &D, L%+1, F% oscli "SAVE """+$$Fn%+""" "+str$~F%+"+"+str$~L% sys "GlobalFree", F% = true def fnchanged : local R% sys "SendMessage", Hedit%, &B8, 0, 0 to R% if R% = 0 then = true sys "MessageBox", @hwnd%, "Save changes?", "TEXTEDIT", 35 to R% if R% = 6 if fns procunchanged : = true if R% = 7 procunchanged : = true = false def proctitle sys "SetWindowText", @hwnd%, "TEXTEDIT - "+$$Fn% endproc def procunchanged sys "SendMessage", Hedit%, &B9, 0, 0 endproc
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #18 on: Nov 30th, 2009, 3:52pm » |
|
Quote:| Could anyone suggest how this could work better |
|
Well, there's a pretty serious and obvious error here:
Code: REM. Create edit window:
Hedit% = FN_createwindow("EDIT", "", 0, 0, @vdu%!208, @vdu%!212, 0, &200044, 0)
Hedit% = FN_createwindow("EDIT", "", 0, 0, @vdu%!208, @vdu%!212, 0, &200044, 0)
PROC_setfocus(Hedit%) You create two edit controls, which is likely to cause all sorts of problems!
Richard.
|
|
Logged
|
|
|
|
Danny72
New Member
member is offline


Posts: 20
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #19 on: Dec 2nd, 2009, 12:29pm » |
|
Thanks. Yes, removing the duplicate line has sorted out the main problem.
Could someone advise me as to how to get the pop-up windows working consistently with the Alt Key e.g. Alt F for File.
Many thanks
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #20 on: Dec 2nd, 2009, 1:58pm » |
|
Quote:| Could someone advise me as to how to get the pop-up windows working consistently with the Alt Key e.g. Alt F for File. |
|
Try replacing the main loop with this:
Code: REM. Main loop:
REPEAT
K% = 0 : SWAP K%, Menu%
CASE K% OF
WHEN 20: IF FNchanged PROCnew
WHEN 21: IF FNchanged PROCload
WHEN 22: IF FNsave PROCunchanged
WHEN 23: IF FNsaveas PROCunchanged
WHEN 24: IF FNchanged PROCexit
WHEN 30: SYS "SendMessage", Hedit%, &C7, 0, 0
WHEN 31: SYS "SendMessage", Hedit%, &300, 0, 0
WHEN 32: SYS "SendMessage", Hedit%, &301, 0, 0
WHEN 33: SYS "SendMessage", Hedit%, &302, 0, 0
WHEN 34: SYS "SendMessage", Hedit%, &303, 0, 0
WHEN 35: SYS "SendMessage", Hedit%, &B1, 0, -1
WHEN 232,200,233,201,226,194,234,202,251,217,231,199,239,207,244,212,235,203, \
\ 249,217,225,193,237,205,241,209,243,211,250,218,252,220,191,161,171,187:
SYS "PostMessage", Hedit%, &102, K%, 0
WHEN 40: PROCfont
ENDCASE
PROC_setfocus(Hedit%)
WAIT 1
UNTIL FALSE
END Richard.
|
|
Logged
|
|
|
|
Danny72
New Member
member is offline


Posts: 20
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #21 on: Dec 4th, 2009, 3:06pm » |
|
Thanks very much, it is all working now. Danny
|
|
Logged
|
|
|
|
|