Recent

Author Topic: Automatic font change  (Read 40527 times)

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #15 on: October 21, 2016, 01:24:10 pm »
WordPad has no function for turning off font switching. Microsofts keyboard layouts are not unified for Semitic and Semitic based languages, which makes them difficult to learn.

The problem is not with my code. Half of it is your own. The functions that I have built are within the rules. I haven't forced anything. The problem is that Microsoft is withholding functionality. They have published RichEdit and RTF rules and functions, but they are not operational.

Rick

Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #16 on: October 21, 2016, 07:49:33 pm »
I found some code in a unit for Delphi, so I am pretty confident that it works for that environment. RichMemo is processing (it doesn't kick anything back) but it is not having any effect. So what is it that is happening (rather, not happening)?

Code: Pascal  [Select][+][-]
  1. procedure TCmdForm.AutoKeyboardOff;
  2. var opt: LResult; // some do integer
  3. const
  4.   IMF_AUTOKEYBOARD        = $0001; // active by load file
  5.   IMF_AUTOFONT            = $0002; // active by default
  6.   IMF_IMECANCELCOMPLETE   = $0004; // high completes output on abort, low cancels ...not active
  7.   IMF_IMEALWAYSSENDNOTIFY = $0008; // active by default
  8. begin
  9. opt:= SendMessage(PageMemo.handle, EM_GETLANGOPTIONS, 0, 0); //showmessage('kbd get: '+inttostr(opt));
  10. if ((opt and IMF_AUTOKEYBOARD)<>0) then Dec(opt, IMF_AUTOKEYBOARD);
  11. SendMessage(PageMemo.handle, EM_SETLANGOPTIONS, 0, LPARAM(opt)); //showmessage('kbd set: '+inttostr(opt));
  12. end;
  13.  
  14. procedure TCmdForm.AutoFontOff;
  15. var opt: LResult; // some do integer
  16. const
  17.   IMF_AUTOKEYBOARD        = $0001; // active by load file
  18.   IMF_AUTOFONT            = $0002; // active by default
  19.   IMF_IMECANCELCOMPLETE   = $0004; // high completes output on abort, low cancels ...not active
  20.   IMF_IMEALWAYSSENDNOTIFY = $0008; // active by default
  21. begin
  22. // SendMessageW (Unicode) and SendMessageA (ANSI)
  23. // does not help to use SendMessageW, nor to invoke RichEdit.EM_
  24. opt:= SendMessage(PageMemo.handle, EM_GETLANGOPTIONS, 0, 0);  //showmessage('fnt get: '+inttostr(opt));
  25. if ((opt and IMF_AUTOFONT)<>0) then Dec(opt, IMF_AUTOFONT);
  26. SendMessage(PageMemo.handle, EM_SETLANGOPTIONS, 0, LPARAM(opt));  //showmessage('fnt set: '+inttostr(opt));
  27. end;
  28.  

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Automatic font change
« Reply #17 on: October 21, 2016, 08:32:13 pm »
just do this :)
Code: Pascal  [Select][+][-]
  1.   SendMessage(PageMemo.handle, EM_SETLANGOPTIONS, 0, 0);
  2.  

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #18 on: October 22, 2016, 01:15:24 pm »
Quote
SendMessage(PageMemo.handle, EM_SETLANGOPTIONS, 0, 0);

No, it does not respond to a 0,0 setting. The communication just isn't there.

One amendment... EM_GETLANGOPTIONS did report that it was set to 0.

Rick
« Last Edit: October 22, 2016, 01:25:32 pm by rick2691 »
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #19 on: October 22, 2016, 03:26:05 pm »
OK. I have not been able to disable font switching, but I have found a way to avoid it.

What I have been doing is posting a table (by tabbing) of keyboard keys and resulting language display results.

The remedy is to activate English, type, tab, then activate Hebrew, type, and activate English and tab.

Before, I had been staying in Hebrew for the Tab, and the same for Syriac and Greek.

By making sure that I was wrapping the characters in English tabs had caused RichEdit to not switch the fonts.

The same would apply to start & ending spaces and the same with punctuations. They need to be typed in your dominant language.

It is a tedious operation if you are trying to write a Keyboard Manual, but it minimally helps with my current sanity.

Please don't let this be a reason to forget about the problem... "autofont" needs to be disabled. Without "autofont" a user can type freely without tedious rules.

Rick

Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #20 on: October 24, 2016, 03:35:34 pm »
My system has Msftedit.dll, Richedit20.dll, and Richedit32.dll

You have previously posted that RichMemo opts for Msftedit.dll first, and uses Richedit20.dll if it is absent. Would there be a way to have it use Richedit20.dll first?

It may be that the misfunctions that I encounter are due to Msftedit.dll

To test it I tried to remove Msftedit.dll from my system, but the system just reinstalled it.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Automatic font change
« Reply #21 on: October 24, 2016, 03:41:00 pm »
To test it I tried to remove Msftedit.dll from my system, but the system just reinstalled it.
please don't do such horrible things to your system :) it doesn't deserve it.

