Click here to Skip to main content
15,891,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working in vb.net windows form application. i have problem with window focus.

Suppose i have a main window having richtextbox control in it and second window (like notification appear at right bottom of screen) have label in it.

During i write in richtextbox suppose if second window in open (some notification), then i lost focus from main window. (second window is focused now) actually i do not want to lost focus from richtextbox when this notification show.

please help me
Posted
Updated 2-May-12 19:40pm
v2
Comments
Nikhil_S 3-May-12 1:35am    
What's rtb control.please specify full forms.
kals84 3-May-12 1:40am    
richtextbox

1 solution

Do not use the Form.Show() method. Instead use an API call:
C#
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public extern static bool ShowWindow(IntPtr hWnd, int mode);

with mode=SW_SHOWNA
Then your main window will stay focused while the other window is shown.
 
Share this answer
 
Comments
kals84 3-May-12 2:19am    
how do use this api. I am sending parameter in second window.

ex.
Dim slice As New newMessageAlert(3000, "name", "sometext, "1")
slide.show()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900