- To All The Masters - How do I get the correct font.Charset from a RichTextBox?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: - To All The Masters - How do I get the correct font.Charset from a RichTextBox?

  1. #1
    Join Date
    Jul 2005
    Posts
    87

    - To All The Masters - How do I get the correct font.Charset from a RichTextBox?

    I’m trying 2 get fonts Charset from a RichTextBox

    The font Script (Charset) is set 2 “Western” and when I click the Alt – Shift buttons the text in the RichTextBox is in any fonts language (“Hebrew”, ‘Arabic”, “Spanish” ….. and “Western”) as were installed in my Windows system.
    I want to emphasis, my problem is only when I press alt-shift, it works perfectly when I manually choose the font from the font list.

    For example:
    Assuming the language is set to “western”, which is the default option in most of our computers, and now I want 2 write in a different language, I press alt-shift.

    When I ask in my Project:
    “x = RichTextBox. Charset”, I get “x=0” (Western).

    This is not the printed language that I typed in the RichTextBox,
    I want to be able 2 get the right fonts name (for example: Arial (Western -Hebrew)), meaning, I want 2 get “x=177”.

    How can I get the correct font.Charset from my RichTextBox Control?

    How the **** did Microsoft made that function work in their WordPad and all of their Pads programs???
    Can any one please help me? It’s really hard 4 me 2 get it.
    I was in all the forums and I searched google but I couldn’t find what I was looking 4 and I know that it can be done.

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    imosha,

    I do not know if you are the same I answered to in the wrox forum.
    Did you try to catch the alt+shift in the richText keyDown event:

    If KeyCode = vbKeyShift And Shift = (vbAltMask + vbShiftMask) Then
    '' check for the current input locale, and set the font charset here
    End If

    this works with me (I can't test Hebrew because I do not have it installed)

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Jul 2005
    Posts
    87
    Yes it’s me
    I was also thinking abut that way
    How can i "check for the current input locale?”
    Do you have the code or where can i find it?

    Please you are the only one that makes sense.

    Thank u 4 all the help that u giving me

    i will search the code tomorrow u are a life saver
    Last edited by imosha; 07-20-2005 at 07:17 PM.

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Use this API:

    Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long

    dim k as long
    k = GetKeyboardLayout(0)

    unfortunatelly, the input locale does not change right way when you press alt+shift.
    what I do, is to set a timer (1 second), and test the language there. This is my code:

    Code:
    Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long
    Private Const LANG_HEBREW = &HD&
    
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyShift And Shift = (vbAltMask + vbShiftMask) Then
            Timer1.Enabled = True
        End If
    End Sub
    
    Private Sub Timer1_Timer()
        Timer1.Enabled = False
        Dim k As Long
        k = GetKeyboardLayout(0)
        If (k And &HFF) = LANG_HEBREW Then
            '' do something
        End If
    End Sub
    hope this helps,
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Similar Threads

  1. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 02:32 PM
  2. Masters degree or Specialize?
    By Carl in forum Careers
    Replies: 7
    Last Post: 08-03-2002, 11:16 AM
  3. Maintain MCSD or do Masters in IT?
    By Richard in forum Careers
    Replies: 5
    Last Post: 06-15-2001, 09:11 AM
  4. RichTextBox
    By James in forum VB Classic
    Replies: 2
    Last Post: 10-22-2000, 08:14 PM
  5. RichTextBox
    By James in forum VB Classic
    Replies: 0
    Last Post: 10-21-2000, 05:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center