RichEdit Functions (OOP) New: with Image-Support

Share your advanced PureBasic knowledge/code with the community.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 543
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by bbanelli »

Greetings to all, I'm having much difficulties with this RichEdit concept, perhaps I'm missing something:

Example used with modules here: http://www.realsource.de/downloads/doc_ ... edit-class

IMA's happens on defined RichEdit variables but not initialized by New_RichEdit. So, I'm having a large GUI where gadgets get created dynamically and only if needed. Naturally, EventGadget() that are not created are not fired at all, but for some reason, putting Case Edit\GetID() when Edit is not set with New_RichEdit fires IMA. Is there another approach to this issue? You can try this in RichEdit_Example.pb in last download file. If you comment out lines related to Edit = RichEdit::New_RichEdit and create any other gadget (for example, I added String gadget), compiling triggers IMA automatically, under the Select EventGadget() and Case Edit\GetID() part.

Image

In addition, how can I catch events in RichEditor gadget with GetActiveGadget()? It doesn't seem to be triggered by something like GetActiveGadget() = Edit\GetID()...
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by IdeasVacuum »

Broken link Thomas?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by RSBasic »

Image
Image
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by IdeasVacuum »

Thanks RS :mrgreen:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
cyril
User
User
Posts: 15
Joined: Sun Feb 23, 2020 4:28 pm

Re: RichEdit Functions (OOP) New: with Image-Support

Post by cyril »

Hi

I've started using your richedit.pbi version 2.4.

But I've noticed what seems a bug:
When I call the RichEdit's Clear function, the text alignment and the bullet stay.

Here is a code to test this which shows the problem:

Code: Select all

XIncludeFile "RichEdit.pbi"

UseModule RichEdit
Global RTFEditor.RichEdit

If OpenWindow(0, #PB_Ignore, #PB_Ignore, 640, 480, "RichEdit test", 
              #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  RTFEditor = New_RichEdit(0, 0, 640, 480)
  RTFEditor\SetAlignment(#PFA_RIGHT)
  RTFEditor\SetBulleted()
  
  RTFEditor\Clear()
  
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Unless I'm missing something, there is no way to reset the RTFModified status and the Bulleted state.
Last edited by cyril on Sun Feb 23, 2020 8:40 pm, edited 2 times in total.
cyril
User
User
Posts: 15
Joined: Sun Feb 23, 2020 4:28 pm

Re: RichEdit Functions (OOP) New: with Image-Support

Post by cyril »

I've made some modification to take in consideration my needs.

Here is the modified and added code:

Code: Select all

  
; Added  
Procedure.i RichEdit_GetBulleted(*this.RichEditClassTemplate)
    Protected format.PARAFORMAT
    format\cbSize = SizeOf(PARAFORMAT)
    format\dwMask = #PFM_NUMBERING
    format\wNumbering = #PFN_BULLET
    ;Read first
    SendMessage_(*this\hWnd, #EM_GETPARAFORMAT, 0, @format)
    
    ProcedureReturn format\wNumbering
EndProcedure
  
; Modified  
Procedure.i RichEdit_SetBulleted(*this.RichEditClassTemplate, numbering.i = #PFN_BULLET)  
    
    ; Description .......:  Start / Change Slection to Bulleting
    
     Protected format.PARAFORMAT
     format\cbSize = SizeOf(PARAFORMAT)
     format\dwMask = #PFM_NUMBERING
     format\wNumbering = #PFN_BULLET
     ;Read first
     SendMessage_(*this\hWnd, #EM_GETPARAFORMAT, 0, @format)
    
    format\dwMask = #PFM_NUMBERING
    format\wNumbering = numbering
    
    ProcedureReturn SendMessage_(*this\hWnd, #EM_SETPARAFORMAT, 0, @format)
EndProcedure
for the SetModified function, I made a parameter, which was hidden, apparent in the list of function :

Code: Select all

SetModified.i(state.i=#True)
SetBulleted has an added parameter too:

Code: Select all

SetBulleted.i(numbering.i = #PFN_BULLET)
siesit
User
User
Posts: 12
Joined: Fri Aug 21, 2009 8:40 am
Location: rus
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by siesit »

Please help friends.

I really like this module, but there is a crash during printing if the document has a table in which a line break occurs.

I don't know how to fix it :(
site created by purebasic work-flow-Initiative
BarryG
Addict
Addict
Posts: 3294
Joined: Thu Apr 18, 2019 8:17 am

Re: RichEdit Functions (OOP) New: with Image-Support

Post by BarryG »

ts-soft wrote: Wed Jul 20, 2011 12:40 amDownload with beginnerfriendly example here:
Download
Can't download; it wants me to sign up? Can you post it elsewhere? Thanks.
siesit
User
User
Posts: 12
Joined: Fri Aug 21, 2009 8:40 am
Location: rus
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by siesit »

BarryG wrote: Sat Oct 08, 2022 2:46 am Can't download; it wants me to sign up? Can you post it elsewhere? Thanks.
I downloaded the latest version from here
http://www.rsbasic.de/backupprogramme/temp/RichEdit.zip
site created by purebasic work-flow-Initiative
BarryG
Addict
Addict
Posts: 3294
Joined: Thu Apr 18, 2019 8:17 am

Re: RichEdit Functions (OOP) New: with Image-Support

Post by BarryG »

Thanks, siesit!
siesit
User
User
Posts: 12
Joined: Fri Aug 21, 2009 8:40 am
Location: rus
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by siesit »

New problem.
on windows 10 tables from opened .rtf files are not displayed :?
siesit wrote: Sat Oct 08, 2022 12:39 am Please help friends.

I really like this module, but there is a crash during printing if the document has a table in which a line break occurs.

I don't know how to fix it :(
site created by purebasic work-flow-Initiative
Karellen
User
User
Posts: 82
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Re: RichEdit Functions (OOP) New: with Image-Support

Post by Karellen »

Hello there,
I use this great module for several projects. With new PB-Versions I have the following problems:

PB 6.01 LTS:
Spell checking shows a black underline instead of the wavy red line.

PB 6.03 LTS:
Spell checking, text alignment and custom fonts don't work anymore.

My OS is Win 11.

Does anybody have a clue?
Stanley decided to go to the meeting room...
User avatar
OldSkoolGamer
Enthusiast
Enthusiast
Posts: 148
Joined: Mon Dec 15, 2008 11:15 pm
Location: Nashville, TN
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by OldSkoolGamer »

I also have an issue with this and the latest PB6.03, if you try to catchRTF a stored image in memory it just says "The system cannot find the file specified" Out of my expertise to fix or know what to look at.
Fred
Administrator
Administrator
Posts: 16622
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by Fred »

You need to enable the RTF mode for the editogadget. Put this code after the line '\hWnd = GadgetID(\ID)':

Code: Select all

SendMessage_(\hWnd, #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
Axolotl
Enthusiast
Enthusiast
Posts: 435
Joined: Wed Dec 31, 2008 3:36 pm

Re: RichEdit Functions (OOP) New: with Image-Support

Post by Axolotl »

and in the responsible procedure there is an 'unknown' value added to the structure member

Code: Select all

 
RichEdit_SetUnderlineWave(*this.RichEditClassTemplate)
  ; ... 
  format\bUnderlineType = #CFU_UNDERLINEWAVE ;| $50   ; <-- maybe this is the hack to get the RED (in older versions) ???? 
  ; ... 
The MSDN shows some more structue members like

Code: Select all

BYTE     bUnderlineColor;
And the color RED is defined like UnderlineColor_Red = 0x05, but that could also be a coincidence.

just my two cents.....
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
Post Reply