FbEdit

User projects written in or related to FreeBASIC.
spartacus13012
Posts: 18
Joined: Nov 30, 2014 12:37
Location: FRANCE

Re: FbEdit

Postby spartacus13012 » Aug 17, 2015 20:51

St_W wrote:
spartacus13012 wrote:[..] I ended up making that I wanted: one which opens as ' encodes snipplets ' and which shows every ' TODO: contained in a file.

Now I would like to see the functioning of an addin which would intercept evenements keyboard and mouse in editeur of text of fbedit.
A generous ame would have it deja had resoudre has this probleme.

Your approach does not work because of multiple reasons:
1. there is no single edit control - a new edit control is created for each new file opened. lpHANDLES->hred is zero at plugin initialization
2. the RAEdit control consists of multiple child-windows, which receive and handle most window messages. the probably most important one is RAEditChild, which contains the editor window. For some reason there are 2 such RAEditChild windows - you could look into the RAEdit source code to find out why and what it does.

You can do it like this:
1. specify HOOK_CREATEEDIT to receive notifications on RAEdit control creation
2. handle AIM_CREATEEDIT:
2.a: Retrieve RAEditChild window handles from RAEdit window handle (passed as wParam)
2.b: Subclass the child window
2.c: Save the old wndProc
3. Call the old wndProc in the new wndProc

Some concept code:

Code: Select all

#Include Once "windows.bi"
#include once "win/richedit.bi"
#include once "win/commctrl.bi"

#Include Once "fbedit/raedit.bi"
#Include Once "fbedit/addins.bi"


Dim Shared As Integer lpOldWndProcEdit

'FBedit Addin Variables
Dim Shared hooks as ADDINHOOKS
Dim Shared lpHandles as ADDINHANDLES ptr
Dim Shared lpFunctions as ADDINFUNCTIONS ptr
Dim Shared lpData as ADDINDATA Ptr


Function InstallDll CDECL alias "InstallDll" (byval hWin as HWND,byval hInst as HINSTANCE) as ADDINHOOKS ptr EXPORT

   lpHandles = Cast(ADDINHANDLES ptr, SendMessage(hWin, AIM_GETHANDLES, 0, 0))
   lpData = Cast(ADDINDATA ptr, SendMessage(hWin, AIM_GETDATA, 0, 0))
   lpFunctions = Cast(ADDINFUNCTIONS ptr, SendMessage(hWin,AIM_GETFUNCTIONS, 0, 0))
   
   OutputDebugString("TEST: Install")
   'DebugBreak()
   

   Dim tmp As String
   tmp = Str(lpHandles->hred)
   OutputDebugString(StrPtr(tmp))

   hooks.hook1 = HOOK_CREATEEDIT
   hooks.hook2 = 0
   hooks.hook3 = 0
   hooks.hook4 = 0
   return @hooks

End Function


Function WndProcEdit(ByVal hWin_ As HWND, _
              ByVal uMsg_ As UINT, _
              ByVal wParam_   As WPARAM, _
              ByVal lParam_   As LPARAM) As Integer
             
  'Dim As String wmName
  'wmName = "TEST: edit ctl wndProc "+getWMName(uMsg_)
  'OutputDebugString(StrPtr(wmname))
 
  Select Case uMsg_
      Case WM_LBUTTONDOWN
          OutputDebugString("TEST: 2 bouton souris dans edit") 
  End Select

  Return CallWindowProc(lpOldWndProcEdit, hWin_, uMsg_, wParam_, lParam_)
End Function
   

