Is it possible integrate wxWidgets n a Lazarus windows? lazarus / 13-General ---------------------------------------------------------------------- Tommi · 2008-12-16 16:44 I'd like integrate wxWidgets controls in windows created with lazarus, is it possible ? I looked for guides with Google but I didn't find anything. Thanks ---------------------------------------------------------------------- Phil · 2008-12-16 17:01 Quote from: "Tommi"I'd like integrate wxWidgets controls in windows created with lazarus, is it possible ? I looked for guides with Google but I didn't find anything. Thanks To use any framework with LCL you would need a widgetset based on that framework. There is no such animal for wxWidgets. You could probably use wxWidgets directly and not use the LCL at all, but then you would lose the visual design of forms with Lazarus. What exactly do you need from wxWidgets? Thanks. -Phil ---------------------------------------------------------------------- Tommi · 2008-12-16 17:38 Quote from: "Phil"Quote from: "Tommi"I'd like integrate wxWidgets controls in windows created with lazarus, is it possible ? I looked for guides with Google but I didn't find anything. Thanks To use any framework with LCL you would need a widgetset based on that framework. There is no such animal for wxWidgets. You could probably use wxWidgets directly and not use the LCL at all, but then you would lose the visual design of forms with Lazarus. What exactly do you need from wxWidgets? Thanks. -Phil I need wxRichTextCtrl from WXWidgets or RichEdit from WinAPI. I prefer wxRichTextCtrl because it is multiplatform. I designed my window with lazarus editor, I need only to add a richedit or equivalent in a TPanel control, but I don't understand how. I tried SynEdit but it is useful for language editor, not so much to show text. ---------------------------------------------------------------------- Tommi · 2008-12-16 17:56 I tried this code, but it does nothing. Code: [Select] var   hWndTip: THandle;   ti: TOOLINFO;   hWnd: THandle;   x,y:integer;   awidth,aheight:integer; begin   hWnd    := Form1.Handle;   LoadLibrary('Riched20.dll');   hWndTip := CreateWindowEx(0, 'RICHEDIT_CLASS', 'Type here',ES_MULTILINE or WS_VISIBLE or WS_CHILD or WS_BORDER or WS_TABSTOP,              10,10,100,100,hWnd, 0, HInstance, nil); I haven't experience with direct winapi programming, can you see why it doesn't run ? ---------------------------------------------------------------------- Phil · 2008-12-16 18:16 Quote from: "Tommi"I tried this code, but it does nothing. Code: [Select] var   hWndTip: THandle;   ti: TOOLINFO;   hWnd: THandle;   x,y:integer;   awidth,aheight:integer; begin   hWnd    := Form1.Handle;   LoadLibrary(Pchar('Riched20.dll'));   hWndTip := CreateWindowEx(0, 'RICHEDIT_CLASS', PChar('Type here'),ES_MULTILINE or WS_VISIBLE or WS_CHILD or WS_BORDER or WS_TABSTOP,              10,10,100,100,hWnd, 0, HInstance, nil); I haven't experience with direct winapi programming, can you see why it doesn't run ? Sorry, can't help you with that. If you just need to display or print RTF, you might find this helpful: http://wiki.lazarus.freepascal.org/XDev_Toolkit Also, you're correct, SynEdit is not a word processor. Thanks. -Phil ---------------------------------------------------------------------- Tommi · 2008-12-17 13:10 Soluction (partial) found: Code: [Select] var a:integer; hWndTip:THandle; hWnd: THandle; begin   a:=LoadLibrary('riched32.dll');   if a>32 then showmessage('OK') else showmessage(inttostr(a));   hWnd    := Form1.Handle;   hWndTip := CreateWindowEx(0, 'RichEdit', 'Type here',ES_MULTILINE or WS_VISIBLE or WS_CHILD or WS_BORDER or WS_TABSTOP,              100,100,200,200,hWnd, 0, HInstance, nil); This code create a richedit box in a window ---------------------------------------------------------------------- Phil · 2008-12-17 15:04 Quote from: "Tommi"Soluction (partial) found: Code: [Select] var a:integer; hWndTip:THandle; hWnd: THandle; begin   a:=LoadLibrary('riched32.dll');   if a>32 then showmessage('OK') else showmessage(inttostr(a));   hWnd    := Form1.Handle;   hWndTip := CreateWindowEx(0, 'RichEdit', 'Type here',ES_MULTILINE or WS_VISIBLE or WS_CHILD or WS_BORDER or WS_TABSTOP,              100,100,200,200,hWnd, 0, HInstance, nil); This code create a richedit box in a window Just remember that this code ties your program to Windows. You won't be able to compile on Linux or OS X. Thanks. -Phil ---------------------------------------------------------------------- Tommi · 2008-12-17 17:46 Quote from: "Phil"Quote from: "Tommi"Soluction (partial) found: Code: [Select] var a:integer; hWndTip:THandle; hWnd: THandle; begin   a:=LoadLibrary('riched32.dll');   if a>32 then showmessage('OK') else showmessage(inttostr(a));   hWnd    := Form1.Handle;   hWndTip := CreateWindowEx(0, 'RichEdit', 'Type here',ES_MULTILINE or WS_VISIBLE or WS_CHILD or WS_BORDER or WS_TABSTOP,              100,100,200,200,hWnd, 0, HInstance, nil); This code create a richedit box in a window Just remember that this code ties your program to Windows. You won't be able to compile on Linux or OS X. Thanks. -Phil yes, I know, but my application needs some control to show a text with some word (search result) colored to distiguish them from others. I think it should be possible create a control cross platform with some basic formatting option but I have no time. So use richedit is more avaiable soluction. ---------------------------------------------------------------------- theo · 2008-12-17 17:52 If you only need to _show_ text, then take TIpHTMLPanel and mark the words with HTML Code before streaming in. ---------------------------------------------------------------------- Tommi · 2008-12-17 20:18 Quote from: "theo"If you only need to _show_ text, then take TIpHTMLPanel and mark the words with HTML Code before streaming in. Yes, I tried but if the text is too big I receive 'List out of Bounds(0)' error. I don't know why. In any case I post an example code to show how use richEdit in a form, hoping it is useful for someone. Quote unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls, ExtCtrls,windows; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     Button2: TButton;     Panel1: TPanel;     procedure Button1Click(Sender: TObject);     procedure Button2Click(Sender: TObject);     procedure FormCreate(Sender: TObject);     procedure FormDestroy(Sender: TObject);     procedure Panel1Resize(Sender: TObject);   private     { private declarations } hWndTip:THandle; Rect:Trect;   public     { public declarations }   end; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.Button2Click(Sender: TObject); var a:PChar; b:string; c:integer; afont:TCHARFORMAT; begin   b:='Hello';   a:=PChar(b);   c:=Integer(a);   FillChar(afont, SizeOf(afont), 0);   afont.cbSize:=Sizeof(afont);   afont.dwMask:=CFM_COLOR or CFM_UNDERLINE or CFM_ITALIC or CFM_OFFSET;   afont.dwEffects:=CFE_ITALIC;   afont.yOffset:=-10;   afont.crTextColor:=clBlue;   SendMessage(hWndTip, EM_SETCHARFORMAT, SCF_SELECTION, LongInt(@afont));   sendmessage(hWndTip, EM_REPLACESEL, 0,c); end; procedure TForm1.Button1Click(Sender: TObject); var a:PChar; b:string; c:integer; afont:TCHARFORMAT; begin   b:='GoodMorning';   a:=PChar(b);   c:=Integer(a);   FillChar(afont, SizeOf(afont), 0);   afont.cbSize:=Sizeof(afont);   afont.dwMask:=CFM_COLOR or CFM_BOLD or CFM_OFFSET or CFM_ITALIC;   afont.dwEffects:=CFE_BOLD;   afont.yOffset:=0;   afont.crTextColor:=clGreen;   SendMessage(hWndTip, EM_SETCHARFORMAT, SCF_SELECTION, LongInt(@afont));   sendmessage(hWndTip, EM_REPLACESEL, 0,c); end; procedure TForm1.FormCreate(Sender: TObject); var a:integer; hWnd: THandle; begin   a:=LoadLibrary('riched32.dll');   if a<=32 then showmessage('Error creating RICHEDIT');   hWnd    := Panel1.Handle;   hWndTip := CreateWindowEx(WS_EX_CLIENTEDGE, 'RichEdit', '',ES_MULTILINE or WS_VISIBLE or WS_CHILD or WS_BORDER or ES_DISABLENOSCROLL or ES_AUTOVSCROLL,              0,0,100,100,hWnd, 0, HInstance, nil);   rect.Bottom:=panel1.Height;   MoveWindow(hWndTip, 3, 3, rect.right - 6, rect.bottom - 6, true); end; procedure TForm1.FormDestroy(Sender: TObject); begin   DestroyWindow(hWndTip); end; procedure TForm1.Panel1Resize(Sender: TObject); begin  rect.Bottom:=panel1.Height;  rect.Right:=panel1.Width;  MoveWindow(hWndTip, 3, 3, rect.right - 6, rect.bottom - 6, true); end; initialization   {$I unit1.lrs} end.