Instead change the code in Win32RichMemoProc.pas.
Find InitRichEdit function and comment out Msftedit.dll usage code like this:
Code: Pascal  [Select][+][-]
  1. function InitRichEdit: Boolean;
  2. begin
  3.   if GlobalRichClass = '' then begin
  4.     {if LoadLibrary('Msftedit.dll') <> 0 then begin
  5.       GlobalRichClass := 'RichEdit50W';
  6.     end else} if LoadLibrary('RICHED20.DLL') <> 0 then begin
  7.       if UnicodeEnabledOS then GlobalRichClass := 'RichEdit20W'
  8.       else
  9.       GlobalRichClass := 'RichEdit20A'
  10.     end else if LoadLibrary('RICHED32.DLL') <> 0 then begin
  11.       GlobalRichClass := 'RichEdit';
  12.     end;
  13.      
  14.     if not Assigned(RichEditManager) then
  15.       RichEditManager := TRichEditManager;
  16.      
  17.     Result := GlobalRichClass <> '';
  18.   end;
  19. end;
  20.  

I was planning to add explicit dll and richedit class selection for Windows.
But for whatever reason it was not completed.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Automatic font change
« Reply #22 on: October 24, 2016, 04:38:41 pm »
I was planning to add explicit dll and richedit class selection for Windows.
But for whatever reason it was not completed.
and now it is done - r5289 allows to override richedit's class used by RichMemo.

Naturally, with the class overridden the proper .dll loading is now a responsibility of the user's code.

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #23 on: October 24, 2016, 05:48:22 pm »
How do I set the class?
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Automatic font change
« Reply #24 on: October 24, 2016, 05:56:22 pm »
How do I set the class?
You need to use the latest revision.
Add "Win32RichMemo" to your uses section. The unit exposes RichEditClass variable, you need to assign a value to it.
Please note that the class might require you to load a specific .DLL version. (you should be able to find the listing of versions + class names + dlls on MSDN. MSDN gives the class name as "RICHEDIT_CLASS" it's not an actual string, but rather a constant name in MSDN headers. To find the actual string you should google for "define RICHEDIT_CLASS"
which might look like this:
Code: [Select]
/* Richedit2.0 Window Class. */

#define RICHEDIT_CLASSA "RichEdit20A"
#define RICHEDIT_CLASS10A "RICHEDIT" // Richedit 1.0

#ifndef MACPORT
#define RICHEDIT_CLASSW L"RichEdit20W"
#else /*----------------------MACPORT */
#define RICHEDIT_CLASSW TEXT("RichEdit20W") /* MACPORT change */
#endif /* MACPORT  */

#if (_RICHEDIT_VER >= 0x0200 )
#ifdef UNICODE
#define RICHEDIT_CLASS RICHEDIT_CLASSW
#else
#define RICHEDIT_CLASS RICHEDIT_CLASSA
#endif /* UNICODE */
#else
#define RICHEDIT_CLASS RICHEDIT_CLASS10A
#endif /* _RICHEDIT_VER >= 0x0200 */
)

Here's an example:
Code: Pascal  [Select][+][-]
  1. uses
  2.   Windows .... , Win32RichMemo;
  3.  
  4.  
  5. procedure TForm1.FormCreate(Sender: TObject);
  6. begin
  7.   LoadLibrary('RICHED32.DLL'); // loading the dll
  8.   RichEditClass := 'RichEdit20W'; // specifying the class
  9. end;
  10.  
  11.  
That's it. Make sure you specify the class and load the library before a RichMemo is actually created.
FormCreate() method is fine. You could also put the code into "initialization" section of your unit.
« Last Edit: October 24, 2016, 05:58:39 pm by skalogryz »

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #25 on: October 24, 2016, 06:32:29 pm »
I am looking at r5289. It doesn't have anything in it for RichEdit20W or RICHEDIT_CLASSW nor anything called for in your post.

To be clear... with the entries:

LoadLibrary('RICHED32.DLL'); // loading the dll
RichEditClass := 'RichEdit20W'; // specifying the class

Isn't RICHED32.DLL for RichEdit version 1? Wouldn't I want to try RICHED20.DLL first?
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #26 on: October 24, 2016, 06:52:49 pm »
Also, should I still do those edits to Win32RichMemoProc?
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Automatic font change
« Reply #27 on: October 24, 2016, 07:31:39 pm »
I am looking at r5289. It doesn't have anything in it for RichEdit20W or RICHEDIT_CLASSW nor anything called for in your post.
The change itself is to make win32 implementation more dynamic, so any class could be used.
So don't except to see RichEdit20W or RICHEDIT_CLASSW there.

Isn't RICHED32.DLL for RichEdit version 1? Wouldn't I want to try RICHED20.DLL first?
You're right, you should try RICHED20.DLL first

Also, should I still do those edits to Win32RichMemoProc?
No, please revert any changes made to Win32RichMemoProc.

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #28 on: October 24, 2016, 08:08:17 pm »
Done deal. I'll try it out.
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Automatic font change
« Reply #29 on: October 24, 2016, 08:14:22 pm »
raised exception win32richmemo line 494

I had used...

LoadLibrary('RICHED20.DLL');  // loading the dll  // 'RICHED32.DLL'
 RichEditClass := 'RichEdit20W'; // specifying the class
« Last Edit: October 24, 2016, 08:18:27 pm by rick2691 »
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

 

TinyPortal © 2005-2018