Richtext unter PB 5.61

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
Velindos
Beiträge: 598
Registriert: 15.11.2010 10:56

Richtext unter PB 5.61

Beitrag von Velindos »

Hallo Leute,
teste gerade den PB 5.61 Stand. Dabei möchte ich
den Richtext von Gadget_0 auf Gadget_1 kopieren.

- geht nicht, verliert Format

Dann möchte ich das Gadget auslesen und in die Datenbank schreiben!

- geht auch nicht, habe kein Rich Format sondern Text.

Code: Alles auswählen

;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;

; PB 5.61 TESTEN der Richtext Funktionen

Global Window_0

Global Button_0, Button_1, Button_2, Editor_0, Editor_1, Text_0
Global sTxt.s = "{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fswiss\fcharset0 Arial;}}" 
sTxt = sTxt + "{\colortbl ;\red255\green0\blue0;}{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 Hello \cf1\fs32 TESTING\cf0\f1\fs20\par}"
Global Notiz$

Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu)
  Button_0 = ButtonGadget(#PB_Any, 30, 300, 100, 30, "")
  Button_1 = ButtonGadget(#PB_Any, 170, 300, 100, 30, "")
  Button_2 = ButtonGadget(#PB_Any, 310, 300, 90, 30, "")
  Editor_0 = EditorGadget(#PB_Any, 30, 80, 220, 200)
  Editor_1 = EditorGadget(#PB_Any, 340, 80, 220, 190)
  Text_0 = TextGadget(#PB_Any, 30, 20, 250, 25, "Richtext Copy von Gadget 0 => 1")
EndProcedure

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False
      
    Case #PB_Event_SizeWindow  

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
        Case Button_0
          SetGadgetText(Editor_0,sTxt)
        Case Button_1
          SetGadgetText(Editor_1,GetGadgetText(Editor_0))
        Case Button_2
          ; Gadgetinhalt als Richtext anzeigen!
          Notiz$ = GetGadgetText(Editor_0)
          Debug "RICHTTEXT= " + Notiz$
          
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure


OpenWindow_0()

Define WindowNr, EEvent

Repeat
  ;{ WindowNr
  WindowNr = EventWindow()    
  EEvent =  WaitWindowEvent() 
  ; ----------------------------------------------------------
  Select WindowNr
      ; Windows 
    Case Window_0
      Window_0_Events(EEvent)
  EndSelect
Until WaitWindowEvent()=#PB_Event_CloseWindow 
;}
Hat jemand eine Idee?

Gruss Velindos ...
Windows 7/8/8.1/10 (32/64-Bit) |Ubuntu 10.4 (64-Bit) |Purebasic 5.71 LTS (32/64-Bit)
Benutzeravatar
RSBasic
Admin
Beiträge: 8022
Registriert: 05.10.2006 18:55
Wohnort: Gernsbach
Kontaktdaten:

Re: Richtext unter PB 5.61

Beitrag von RSBasic »

Aus privaten Gründen habe ich leider nicht mehr so viel Zeit wie früher. Bitte habt Verständnis dafür.
Bild
Bild
Benutzeravatar
Velindos
Beiträge: 598
Registriert: 15.11.2010 10:56

Re: Richtext unter PB 5.61

Beitrag von Velindos »

Hallo RSBasic,
besten DANK für deinen TiP!

Code: Alles auswählen

;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-- EDITORGADGET
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Global EditorGadget_RawRichText$
Global Notiz$
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Get_EditorGadget_RawRichTextCB(dwCookie,pbBuff,cb,pcb)
  If cb
    EditorGadget_RawRichText$+PeekS(pbBuff,cb,#PB_Ascii)
  EndIf
  pcb=cb
EndProcedure
Procedure.s Get_EditorGadget_RawRichText(gad)
  EditorGadget_RawRichText$=""
  str.EDITSTREAM\dwCookie=0
  str\dwError=0
  str\pfnCallback=@Get_EditorGadget_RawRichTextCB()
  SendMessage_(GadgetID(gad),#EM_STREAMOUT,#SF_RTF,@str)
  ProcedureReturn EditorGadget_RawRichText$
EndProcedure
;}
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
rtf$="{\rtf1\ansi\ansicpg1252\deff0\uc1\pard\sa200\sl276\b\f0\fs22 do\b0  \i re\i0  \ul mi}"
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
OpenWindow(0,0,0,200,150,"test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Text ins EditorGadget
EditorGadget(0,10,10,180,50)
SetGadgetText(0,rtf$)
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Text ins TextGadget
TextGadget(1,10,70,180,100,"") ; Shows: {\rtf1\ansi\ ...
Notiz$ = Get_EditorGadget_RawRichText(0)
SetGadgetText(1,Notiz$)
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Gruss Velindos...
Windows 7/8/8.1/10 (32/64-Bit) |Ubuntu 10.4 (64-Bit) |Purebasic 5.71 LTS (32/64-Bit)
Antworten