Function DllFunction CDECL alias "DllFunction" (byval hWin as HWND,byval uMsg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as bool EXPORT
   
   Select Case uMsg
                  
      Case AIM_CREATEEDIT
         OutputDebugString("TEST: EditCreated")
         Dim As String tmp
         tmp = "TEST: Edit Ctl hWnd " + hex(wParam, 8)
         OutputDebugString(StrPtr(tmp))
         Dim As HWND editChildhWnd, editChildhWnd2
         editChildhWnd = FindWindowEx(wParam, 0, @"RAEditChild", 0)
         editChildhWnd2 = FindWindowEx(wParam, editChildhWnd, @"RAEditChild", 0)
         tmp = "TEST: Edit Child 1 Ctl hWnd " + Hex(editChildhWnd, 8)
         OutputDebugString(StrPtr(tmp))
         tmp = "TEST: Edit Child 2 Ctl hWnd " + Hex(editChildhWnd2, 8)
         OutputDebugString(StrPtr(tmp))
         
         lpOldWndProcEdit = SetWindowLong(editChildhWnd2, GWL_WNDPROC, @WndProcEdit)
         

   end select
   return FALSE
End Function


Thank you for the answer I am going to try in succession
spartacus13012
Posts: 18
Joined: Nov 30, 2014 12:37
Location: FRANCE

Re: FbEdit

Postby spartacus13012 » Aug 27, 2015 21:29

Greeting of France,

I have use the code which St_W has me deal, and it works perfectly.

Now I have a problem in my code which consists in changing the back color of identical all words has selection.

When I change back color by the message EM_SETCHARFORMAT with a variable of type CHARFORMAT2, the sendmessage return a zero.

Whatever modifs.

Me lack it something?

There at it a thing which I ignore sweats this message

Thank you in advance

My code

Code: Select all

   Type enrselect
      Dim posorigine      As Integer
      Dim posfin         As Integer      
      Dim chaine         As ZString * (1024*10)   'String
      Dim encours         As Integer
      Dim colbackligne   As COLORREF
      Dim colbackfond   As COLORREF
   End Type

   Dim Shared doubleselecttext         As Integer = FALSE
   Dim Shared memenregselect            As enrselect

   Sub displaySelect(ByVal hWin_ As HWND, _
                     ByVal match As Integer)      'TODO: 0000
      Dim poschaine      As Integer
      Dim txtrange       As TEXTRANGE
      Dim buffer         As ZString * (1024*10)
      
      'Dim poscarstart   As integer
      'Dim poscarend      As Integer
      'Dim texte      As String
      
      ' charge la chaine a chercher dans editeur
      poschaine = SendMessage(hWin_, EM_GETSEL, 0, 0)
      
      memenregselect.posorigine = LoWord(poschaine)
      memenregselect.posfin = HiWord(poschaine)
      
      txtrange.chrg.cpMin = memenregselect.posorigine
      txtrange.chrg.cpMax = memenregselect.posfin
      
      txtrange.lpstrText = @buffer
      SendMessage(hWin_, EM_GETTEXTRANGE, 0, Cast(LPARAM, @txtrange))
      memenregselect.chaine = buffer
               
      'preparer recherche         
      Dim uFlags          As Integer
      Dim nRet          As integer
      Dim find          As FINDTEXTEX
      Dim fmt          As CHARRANGE
      Dim formatcar      As CHARFORMAT2
   
      'Dim FindBuffer     As String * 256
      
      uFlags = FR_DOWN Or FR_WHOLEWORD
      If match = TRUE Then
         uFlags Or= FR_MATCHCASE
      EndIf
      
      formatcar.cbSize = sizeof(formatcar)     'formatcar
      formatcar.dwMask = CFM_BACKCOLOR   
      formatcar.crBackColor = RGB(0, 0, 255)
      
      find.chrg.cpMin = 0
      find.chrg.cpMax = -1
      find.lpstrText = Strptr(memenregselect.chaine)
      
      ' recherche
      Do
         nRet = SendMessage(hWin_, EM_FINDTEXTEX, _
                              uFlags, Cast(Lparam, @find))
         If nRet = -1 Then Exit Do
         
         If find.chrgText.cpMin <> memenregselect.posorigine Then
            ' selection
            fmt.cpMin = find.chrgText.cpMin
            fmt.cpMax = find.chrgText.cpMax
            SendMessage(hWin_, EM_SETSEL, fmt.cpMin, fmt.cpMax)
            
            nRet = SendMessage(hWin_, EM_SETCHARFORMAT, _
                        SCF_SELECTION, Cast(LPARAM, @formatcar)) '
            
            LOC_messageOutput(Str(nRet))'TODO: effacer apres tests
            
            'Exit do  'TODO: effacer apres tests
         EndIf
         
         find.chrg.cpMin = find.chrgText.cpMax
         find.chrg.cpMax = -1
      Loop

      ' selectionne le mot d'origine
      SendMessage(hWin_, EM_SETSEL, _
                     memenregselect.posorigine, _
                     memenregselect.posfin)
      
      ' en cours
      
   End Sub

   Function WndProcEdit(ByVal hWin_    As HWND, _
                  ByVal uMsg_       As UINT, _
                  ByVal wParam_    As WPARAM, _
                  ByVal lParam_    As LPARAM) As Integer
      Select Case uMsg_            
         Case WM_LBUTTONUP
            'isProcAtCursor(lpHandles->hred)
            
            'TODO: 0002 annuler selection si necessaire
            
            If doubleselecttext = TRUE Then
               If wParam_ = MK_SHIFT Then
                  displaySelect(lpHandles->hREd, TRUE)
               Else
                  displaySelect(lpHandles->hREd, FALSE)
               EndIf
               
               doubleselecttext = FALSE   
            EndIf
            
         'Case WM_KEYUP   
         '   isProcAtCursor(lpHandles->hred)
         Case WM_LBUTTONDBLCLK
            doubleselecttext = TRUE
      End Select      
    
      Return CallWindowProc(lpOldWndProcEdit, hWin_, uMsg_, wParam_, lParam_)
   End Function
stephanbrunker
Posts: 62
Joined: Nov 02, 2013 14:57

Re: FbEdit

Postby stephanbrunker » Sep 01, 2015 18:58

I'm the one who created the tutorial at freebasic-portal.de. I found this thread because I wanted to know if there's anyone interested in it and it was mentioned. I work with FBEdit version 1.0.7.6c, which is the last one compiled at freebasic-portal.de . If there's actually a need, then I can translate the whole tutorial in an english version if there's no native english speaker who can translate it from german. I've also a couple of additions which I didn't wrote yet, mostly because I don't know if someone would read or need them (Treeview, transparent bitmaps for menu, dynamic menu bar, including a Html Help ...).

For my windows applications, i prefer the combo Freebasic + FBEdit, because the knowledge base on pure C windows programming is quite a big one, and translating C into Freebasic is not so hard. Writing in C ... urggh. Also, since v1.02/1.03 of the freebasic package, the windows headers are way improved.
spartacus13012
Posts: 18
Joined: Nov 30, 2014 12:37
Location: FRANCE

Re: FbEdit

Postby spartacus13012 » Sep 03, 2015 8:23

stephanbrunker wrote:I'm the one who created the tutorial at freebasic-portal.de. I found this thread because I wanted to know if there's anyone interested in it and it was mentioned. I work with FBEdit version 1.0.7.6c, which is the last one compiled at freebasic-portal.de . If there's actually a need, then I can translate the whole tutorial in an english version if there's no native english speaker who can translate it from german. I've also a couple of additions which I didn't wrote yet, mostly because I don't know if someone would read or need them (Treeview, transparent bitmaps for menu, dynamic menu bar, including a Html Help ...).

For my windows applications, i prefer the combo Freebasic + FBEdit, because the knowledge base on pure C windows programming is quite a big one, and translating C into Freebasic is not so hard. Writing in C ... urggh. Also, since v1.02/1.03 of the freebasic package, the windows headers are way improved.


Hello

I do not want to get ahead for the others, I think that a tres good idea would belong. Because translation google, they know all that this gives.

Up to now I went through this tutos by taking some ideas to advance in the knowledge of BFRS. With an English version, for my part, I am really going to be able to advance, by using them entirely.

Good courage for this job.

PS if you know an automatic translator of better quality than google I take.
chung
Posts: 549
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Re: FbEdit

Postby chung » Sep 18, 2015 10:34

Need help !
its been a while yet my fbedit dont save .undo file any more , how can i have it saved again ?


i am running windows 8.1 64bits
St_W
Posts: 1435
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FbEdit

Postby St_W » Sep 18, 2015 13:04

chung wrote:its been a while yet my fbedit dont save .undo file any more , how can i have it saved again ?

First check whether you have the "UndoSave" Addin enabled (Options -> Addins -> "UndoSave.dll" should be checked).
You can check whether it was loaded by looking for the "Clear Undo buffer" entry in the edit menu. It should be there (the name may be a little different).

.undo files are only saved for Projects, as far as I remember. So if you don't use a project you won't have an .undo file.
Another thing you can check is whether FbEdit has all permissions needed to create and write into the .undo file in the project directory. You could use e.g. "ProcessMonitor" to check whether FbEdit tries to create an .undo file and fails or does not even try.
chung
Posts: 549
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Re: FbEdit

Postby chung » Sep 18, 2015 13:49

i am using fbprojects , but i have no undosave.dll in my addin menu , how can i get it ? on sourceforge there is only the 1068 version
fxm
Posts: 8541
Joined: Apr 22, 2009 12:46
Location: Paris (suburbs), FRANCE

Re: FbEdit

Postby fxm » Sep 18, 2015 13:59

Last edited by fxm on Sep 18, 2015 16:15, edited 2 times in total.
chung
Posts: 549
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Re: FbEdit

Postby chung » Sep 18, 2015 14:20

thanks, it works now
andykmv
Posts: 34
Joined: Feb 12, 2015 9:50

Compiling FbEdit sources...

Postby andykmv » Sep 30, 2016 9:45

hi all! i have the fbedit sources and i am trying to compile it but just getting a freebasic editor popup dialogue box with the compile command in it (with my paths to fbc.exe, the bas file, the rc file and the -x target exe path and name. come to think of it, i am trying to compile fbedit from within fbedit.

my reason for wanting to compile fbedit - i am preparing to write an application and fbedit actually has a lot of the elements i want so i thought i might pare it back to the essentials i need, so successful recompile was my first step.

i recently saw some posts in a thread about compiling the 1.0.7xx sources for windows when someone else was trying to compile it and i cant for the life of me find it. can anyone point me in the right direction ?

come to think of it, i am trying to compile fbedit from within fbedit - but the target exe is fbedit-andys.exe so shouldnt clash, unless fbedit.exe is produced in an intermediate step..... ?
St_W
Posts: 1435
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FbEdit

Postby St_W » Sep 30, 2016 14:00

I wouldn't recommend starting a project with such a big and complicated application as FBedit as basis - especially as a beginner.
That's why:
- large parts of FBedit are written in assembly language (i.e. most controls including the editor) and the FreeBasic code "just" puts everything together
- there's nearly no documentation you've to jump between assembly and FreeBasic code to understand what code might do
- the code is not structured very nicely
- the code extensively uses Win32 API
- the code does not use modern programming techniques like OOP, but is rather Assembly- or C-style.


Anyway, if you'd still like to build FbEdit I'd suggest taking the following sources (use a svn client to check out):
https://svn.freebasic-portal.de/svn/fbedit/

They contain a "Make.bat" file, which does everything for you. Just make sure that you enter valid paths for all the needed tools in "Make.ini" before. The FreeBasic Composer, MASM and RadASM are needed. Afterwards everything you've to do is double clicking the "Make.bat" (ideally :-) if you've done everything right).
Cherry
Posts: 351
Joined: Oct 23, 2007 12:06
Location: Austria
Contact:

Re: FbEdit

Postby Cherry » Sep 30, 2016 14:11

@andykmv: Maybe you are refering to my posts on page 60?
andykmv
Posts: 34
Joined: Feb 12, 2015 9:50

Re: FbEdit

Postby andykmv » Sep 30, 2016 21:49

@cherry and @St_W, thanks for your replies.
@cherry thanks - i knew i had seen it somewhere! :)
@St_W - many thanks for the tips - i like a challenge, and i'm just starting to get my head around the messaging model of the win api, so a long learning curve for me. doing a successful compile will be a useful learning exercise in itself :)
andykmv
Posts: 34
Joined: Feb 12, 2015 9:50

