It is currently Fri May 24, 2013 5:04 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject:
PostPosted: Sat Sep 08, 2001 2:22 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 08, 2001 4:03 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 08, 2001 4:14 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by ricardo.

Quote:
That's a really cool tip, thanks

Mr Skunk

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


Thank you Mr.Skunk


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 08, 2001 9:59 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by PB.

Quote:
;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...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 08, 2001 10:26 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by ricardo.

Quote:
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?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 09, 2001 5:03 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
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...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2001 1:03 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2001 3:15 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by PB.

Quote:
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2001 7:18 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 18, 2001 4:36 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 18, 2001 11:05 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by fred.

Quote:
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: woki and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye