Showing Caret

S

Sean

Hi,

I have an application that will pop up a listboxwindow
(containing words that users can choose from)
when I type certain characters on a richtextbox.

Now I have a problem of maintaining the caret at the
richtextbox, because once the listboxwindow pops up, the
input focus will move to the listboxwindow.

How can I make the caret stay at the richtextbox?

I tried the following but it didn't work:

if(m.Msg == WM_NCACTIVATE)
{
if (((int) m.WParam) == 0)
{
SendMessage(this.Handle, WM_NCACTIVATE, 1,
IntPtr.Zero);
SendMessage(this.Handle, WM_SETFOCUS, 1,
IntPtr.Zero);
CreateCaret(this.Handle, IntPtr.Zero, 0, 0);
ShowCaret(this.Handle);
}
}

Any idea would be appreciated.
Thank you in advance. :)


regards,
Sean
 
A

Arne Janning

Sean said:
I have an application that will pop up a listboxwindow
(containing words that users can choose from)
when I type certain characters on a richtextbox.

Now I have a problem of maintaining the caret at the
richtextbox, because once the listboxwindow pops up, the
input focus will move to the listboxwindow.

How can I make the caret stay at the richtextbox?

I tried the following but it didn't work:

if(m.Msg == WM_NCACTIVATE)
{
if (((int) m.WParam) == 0)
{
SendMessage(this.Handle, WM_NCACTIVATE, 1,
IntPtr.Zero);
SendMessage(this.Handle, WM_SETFOCUS, 1,
IntPtr.Zero);
CreateCaret(this.Handle, IntPtr.Zero, 0, 0);
ShowCaret(this.Handle);
}
}

Any idea would be appreciated.
Thank you in advance. :)

Hi Sean,

"Keeping the Main Form Title Active and Detecting Alt-Tabbing"
http://www.vbaccelerator.com/home/NET/Code/Controls/Popup_Windows/Popup_Windows/article.asp

is an article that might help. Overriding WndProc is the right way.

Cheers

Arne Janning
 
G

Guest

Hi Arne,

Thanks for your reply.
But that's not what I want.

I want the caret to stay at the richtextbox, because once
the listboxwindow pops up, the input focus will move to
the listboxwindow.

Any more ideas/suggestion would be greatly appreciated!



regards,
Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top