Page 1 of 1

Posted: Sat Sep 08, 2001 2:22 pm
by BackupUser
Restored from previous forum. Originally posted by ricardo.

;This example creates a NOTEPAD like with RICHEDIT (RICHED32) by Ricardo Arias
;You can set ALL the parameters in ONE CONSTANT to call the CreateWindowEx API CALL

#RICHEDIT = #WS_CHILD | #WS_VISIBLE |#WS_VSCROLL |#ES_MULTILINE |#ES_AUTOVSCROLL
#WINDOW_PARAMETERS = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget
#WindowHeight = 400
#WindowWidth = 470
#WM_CUT = $300
#WM_COPY = $301
#WM_PASTE = $302
text.s = ""

RichEditText.s = "This is a simple example of RichEdit in PureBasic" + chr(10) + chr(10) + "Multiline is enable!! and scrollbar"

If CreateMenu(0)
MenuTitle("File")
MenuItem( 1, "&Read RichEdit")
MenuItem( 2, "&Destroy RichEdit")
MenuItem( 3, "&Create RichEdit")
MenuTitle("Edition")
MenuItem( 4, "&Cut")
MenuItem( 5, "&Copy")
MenuItem( 6, "&Paste")
EndIf

If OpenWindow(0,100,100, #WindowWidth, #WindowHeight, #WINDOW_PARAMETERS ,"NotePad in PB")

AttachMenu(0, WindowID())

class$ = "Class1" ;The class of the window
exe$ = "NotePad in PB" ;The caption of the window

RESULTADO = FindWindow_(class$,exe$)

module = GetModuleHandle_("abc.EXE")
result = FindWindow_(class$,exe$)
LoadLibrary_("RICHED32.DLL")
hwn = CreateWindowEx_(#WS_EX_CLIENTEDGE ,"RichEdit",RichEditText,#RICHEDIT,5,5,450,340,result,1,module,0)

EndIf




Repeat
EventID.l = WaitWindowEvent()

If EventID = #PB_EventMenu

Select EventMenuID()

Case 1 ; Read RichEdit
len = GetWindowTextLength_(hwn)
GetWindowText_(hwn,text,len + 2)
messagerequester("This is the text displayed on the RichEditGadget",text,0)

Case 2 ; Destroy it
dsthwn = DestroyWindow_(hwn)
hwn = 0

Case 3 ; Create a new richedit
If dsthwn = 1 ;if we dont use this condition, the user can create any number of controls
hwn = CreateWindowEx_(#WS_EX_CLIENTEDGE ,"RichEdit",RichEditText,#RICHEDIT,5,5,450,340,result,1,module,0)
dsthwn = 0
EndIf

Case 4 ; Cut
SendMessage_(hwn,#WM_CUT,0,0)

Case 5 ; Copy
SendMessage_(hwn,#WM_COPY,0,0)

Case 6 ; Paste
SendMessage_(hwn,#WM_PASTE,0,0)

EndSelect
EndIf

Until EventID = #PB_EventCloseWindow

End

Posted: Sat Sep 08, 2001 4:03 pm
by BackupUser
Restored from previous forum. Originally posted by Mr.Skunk.

That's a really cool tip, thanks

Mr Skunk

Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st

Posted: Sat Sep 08, 2001 4:14 pm
by BackupUser
Restored from previous forum. Originally posted by ricardo.
That's a really cool tip, thanks

Mr Skunk

Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
Thank you Mr.Skunk

Posted: Sat Sep 08, 2001 9:59 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
;This example creates a NOTEPAD like with RICHEDIT (RICHED32) by Ricardo Arias
One problem: if the user doesn't have riched32.dll installed, it won't work.
I just tried it and it failed...

Posted: Sat Sep 08, 2001 10:26 pm
by BackupUser
Restored from previous forum. Originally posted by ricardo.
One problem: if the user doesn't have riched32.dll installed, it won't work.
I just tried it and it failed...
See the WIN32 reference, wich windows version do you have?

Posted: Sun Sep 09, 2001 5:03 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

You missed my point, which is that your app is going to have
to check that riched32.dll is installed. That is, you can't
just assume that it will be on all systems, even if it does
get installed with Windows. Remember that files can get
corrupted or deleted by users by mistake...

Posted: Mon Sep 10, 2001 1:03 pm
by BackupUser
Restored from previous forum. Originally posted by ricardo.

ah, ok.
well, this was just an example not an application...
however, yes, in a real application every one has to look for every external file before calling it

Regards,

Ricardo Arias

Posted: Mon Sep 10, 2001 3:15 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
ah, ok.
well, this was just an example not an application...
however, yes, in a real application every one has to look for every external file before calling it
I hope I didn't offend you... I was just pointing that out for
the benefit of any lurkers here, that's all.

Posted: Mon Sep 10, 2001 7:18 pm
by BackupUser
Restored from previous forum. Originally posted by ricardo.


Not at all my friend, im trying to learn and any help are welcome
I notice that some users (Mr.Skunk, Blueb,Paul, You and others are always
trying to help and i respect that a lot !!)

Thanks

Ricardo

Posted: Tue Sep 18, 2001 4:36 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.

Good work Ricardo!
Question:
you load a DLL with: LoadLibrary_("RICHED32.DLL")but you don't use the
'FreeLibrary_("RICHED32.DLL")' command at the end of your code.

Is this not needed? I'm worried about memory leaks.



Have a nice day...
Franco

Posted: Tue Sep 18, 2001 11:05 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
Good work Ricardo!
Question:
you load a DLL with: LoadLibrary_("RICHED32.DLL")but you don't use the
'FreeLibrary_("RICHED32.DLL")' command at the end of your code.

Is this not needed? I'm worried about memory leaks.



Have a nice day...
Franco
This is not necessary as an application ALWAYS free unnucessary stuffs at end (Thanks to Windows)..

Fred - AlphaSND