Include & libs tool Howto insert txt iinto pbide

Just starting out? Need help? Post your questions and find answers here.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Include & libs tool Howto insert txt iinto pbide

Post 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
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Include & libs tool Howto insert txt iinto pbide

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply