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