Re: FbEdit

Postby andykmv » Sep 30, 2016 22:56

@St_W - many thanks - the svn site is asking for uid and pw - is there a standard one or do i need to request an access uid & pw ?

St_W wrote:I wouldn't recommend starting a project with such a big and complicated application as FBedit as basis - especially as a beginner.
That's why:
- large parts of FBedit are written in assembly language (i.e. most controls including the editor) and the FreeBasic code "just" puts everything together
- there's nearly no documentation you've to jump between assembly and FreeBasic code to understand what code might do
- the code is not structured very nicely
- the code extensively uses Win32 API
- the code does not use modern programming techniques like OOP, but is rather Assembly- or C-style.


Anyway, if you'd still like to build FbEdit I'd suggest taking the following sources (use a svn client to check out):
https://svn.freebasic-portal.de/svn/fbedit/

They contain a "Make.bat" file, which does everything for you. Just make sure that you enter valid paths for all the needed tools in "Make.ini" before. The FreeBasic Composer, MASM and RadASM are needed. Afterwards everything you've to do is double clicking the "Make.bat" (ideally :-) if you've done everything right).
St_W
Posts: 1435
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FbEdit

Postby St_W » Oct 01, 2016 15:46

andykmv wrote:@St_W - many thanks - the svn site is asking for uid and pw - is there a standard one or do i need to request an access uid & pw ?

I don't think you need any authentication for checkout (only if you wanted to commit changes). Can you access it in a normal web browser?
Just use:

Code: Select all

svn co https://svn.freebasic-portal.de/svn/fbedit/

Return to “Projects”

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests