How to know which RichEdit has focus on the Editor

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.

Hi,

Im pasting a lines to the editor, but i cant get which of the possible RichEdits (supoussing that the user has more than one code displayed) has the focus.

I tried ChildWindowFromPoint and EnumChildProc and i get the handles okay, but how to know which one is the one with focus?



Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

r=GetFocus_() ; r = handle of the gadget with the focus.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Revolver.

*RichEdit is a pointer to the currently used rich edit, although it doesn't tell you if it has focus or not
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.
Originally posted by PB

r=GetFocus_() ; r = handle of the gadget with the focus.
Nop, dosent work.
I try this one before but gives me always the handle of the first RichEdit, not the active one.

Im coding an external application that stays on the systray and i want that when i call this app paste some lines to the code that i have active in the Editor, no matters that i have more codes opened on the Editor.

In fact if the calling thread's message queue does not have an associated window with the keyboard focus, the return value is NULL.

I tried to associate both threads

Code: Select all

  Hnd.l = FindWindow_("WindowClass_0","PureBasic")
  Active = ChildWindowFromPoint_(Hnd,WindowX()+100,WindowY()+200)
  Otra = GetWindowThreadProcessId_(Hnd,0)
  Mia = GetCurrentThreadId_()
  result = AttachThreadInput_(Mia,Otra,-1)
  r=GetFocus_()
  SendMessage_(r,#WM_PASTE,0,0)
  AttachThreadInput_(Mia,Otra,0)

But it dosent gives me the handle of the RichEdit so the paste fails, i get some strange handle... i will try to find which handle is it returning me

Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.


Im so idiot!!

Now its working... missing give foreground to the window

Code: Select all

  Hnd.l = FindWindow_("WindowClass_0","PureBasic")
  Active = ChildWindowFromPoint_(Hnd,WindowX()+100,WindowY()+200)
  Otra = GetWindowThreadProcessId_(Hnd,0)
  Mia = GetCurrentThreadId_()
  result = AttachThreadInput_(Mia,Otra,-1)
  SetForegroundWindow_(Hnd)
  r=GetFocus_()
  SendMessage_(r,#WM_PASTE,0,0)
  AttachThreadInput_(Mia,Otra,0)

Thanks!!

Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> SetForegroundWindow_(Hnd)
> r=GetFocus_()
> SendMessage_(r,#WM_PASTE,0,0)

Why can't you shorten the above to:

SendMessage_(Hnd,#WM_PASTE,0,0)

Why use r=GetFocus_() ? r = Hnd anyway due to SetForegroundWindow...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.
Originally posted by PB

> SetForegroundWindow_(Hnd)
> r=GetFocus_()
> SendMessage_(r,#WM_PASTE,0,0)

Why can't you shorten the above to:

SendMessage_(Hnd,#WM_PASTE,0,0)

Why use r=GetFocus_() ? r = Hnd anyway due to SetForegroundWindow...
Because it dosent works in that way.

The handle must be the handle of RichEdit.



Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> The handle must be the handle of RichEdit.

Sorry Ricardo, I misunderstood -- I thought Hnd was the handle of
the RichEdit. My mistake! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.

:)

Best Regards

Ricardo

Dont cry for me Argentina...
Post Reply