473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to get a form on top of all other windows

I would like to know that how can I get a form on top of all other windows in such a manner that no new window can appear over it using visual basic
Jun 27 '07 #1
1 1096
sashi
1,754 Expert 1GB
Hi there,

Kindly refer to below code segment, hope it helps. Good luck & Take care.

Expand|Select|Wrap|Line Numbers
  1. Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
  2.  
  3.  
  4.              ByVal hWndInsertAfter As Long, _
  5.  
  6.  
  7.              ByVal x As Long, ByVal y As Long, _
  8.  
  9.  
  10.              ByVal cx As Long, ByVal cy As Long, _
  11.  
  12.  
  13.              ByVal wFlags As Long) As Long
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. Global Const SWP_NOMOVE = 2
  23.  
  24.  
  25. Global Const SWP_NOSIZE = 1
  26.  
  27.  
  28. Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
  29.  
  30.  
  31. Global Const HWND_TOPMOST = -1
  32.  
  33.  
  34. Global Const HWND_NOTOPMOST = -2
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. Public Sub MakeTopMost(f As Form, v As Boolean)
  44.  
  45.  
  46.     Dim success As Long
  47.  
  48.  
  49.  
  50.  
  51.  
  52.     If v Then
  53.  
  54.  
  55.         success = SetWindowPos(f.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
  56.  
  57.  
  58.     Else
  59.  
  60.  
  61.         success = SetWindowPos(f.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
  62.  
  63.  
  64.     End If
  65.  
  66. End Sub
  67.  
I would like to know that how can I get a form on top of all other windows in such a manner that no new window can appear over it using visual basic
Jun 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. ...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
11
by: Özden Irmak | last post by:
Hello, In my VB.Net application I create a new instance of my form like : NewForm = new MyNewForm() But with this line, this new form is automatically shown. I want it to be hidden at the...
0
by: Amiram Korach | last post by:
When you create a MDI form, you can attach a main menu to the parent and to the child. When a child form is active, its menu is merged with the parent menu. The problem is: when the forms are...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
4
by: Philip Wagenaar | last post by:
I have made a form with a tab that containts groupboxes and those contain checkboxes. When I run the application sometimes the outlining for some groupboxes are not shown, if I switch tabs and...
7
by: Terry | last post by:
I have a Mainform with a Statusbar. When opening another form or doing some processing I want to display info in the Statusbar of the Mainform. I have read a lot of articles on this & have come up...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.