Page 1 of 1
Posted: Sat Feb 23, 2002 4:42 pm
by BackupUser
Restored from previous forum. Originally posted by FAKEFACTORY.
Hi,
i'm currently stuck into a problem...
I need a Multiline Editcontrol (RichEdit) with the abbility to completly change the backgroundcolor of this control (not only text-background - the complete control should be colored, like the Purebasic editor).
My goal is to print green text on a black background (simulating an old monocolor-monitor)
Is someone here with a codesnipped, that can i use for this purpose, or ... Fred... how about uploading the Editor-Code? This would be a great source for learning and using.
Registered PureBasic Coder
Posted: Sat Feb 23, 2002 5:11 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.
Why not use El_Choni's RichEdit Library??
It easily lets you select background and text colors.
Posted: Sat Feb 23, 2002 5:24 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
Hi,
If you don't want to use the library, the following line should do what you need:
Code: Select all
SendMessage_(RichControlhWnd, #EM_SETBKGNDCOLOR, 0, BGR value) ;
Bye,
El_Choni
Posted: Sat Feb 23, 2002 6:34 pm
by BackupUser
Restored from previous forum. Originally posted by FAKEFACTORY.
Thx, El_Choni. This is exactly, what i need.
Registered PureBasic Coder
Posted: Sun Feb 24, 2002 5:07 am
by BackupUser
Restored from previous forum. Originally posted by TronDoc.
Code: Select all
SendMessage_(RichControlhWnd, #EM_SETBKGNDCOLOR, 0, BGR value) ;
could you give a small example? I can't get it to work. Joe
elecTRONics DOCtor
{registeredPB}P150 32Mb w98/DOS/Linux NO DirX NO IE

Posted: Sun Feb 24, 2002 12:06 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
Hi, try this:
UPDATED: added green text and face change, like you needed.
Code: Select all
#RICHEDIT = #WS_CHILD|#WS_VISIBLE|#WS_VSCROLL|#ES_MULTILINE|#ES_AUTOVSCROLL|#ES_NOHIDESEL
#SCF_ALL = 4
#SCF_SELECTION = $0001
#SCF_WORD = $0002
#WINDOW_PARAMETERS = #PB_Window_SystemMenu|#PB_Window_MinimizeGadget
If OpenWindow(0, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #WINDOW_PARAMETERS, "RichEdit example")
If LoadLibrary_("RICHED20.DLL")
RichClass.s = "RichEdit20A"
Else
If LoadLibrary_("RICHED32.DLL")
RichClass.s = "RichEdit"
Else
MessageRequester("Error", "RichEdit Windows library not present.", 0)
End
EndIf
EndIf
hWnd = CreateWindowEx_(#WS_EX_CLIENTEDGE, RichClass, "This will desappear with SetWindowText.", #RICHEDIT, 0, 0, WindowWidth(), WindowHeight(), WindowID(), 0, GetModuleHandle_(0), 0)
If hWnd
ShowWindow_(hWnd, #SW_HIDE) ; hide our changes to the user
SetWindowText_(hWnd, "Hi everybody!")
BGR = 0
SendMessage_(hWnd, #EM_SETBKGNDCOLOR, 0, BGR) ; BGR value = black
cf.CHARFORMAT
cf\cbSize = SizeOf(CHARFORMAT)
Red = 0
Green = 255
Blue = 0
BGR = (Blue*65536)|(Green*256)|Red
cf\crTextColor = BGR ; BGR value = green
FontFace.s = "Courier New"
For t = 0 To Len(FontFace)
cf\szFaceName[t] = Asc(Mid(FontFace, t+1, 1))
Next t
cf\dwMask =#CFM_COLOR|#CFM_FACE
SendMessage_(hWnd, #EM_SETCHARFORMAT, #SCF_ALL, @cf)
ShowWindow_(hWnd, #SW_SHOW) ; now show
SetForegroundWindow_(WindowID())
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
Else
MessageRequester("Error", "Could not create the RichEdit control.", 0)
End
EndIf
Else
MessageRequester("Error", "Could not create the main window.", 0)
EndIf
End
Bye,
Edited by - El_Choni on 24 February 2002 12:48:06
Posted: Sun Feb 24, 2002 3:16 pm
by BackupUser
Restored from previous forum. Originally posted by TronDoc.
Excellent! Thank you.
It looks pretty complicated, so
I'll have to spend some time
trying to understand it.
Posted: Sun Feb 24, 2002 6:49 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
You may also, as Paul said, use the RichEdit library, which would save more than 20 lines of code here and seems more human-friendly. But that's up to you. If you need any more help with RichEdit, just ask, I've become quite a RichEdit expert coding the lib
Bye,
El_Choni
Posted: Sun Feb 24, 2002 8:07 pm
by BackupUser
Restored from previous forum. Originally posted by TronDoc.
perhaps then, you could help Fred with
incorporating it into PureBASIC?
Posted: Sun Feb 24, 2002 9:49 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
It would seem like me asking my cat to help me with the RichEdit library. PureBasic uses a RichEdit control, so Fred must know everything about it, and I think he's been working on RTF support at least since June 2001. But RichEdit has lots of functionalities and issues to watch carefully, and there hasn't been too much postings asking him to add it, so I understand that he tries to fix bugs first and add improvements that people do ask for.
At least, that's what me and my cat think. Bye,
El_Choni
Posted: Mon Feb 25, 2002 1:53 am
by BackupUser
Restored from previous forum. Originally posted by TronDoc.
HaH HaH =-= good one El Choni!
I guess you set me straight..
..say "meow" to kitty for me.