Page 1 of 1

Include & libs tool Howto insert txt iinto pbide

Posted: Thu Aug 23, 2012 11:33 pm
by Zebuddi123
Hi to all

I have created a tool to list all procedures and macros in your include files via a menu system, also quick access buttons for userlib directory's etc
i need now to be able to insert in the current pbide source file at the top of the file "Include bla bla" etc from the selected include file and at point of cursor to paste the selected procedure ie "Procedure ListFiles( )".

so the question is how to insert the line of text ? and at specific line ? the new lines of code. am i right in assuming that i need to use sendmessage().

code snippet`s greatly appreciated.

i will release as soon as this part of code is functional.



Image

Image

Zebuddi. :D

Re: Include & libs tool Howto insert txt iinto pbide

Posted: Thu Aug 23, 2012 11:41 pm
by ts-soft
Windows only:

Code: Select all

Procedure GetProcessFromWindow(hwnd)
  Protected pid, result
 
  If GetWindowThreadProcessId_(hwnd, @pid)
    result = OpenProcess_(#PROCESS_ALL_ACCESS, #False, pid)
  EndIf
 
  ProcedureReturn result
EndProcedure

Procedure PasteText(buffer.s)
  Protected hProc, mem, bW, hsci, len
  
  hsci = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
  hProc = GetProcessFromWindow(hsci)
 
  If hProc
   
    len = Len(buffer)
    mem = VirtualAllocEx_(hProc, 0, len, #MEM_RESERVE | #MEM_COMMIT, #PAGE_EXECUTE_READWRITE)
   
    If mem
      WriteProcessMemory_(hProc, mem, @buffer, len, @bW)
      SendMessage_(hsci, #SCI_ADDTEXT, len, mem)
      VirtualFreeEx_(hProc, mem, len, #MEM_RELEASE)
    EndIf
   
    CloseHandle_(hProc)
  EndIf
 
EndProcedure