Editorgadget (windows) broken with RTF table

Just starting out? Need help? Post your questions and find answers here.
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Editorgadget (windows) broken with RTF table

Post by drgolf »

Editorgadget dont works with rtf table.

This code works with PB 5.46 but not with PB5.73 or 6 (WINDOWS)
Any suggestion ?

Code: Select all

Enumeration
  #Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
  #Editor_0
EndEnumeration
;}
;}
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 529, 111, 400, 400,"Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
    EditorGadget(#Editor_0, 30, 20, 330, 220)
    
    t$="{\rtf1\ansi\deff0"
t$+"\trowd"
t$+"\cellx1000"
t$+"\cellx2000"
t$+"\cellx3000"
t$+"\intbl cell 1\cell"
t$+"\intbl cell 2\cell"
t$+"\intbl cell 3\cell"
t$+"\row"
t$+"} "
SetGadgetText(#Editor_0,t$)
  EndIf
EndProcedure

OpenWindow_Window_0()

;{- Event loop
Repeat
  Event = WaitWindowEvent()
  Select Event
    ; ///////////////////
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Editor_0
      EndSelect
    ; ////////////////////////
    Case #PB_Event_CloseWindow
      Select EventWindow()
        Case #Window_0
          CloseWindow(#Window_0)
          Break
      EndSelect
  EndSelect
ForEver

// Moved from "Bugs" to "Coding Questions" (Kiffi)
User avatar
mk-soft
Always Here
Always Here
Posts: 6205
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Editorgadget (windows) broken with RTF table

Post by mk-soft »

No broken, PB its Unicode

Solution : https://www.purebasic.fr/english/viewto ... 36#p520036
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Re: Editorgadget (windows) broken with RTF table

Post by drgolf »

thanx for your answer.

Dont work with your snippet with table in RTF.

Work on unicode or not with earlier version of PB.
Axolotl
Addict
Addict
Posts: 802
Joined: Wed Dec 31, 2008 3:36 pm

Re: Editorgadget (windows) broken with RTF table

Post by Axolotl »

Honestly, I do not have any idea, why that does not work.
Recently I followed a discussion about the support of the latest Rich Text Control (RichClass.s = "RichEdit50W")
So I was thinking that this will happen.
Maybe there is an reduced feature set implemented in PB.
With the windows API you can do what you want.

Code: Select all

#MainWindow = 1
#RICHEDITFLAGS = #WS_CHILD|#WS_VISIBLE|#WS_VSCROLL|#ES_MULTILINE|#ES_AUTOVSCROLL|#ES_NOHIDESEL

If OpenWindow(#MainWindow, 100, 200, 640, 480, "PureBasic Window", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget) 
  If  LoadLibrary_("MSFTEDIT.dll")
    RichClass.s = "RichEdit50W"
  ElseIf LoadLibrary_("RICHED20.DLL")
    RichClass.s = "RichEdit20A"
  ElseIf LoadLibrary_("RICHED32.DLL")
    RichClass.s = "RichEdit"
  Else
    MessageRequester("Error", "RichEdit Windows library not present.", 0)
    End
  EndIf   :Debug "RichClass == "+RichClass 
 
  hWnd = CreateWindowEx_(#WS_EX_CLIENTEDGE, RichClass, "This will With SetWindowText.", #RICHEDITFLAGS, 2, 2, 636, 476, WindowID(#MainWindow), 0, GetModuleHandle_(0), 0)
  If hWnd <> 0
    SetWindowText_(hWnd, "Move Cursor behind --+ and Press Enter:"+#CRLF$+"+---+---+---+")
;   SetForegroundWindow_(1)
  EndIf 
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break 
    EndSelect
  ForEver 
EndIf
End 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Axolotl
Addict
Addict
Posts: 802
Joined: Wed Dec 31, 2008 3:36 pm

Re: Editorgadget (windows) broken with RTF table

Post by Axolotl »

Second Version: With your Text you need such a function.

Code: Select all


Procedure.i SetRichEditText(hwnd, Text$) 
  Protected ret, settext.SETTEXTEX 
  Protected *mem 

  *mem = AllocateMemory(MemoryStringLength(@Text$, #PB_Unicode) + SizeOf(Character)) 
  If *mem 
    PokeS(*mem, Text$, -1, #PB_UTF8) 
    ret = SendMessage_(hwnd, #EM_SETTEXTEX, settext, *mem)                :Debug " #EM_SETTEXTEX -- result = " + ret  
    FreeMemory(*mem) 
  EndIf 
  ProcedureReturn ret  ;' returns 0|1 -- 1 = text is successfully set 
EndProcedure ;() 


#MainWindow = 1
#RICHEDITFLAGS = #WS_CHILD|#WS_VISIBLE|#WS_VSCROLL|#ES_MULTILINE|#ES_AUTOVSCROLL|#ES_NOHIDESEL

If OpenWindow(#MainWindow, 100, 200, 640, 480, "PureBasic Window", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget) 
  If  LoadLibrary_("MSFTEDIT.dll")
    RichClass.s = "RichEdit50W"
  ElseIf LoadLibrary_("RICHED20.DLL")
    RichClass.s = "RichEdit20A"
  ElseIf LoadLibrary_("RICHED32.DLL")
    RichClass.s = "RichEdit"
  Else
    MessageRequester("Error", "RichEdit Windows library not present.", 0)
    End
  EndIf   :Debug "RichClass == "+RichClass 
 
  hWnd = CreateWindowEx_(#WS_EX_CLIENTEDGE, RichClass, "This will With SetWindowText.", #RICHEDITFLAGS, 2, 2, 636, 476, WindowID(#MainWindow), 0, GetModuleHandle_(0), 0)
  If hWnd <> 0
;   SetWindowText_(hWnd, "Move Cursor behind --+ and Press Enter:"+#CRLF$+"+---+---+---+")

    t$="{\rtf1\ansi\deff0"
    t$+"\trowd"
    t$+"\cellx1000"
    t$+"\cellx2000"
    t$+"\cellx3000"
    t$+"\intbl cell 1\cell"
    t$+"\intbl cell 2\cell"
    t$+"\intbl cell 3\cell"
    t$+"\row"
    t$+"} "

  ; SetWindowText_(hWnd, t$)
    SetRichEditText(hwnd, t$) 
  EndIf 
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break 
    EndSelect
  ForEver 
EndIf
End 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Post Reply