Results 1 to 6 of 6

Thread: A problem with Multiple Forms

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    hongkong
    Posts
    251
    Dear All Friends,

    I hope to post a question on manipulating multiple forms.

    My application has a main window and several smaller toolwindows like the look of Photoshop.

    I have used the function (suggested by a nice member in the forum):

    **********************************************************
    In Genral Declaration:
    ______________________
    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

    In MDIForm_Load:
    ________________
    frmToolbox1.Show
    SetWindowPos frmToolbox1.hwnd, -1, 0, 0, 0, 0, 3

    :
    :
    etc

    **********************************************************

    to display the toolwindow forms on top of the main form.


    When I switch from my application to another like a browser by clicking the tab on the taskbar, the toolwindows still display on top of the another application. This is very misleading and inconvenient to the users.

    If I want the toolwindows display only when my application main window is displayed / on focus, how can I achieve this?

    Thank you very much for your help.

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    You may try this:

    Code:
    ------------------------------------------------
    ¡® Put this on your toolwindows

    Option Explicit
    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

    Private Sub Form_GotFocus()
    'Set your form topmost

    SetWindowPos hwnd, -1, 0, 0, 0, 0, 3

    End Sub


    Private Sub Form_LostFocus()
    'Cancel the topmost position of your form and put it on the taskbar

    SetWindowPos hwnd, -2, 0, 0, 0, 0, 3

    End Sub
    ------------------------------------------------


  3. #3
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    You may try this:

    Code:
    ------------------------------------------------
    ¡® Put this on your toolwindows

    Option Explicit
    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

    Private Sub Form_GotFocus()
    'Set your form topmost

    SetWindowPos hwnd, -1, 0, 0, 0, 0, 3

    End Sub


    Private Sub Form_LostFocus()
    'Cancel the topmost position of your form and put it on the taskbar

    SetWindowPos hwnd, -2, 0, 0, 0, 0, 3

    End Sub
    ------------------------------------------------
    Is that what you want?



  4. #4
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    well if ur main app loses focus then tell it to minimize all other forms in the lost focus event

  5. #5
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Yes. theman32x is right. We can put other code in that event. And it seems better to put the SetWindowsPos function in the Form_GotFocus event than in the Form_Load event.

  6. #6
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    you know to avoid all the coding you could try to make your app into an MDI ... like AOL ... that way ur app will be the main form and everything else will be its children

    so if you have aol u've seen how everything in it minimize with the main app because everything is inside it

Posting Permissions

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



Click Here to Expand Forum to Full Width