Author |
Topic: * key 1 "è" in textedit.bbc (Read 1157 times) |
|
Danny72
New Member
member is offline


Posts: 20
|
 |
* key 1 "è" in textedit.bbc
« Thread started on: Nov 11th, 2009, 3:30pm » |
|
Hello
I would like to use the textedit.bbc as a simple wordprocessor in other languages.
I have tried putting in the code * key 1 "è" as an easy way to input foreign accents but it doesn't seem to recognise it in the program.
Is there an easy solution to this?
Also, would the author of textedit.bbc mind if I distribute this text editor to other people.
Many thanks
Danny
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #1 on: Nov 11th, 2009, 5:17pm » |
|
Quote:I have tried putting in the code *key 1 "è" as an easy way to input foreign accents but it doesn't seem to recognise it in the program. |
|
TEXTEDIT.BBC spawns a Windows Edit Control, and doesn't use BBC BASIC for its keyboard input. As a result things like *KEY and *EXEC can't work (they are part of BASIC). Effectively, it works exactly as NOTEPAD does (which also uses a standard Edit Control).
However, for the same reason, the 'official' Windows shortcuts for accented characters etc. do work. For example if you have enabled the US-International Keyboard or the UK Extended Keyboard you can generate è by typing `e. If you have a French keyboard there's a key for it (the '7' key). Failing any of those, you can type Alt-0232 (Hold down Alt, type 0232 on the numeric keypad, release Alt).
For more information: http://support.microsoft.com/default.aspx?scid=kb;en-us;306560&sd=tech#2 http://french.about.com/od/writing/ss/typeaccents.htm
If you're really determined you could probably make F1 work by re-engineering TEXTEDIT.BBC to use a docked dialogue box, using the WINLIB2B library (which includes a special function FN_newdialogaccel() that takes an additional parameter) and creating an Accelerator Table which performs the necessary translation. An interesting challenge!
Richard.
|
|
Logged
|
|
|
|
Danny72
New Member
member is offline


Posts: 20
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #2 on: Nov 11th, 2009, 7:31pm » |
|
Is it possible to have an extra pop-up menu on textedit.bbc which would then display the accented character, when clicked?
thanks
Danny
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #3 on: Nov 11th, 2009, 10:14pm » |
|
Quote:Is it possible to have an extra pop-up menu on textedit.bbc which would then display the accented character, when clicked? |
|
Yes, that's straightforward. You could go further and have a toolbar (maybe a floating toolbar) with the accented characters all 'continuously' available with a single click of the mouse. When you want to insert the character, just send an appropriate WM_CHAR message to the edit control.
Richard.
|
|
Logged
|
|
|
|
Danny72
New Member
member is offline


Posts: 20
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #4 on: Nov 12th, 2009, 08:05am » |
|
Thanks for the WM_CHAR tip, though I can't seem to find any more info on this in the manual etc.
Could you let me know where it might go in the textedit.bbc please. To get the character "è", would it be something like WM_CHAR 0232 somewhere?
Danny
rem. A simple text editor in BBC BASIC for Windows, 01-Dec-2006 install @lib$+"WINLIB5" rem. Set up menus: AM$ = "AppendMenu" 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 "DrawMenuBar", @hwnd% rem. Create edit window: Hedit% = fn_createwindow("EDIT", "", 0, 0, @vdu%!208, @vdu%!212, 0, &200044, 0) 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% = !!^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% = !!^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 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 #5 on: Nov 12th, 2009, 08:38am » |
|
Quote:Could you let me know where it might go in the textedit.bbc please. |
|
The simplest solution is to add a new menu:
Code: SYS "CreatePopupMenu" TO char%
SYS "AppendMenu", char%, 0, 232, "è"
SYS "AppendMenu", char%, 0, 233, "é" which you then need to add to the menu bar:
Code: SYS "AppendMenu", M%, 16, char%, "&Characters" and then, in the main loop, process the messages:
Code: WHEN 232,233: SYS "SendMessage", Hedit%, WM_CHAR, K%, 0 (WM_CHAR is &102).
I still think a toolbar might be nicer, so you can get the accented characters with one mouse click rather then two.
Richard.
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #6 on: Nov 12th, 2009, 08:55am » |
|
You could also use a Rich Edit Control which will allow you to use UNICODE. This code is a shell to expand on...
Code:
MODE 8
:\
\\ Install libraries
\
INSTALL @lib$+"WINLIB"
INSTALL @lib$+"WINLIB2"
INSTALL @lib$+"WINLIB5A"
REM!WC
WM_COMMAND = &111
CFM_BOLD = &1
CFM_COLOR = &40000000
CFM_FACE = &20000000
CFM_ITALIC = &2
CFM_SIZE = &80000000
CFM_STRIKEOUT = &8
CFM_UNDERLINE = &4
EM_EXLIMITTEXT = &435
EM_SETBKGNDCOLOR = &443
EM_SETCHARFORMAT = &444
EM_SETEVENTMASK = &445
EM_SHOWSCROLLBAR = &460
ENM_CHANGE = &1
ENM_KEYEVENTS = &10000
ENM_MOUSEEVENTS = &20000
ES_AUTOHSCROLL = &80
ES_AUTOVSCROLL = &40
ES_MULTILINE = &4
ES_NOHIDESEL = &100
SB_HORZ = 0
SB_VERT = 1
SCF_ALL = &4
WS_BORDER = &800000
_TRUE = 1
REM. Set up menus:
AM$ = "AppendMenu"
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 "DrawMenuBar", @hwnd%
REM Set up RichEdit Control
DIM CHARFORMAT{cbSize%, \
\ dwMask%, \
\ dwEffects%, \
\ yHeight%, \
\ yOffset%, \
\ crTextColor%, \
\ bCharSet&, \
\ bPitchAndFamily&, \
\ szFaceName&(31), \
\ padding&(1) }
fontsize% = 12
fontname$ = "Times"
bckgrdcolour% = &204030 : REM Horrible Greeny colour
textcolour% = &FFFFFF : REM White
SYS "LoadLibrary", "RICHED20.DLL" TO hRichEditDLL%
IF hRichEditDLL%=0 THEN ERROR 100,"Failed to load MSFTEDIT.DLL"
id_richedit% = 100
hRichEdit% = FN_createwindow(@hwnd%, \
\ "RichEdit20A", \
\ "", \
\ @vdu%!208/2, \
\ 0, \
\ @vdu%!208-@vdu%!208/2, \
\ @vdu%!212-20, \
\ id_richedit%, \
\ WS_BORDER OR ES_MULTILINE OR ES_AUTOHSCROLL OR ES_AUTOVSCROLL OR ES_NOHIDESEL, \
\ 0 )
:\
\\ Set Richedit FONT
\
CHARFORMAT.cbSize% = DIM(CHARFORMAT{})
CHARFORMAT.dwMask% = CFM_BOLD OR CFM_ITALIC OR CFM_UNDERLINE OR \
\ CFM_STRIKEOUT OR CFM_FACE OR CFM_COLOR OR CFM_SIZE
CHARFORMAT.dwEffects% = 0
CHARFORMAT.yHeight% = fontsize%*20
CHARFORMAT.crTextColor% = textcolour%
CHARFORMAT.szFaceName&() = fontname$
SYS "SendMessage", hRichEdit%, EM_SETCHARFORMAT, SCF_ALL, CHARFORMAT{}
SYS "SendMessage", hRichEdit%, EM_SETBKGNDCOLOR, 0, bckgrdcolour%
SYS "SendMessage", hRichEdit%, EM_SHOWSCROLLBAR, SB_VERT, _TRUE
SYS "SendMessage", hRichEdit%, EM_SHOWSCROLLBAR, SB_HORZ, _TRUE
SYS "SendMessage", hRichEdit%, EM_SETEVENTMASK, 0, ENM_KEYEVENTS OR ENM_MOUSEEVENTS OR ENM_CHANGE
SYS "SendMessage", hRichEdit%, EM_EXLIMITTEXT, 0, 20000
ON ERROR PROC_Cleanup:PROC_Error:QUIT
ON CLOSE PROC_Cleanup:QUIT
:\
\\ Main Loop
\
DIM Msg%(2), msg%(2)
Msg%() = -1
ON SYS Msg%() = @msg%,@wparam%,@lparam% : RETURN
REPEAT
msg%(0) = INKEY(1)
SWAP Msg%(), msg%()
CASE msg%(0) OF
WHEN WM_COMMAND:
:\
\\ when the user selects a command item from a menu,
\\ when a control sends a notification message to its parent window,
\\ or when an accelerator keystroke is translated.
\\
\\ msg%(0) = WM_COMMAND
\\ msg%(1) = wParam
\\ msg%(2) =lParam
\\
\\ msg%(1) = high word, 0 Menu, 1 Accelerator, x control
\\ msg%(1) = low word, IDM_* menu, IDM_* accelerator, control id
\
PRINT msg%(0), msg%(1), msg%(2)
highword% = msg%(1) >> 16
lowword% = msg%(1) AND &FFFF
CASE msg%(1) OF
WHEN 24:
PROC_Cleanup
QUIT
ENDCASE
ENDCASE
UNTIL FALSE
:\
\\ Free Library at the end
\
DEF PROC_Cleanup
hRichEdit% += 0 : PROC_closewindow (hRichEdit%)
SYS "FreeLibrary", hRichEditDLL%
ENDPROC
DEF PROC_Error
SYS "MessageBox", @hwnd%, REPORT$, STR$ERR, 0
ENDPROC
I suppose it would be 'easy' to get the characters you want with this?
Michael
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #7 on: Nov 12th, 2009, 09:02am » |
|
Just found it :
In your SDK : ms-help://MS.LHSMSSDK.1033/MS.LHSWinSDK.1033/Controls/controls/richedit/richeditcontrols/aboutricheditcontrols.htm
look for Rich Edit Shortcut Keys
Ctrl+' (apostrophe) Accent acute After pressing the short cut key, press the appropriate letter (for example a, e, or u). This applies to English, French, German, Italian, and Spanish keyboards only. Ctrl+` (grave) Accent grave See Ctrl+' comments. Ctrl+~ (tilde) Accent tilde See Ctrl+' comments. Ctrl+; (semicolon) Accent umlaut See Ctrl+' comments. Ctrl+Shift+6 Accent caret (circumflex) See Ctrl+' comments. Ctrl+, (comma) Accent cedilla See Ctrl+' comments.
So with the above program type [ctrl+`] then e - "è",
etc
Michael
|
|
|
|
Danny72
New Member
member is offline


Posts: 20
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #8 on: Nov 12th, 2009, 3:34pm » |
|
Thanks very much. I have implemented the WM_CHAR idea, and it is working perfectly.
I noticed that textedit.bbc doesn't automatically place the cursor in the typing area like notepad does. Is there a simple way to do this?
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #9 on: Nov 12th, 2009, 4:11pm » |
|
Quote:I noticed that textedit.bbc doesn't automatically place the cursor in the typing area like notepad does. Is there a simple way to do this? |
|
Try a PROC_setfocus immediately after the call to FN_createwindow:
Code: Hedit% = FN_createwindow("EDIT", "", 0, 0, @vdu%!208, @vdu%!212, 0, &200044, 0)
PROC_setfocus(Hedit%) Richard.
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #10 on: Nov 26th, 2009, 02:13am » |
|
Out of interest I was trying to create a Rich Edit text editor. I have got this far....
http://tech.groups.yahoo.com/group/bb4w/files/%22Temp%20Folder%22/MDCH/Rich%20Edit%20text%20editor/Unicode%20Text%20Editor%20testing%20callback.bbc
I am able to load and save unicode rtf files with the PROCLoadsave routine. I thought I should try to get the EM_STREAMIN message to work, but am getting an error returned in the EDITSTREAM.dwError% member. It seems to successfully call the EditStreamCallback function, fills the buffer, but doesn't show anything in the RichEdit control.
I know there are other memory leaks in the code at the moment, but will tidy these up once I get the callback to work.
I have also tried using CALLBACK.BBC but have had trouble figuring out a way of getting the address of the callback function into the EDITSTREAM{}.
Can anyone see what I am doing wrong?
Michael
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #11 on: Nov 26th, 2009, 12:44pm » |
|
I have also tried:
Code:
...enter function
REM Create the EDITSTREAM structure
LOCAL EDITSTREAM{}
DIM EDITSTREAM{dwCookie%, dwError%, pfnCallBack%}
EDITSTREAM.dwCookie% = hFile%
EDITSTREAM.pfnCallBack% = FN_callback(FNEditStream(),4)
SYS FN_syscalls("SendMessage"), hRichEdit%, EM_STREAMIN, SF_RTF, EDITSTREAM{}
R% = FN_sysresult
REM Close the file
SYS "CloseHandle", hFile%
=R%
DEF FNEditStream(dwCookie%, buffer%, cb%, pcb%)
SYS "ReadFile", dwCookie%, buffer%, cb%, pcb% TO R%
IF R% THEN =0 ELSE = -1
but must admit confusion. Does the RichEdit create a buffer - or do I need to?
Still musing on this problem. Still no results.
Michael
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #13 on: Nov 26th, 2009, 10:21pm » |
|
Quote:Still musing on this problem. Still no results. |
|
Your code contains at least one significant error:
Code:SYS "ReadFile", dwCookie%, buffer%, cb%, pcb% TO R% ReadFile takes five parameters but you've supplied only four (the missing parameter is lpOverlapped).
Code: Last time you did this I pointed out that a nicer way (which avoids the end-of-function being buried) is:
Code: I'm sure you said on that occasion that you'd use this method in future.
Richard.
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: * key 1 "è" in textedit.bbc
« Reply #14 on: Nov 27th, 2009, 02:30am » |
|
Ah ha.
Code:
DEFFNRichEditStreamIn(filename$)
LOCAL hFile%, R%
REM Get the file handle
SYS "CreateFile", filename$, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0 TO hFile%
IF hFile% = INVALID_HANDLE_VALUE THEN
SYS "MessageBox",@hwnd%, "File not found.","",0
= 0
ENDIF
REM Create the EDITSTREAM structure
LOCAL EDITSTREAM{}
DIM EDITSTREAM{dwCookie%, dwError%, pfnCallBack%}
EDITSTREAM.dwCookie% = hFile%
EDITSTREAM.pfnCallBack% = FN_callback(FNEditStream(),4)
SYS FN_syscalls("SendMessage"), hRichEdit%, EM_STREAMIN, SF_RTF, EDITSTREAM{}
R% = FN_sysresult
REM Close the file
SYS "CloseHandle", hFile%
=R%
DEF FNEditStream(dwCookie%, buffer%, cb%, pcb%)
LOCAL R%
SYS "ReadFile", dwCookie%, buffer%, cb%, pcb%, 0 TO R%
= (R%=0)
This now works. Thank you. A typical mixture of errors on my part.
Michael
|
|
Logged
|
|
|
|
|