Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Visual Basic Programming Code Examples

Visual Basic > Forms Code Examples

Put your form on top of all

Put your form on top of all I took your StayOnTop routine and simplfied it for VB4. Takes Two agruments. The form itself (as your original) and a boolean value. True to stay on top, false to not. 'add to a module form Declare Function SetWindowPos Lib "user32" (ByVal hwnd as Long, ByVal hWndInsertAfter as Long, ByVal X as Long, ByVal Y as Long, ByVal cx as Long, ByVal cy as Long, ByVal wFlags as Long) as Long Public sub StayOnTop(frmForm as Form, fOnTop as Boolean) Const HWND_TOPMOST = -1 Const HWND_NOTOPMOST = -2 dim lState as Long dim iLeft as Integer, iTop as Integer, iWidth as Integer, iHeight as Integer With frmForm iLeft = .Left / Screen.TwipsPerPixelX iTop = .Top / Screen.TwipsPerPixelY iWidth = .Width / Screen.TwipsPerPixelX iHeight = .Height / Screen.TwipsPerPixelY end With If fOnTop Then lState = HWND_TOPMOST Else lState = HWND_NOTOPMOST end If Call SetWindowPos(frmForm.hWnd, lState, iLeft, iTop, iWidth, iHeight,0) End Sub Return