At the Top

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ali Rizwan
    Banned
    Contributor
    • Aug 2007
    • 931

    At the Top

    Hi
    I want to set my form at the top of all winows. Is it possible in vb6 if yes then plz help me
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by Ali Rizwan
    Hi
    I want to set my form at the top of all winows. Is it possible in vb6 if yes then plz help me

    I think you have to set the form ZeroOrder like

    [CODE=vb]Form1.ZOrder 0[/CODE]

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      U have to use Win API's:
      declare this Form level(At the beginning if Form code window):


      [code=vb]
      Private 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

      Const SWP_NOSIZE = &H1
      Const SWP_NOMOVE = &H2
      Const SWP_SHOWWINDOW = &H40
      Const HWND_NOTOPMOST = -2
      Const HWND_TOPMOST = -1

      Private Sub SetAlwaysOnTopM ode(hWndOrForm As Variant, Optional ByVal OnTop As Boolean = _
      True)
      Dim hWnd As Long
      ' get the hWnd of the form to be move on top
      If VarType(hWndOrF orm) = vbLong Then
      hWnd = hWndOrForm
      Else
      hWnd = hWndOrForm.hWnd
      End If
      SetWindowPos hWnd, IIf(OnTop, HWND_TOPMOST, HWND_NOTOPMOST) , 0, 0, 0, 0, _
      SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW
      End Sub
      [/code]


      Call this in FormLoad:
      [code=vb]
      Call SetAlwaysOnTopM ode(Me, True)
      [/code]


      Regards
      Veena

      Comment

      Working...