How to float/dropdown a form over another form?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How to float/dropdown a form over another form?

  1. #1
    Join Date
    Aug 2011
    Posts
    8

    Post How to float/dropdown a form over another form?

    I have two form in vb6 project. I want to show form1 always and show form2 just below of a text box in form1. There is a text box in form1 to supply search character and form2 have flexgrid which shows the data according to form1 text box. Now please suggest me how can I make form1 always showing and from two showing over it but focus is always on form1.text1. I want to make form2 as like drop down controls.

    Anampathik

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,850

    Re: How to float/dropdown a form over another form?

    Off the top of my head I would say that you may find it better to use a frame to hold your flexgrid rather than a seperate form. The frame can be moved around, resized, hidden as needed at runtime while keeping foucs on the textbox.


    Aside from that you can use the topmost window method to cause from 2 to always stay on top of all other windows which would allow you to display form 2 over form 1 while still having focus on form 1 but I think the frame is a much better way to handle it.
    Last edited by DataMiser; August 8th, 2011 at 10:47 PM.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: How to float/dropdown a form over another form?

    You are right, DataMiser, but lets get to the top - or no, to the bottom of it:

    Code:
    Public Declare Function SetWindowPos Lib "user32" ( _
           ByVal hWnd As Long, _
           ByVal hWia 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 Const SWP_NoSize = 1&
    Public Const SWP_NoMove = 2&
    Public Const SWP_NoZOrder = 4&
    Public Const SWP_NoOwnerZOrder = &H200
    Public Const SWP_FrameChanged = &H20
    
    Public Const HWND_Top = 0&
    Public Const HWND_Bottom = 1&
    Public Const HWND_TopMost = -1&
    Public Const HWND_NoTopMost = -2&
    To make a form named "Form1" float on top of all other open forms you'd make a call like
    Code:
     SetWindowPos Form1.hWnd, HWND_TopMost, 0, 0, 0, 0, SWP_NoMove Or SWP_NoSize

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center