Results 1 to 37 of 37

Thread: [RESOLVED] How Can I show Form2 Without Show all Project Forms !?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Resolved [RESOLVED] How Can I show Form2 Without Show all Project Forms !?

    Hello
    I Wonder Why Can`t Show Only One Form Without Show All Others !?
    I Need Show Only Form2 Without Hide the Others
    Thank You
    Name:  04-06-14_22-25-06.jpg
Views: 273
Size:  7.2 KB

  2. #2
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How Can I show Form2 Without Show all Project Forms !?

    Try something like this

    Code:
    Dim frm as form
    
    For each frm in me
    If not frm.name = "Form2" then frm.hide
    Next frm
    Not tested written from phone but should work

    Or you could set the startup form to be form2

  3. #3
    Lively Member
    Join Date
    Oct 2013
    Posts
    124

    Re: How Can I show Form2 Without Show all Project Forms !?

    I'm not sure what code you are using that shows them all. One of the properties of a form is the 'Visible' property. You should be able to set it to false at design time, load the form any time and then set Visible to True.

    But there is also the modal or modeless issue, and the Z-order. In this case I think it would be nice if you post the part of your code that shows the form.
    Last edited by Honduras 2811; Apr 6th, 2014 at 05:43 PM. Reason: Clarification
    AMD FX-4300, WinXPSP3, VB6SP6

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Thank you for replay
    I don`t want hide any form I want it all visible
    example:
    if I set Form2 Topmost from systray that will Bring all forms !
    I know Only Form2 will be Topmost but I don`t want show all forms when I do this

  5. #5
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How Can I show Form2 Without Show all Project Forms !?

    How do you set topmost from systray?

    If you want show all forms then use frm.show instead of frm.hide in my example

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: How Can I show Form2 Without Show all Project Forms !?

    Your question doesn't make any sense

    In one sentence you say that you don;t want to hide any forms that you want them all visible and then you turn around and say you don't want them visible.

    You can toggle any form visible or not visible at any time. Using API you can set a from as top most but I really don;t know what you are trying to say as your post contradicts itself.

  7. #7
    Lively Member
    Join Date
    Oct 2013
    Posts
    124

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Noob13 View Post
    Thank you for replay
    I don`t want hide any form I want it all visible
    example:
    if I set Form2 Topmost from systray that will Bring all forms !
    I know Only Form2 will be Topmost but I don`t want show all forms when I do this
    Once again, I'm having a little trouble understanding. You say you don't want to hide anything, but, in your example you say you don't want to show any of them except Form2.
    Last edited by Honduras 2811; Apr 6th, 2014 at 05:50 PM. Reason: Clarification.
    AMD FX-4300, WinXPSP3, VB6SP6

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    My Project Have Main Base I need it always visible on Desktop
    if I call form2 from taskbar or systray it will show all forms
    as you can see form1 bring with form2 ontop opened folder
    I want form1 stay show and active on desktop if there is nothing hide it I can see it and if I need it i can call it alone
    sorry I trying hard to figure it out to you but my English not the best
    Name:  04-07-14_01-01-51.jpg
Views: 244
Size:  21.8 KB

  9. #9
    Lively Member
    Join Date
    Oct 2013
    Posts
    124

    Re: How Can I show Form2 Without Show all Project Forms !?

    I think I'm starting to understand.

    Try this: Show the Base form with Style = vbModal. Drag it where it is out of the way. Only show Form2 from the button on the base form.

    Like under the button have

    Code:
    Private Sub cmdNote2_Click()
         Form2.Show
    End Sub
    Does that sound reasonable? Don't show Form2 any other way.

    The Base form is the only one you should try to show any other way. I'm still not sure where the systray and taskbar come into it. When you start the application the Base form, only, should be shown automatically if you have set it as the Startup Object under Project Properties. Just don't close it.

    Oh, ShowInTaskbar should be set to False on all the forms except maybe the base form.

    This is not a very good explanation. Do you need me to clarify anything.
    Last edited by Honduras 2811; Apr 6th, 2014 at 06:46 PM. Reason: Added note
    AMD FX-4300, WinXPSP3, VB6SP6

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Two Forms in one Project
    if I click on ""Clock Form"" I don`t Want ""Control Form"" bring up , I want it stay on desktop behind folder
    Name:  04-07-14_01-29-23.jpg
Views: 240
Size:  30.1 KB

  11. #11
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How Can I show Form2 Without Show all Project Forms !?

    If your form is not vbmodal then it shouldn't bring two forms at once, not sure you need to show us the code from the clock form... maybe form_click event?

  12. #12
    Lively Member
    Join Date
    Oct 2013
    Posts
    124

    Re: How Can I show Form2 Without Show all Project Forms !?

    Well, that leaves out vbModal. I don't know why both forms show, but it may be an operating system thing. I don't recognize the OS that you are using. I've never tried to show a form except from another form in the same project, so I don't think I can help you. Sorry.
    AMD FX-4300, WinXPSP3, VB6SP6

  13. #13
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How Can I show Form2 Without Show all Project Forms !?

    you could do it with api setwindowpos or/and api showwindow... you could make the clock form topmost with setwindowpos and then use the showwindow and set the control from to appear behind everything.

    But I don't understand why you can't use form.visible

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    No Matter What OS I use
    I use Win8.1 x64
    I test it on Winxp x32 it same!

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    this is just example , clock from I got it from planet-source-code (analogue clock gadget)
    Not form_click event if I use two empty Form I`ll got the same thing

  16. #16
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How Can I show Form2 Without Show all Project Forms !?

    I'm trying to understand what you are saying but its hard.

    You got two forms.

    -Form1
    -Form2

    1. No code at all in the forms.
    2. You click run (in vb6 IDE), Form1 Opens up, Form2 will be hidden.

    So what your saying is in your OS if you follow my steps Form1 & Form2 will show?

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Max187Boucher View Post
    I'm trying to understand what you are saying but its hard.

    You got two forms.

    -Form1
    -Form2

    1. No code at all in the forms.
    2. You click run (in vb6 IDE), Form1 Opens up, Form2 will be hidden.

    So what your saying is in your OS if you follow my steps Form1 & Form2 will show?
    Form1.Show and Form2.show
    now go to Desktop open folder or MyComputer However and Cover form1 and form2
    tray to call form2 as you wish from taskbar or systray .....
    it`ll show form1 and form2 ontop ""folder or MyComputer"" not only form2

  18. #18
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: How Can I show Form2 Without Show all Project Forms !?

    Well, it sounds like you are saying that you have two forms open and active in your program and then you send the program to the background and then click on the program to bring it back in focus which of course brings the program into focus [which consists of two open forms] not just the form you clicked on. If you want one form visible and the other hidden then you need to write some code. The simple method being .Hide

  19. #19
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How Can I show Form2 Without Show all Project Forms !?

    You could always create two projects, or hook the window (more complicated for such a little gain)

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by DataMiser View Post
    Well, it sounds like you are saying that you have two forms open and active in your program and then you send the program to the background and then click on the program to bring it back in focus which of course brings the program into focus [which consists of two open forms] not just the form you clicked on. If you want one form visible and the other hidden then you need to write some code. The simple method being .Hide
    that`s right But I don`t want use hide

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Max187Boucher View Post
    You could always create two projects, or hook the window (more complicated for such a little gain)
    but i want my program in one project and without this Problem

  22. #22
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Noob13 View Post
    that`s right But I don`t want use hide
    Why? I never understand it when someone says I want my program to do X but I do not want to code it to do X.

    If you want a form hidden then hide it, or unload it. If you do not want to hide it then that means you want it to be visible but you say you don't want it visible.

    Sounds like you need to stop and think about what it is that you are really trying to do.

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by DataMiser View Post
    Why? I never understand it when someone says I want my program to do X but I do not want to code it to do X.

    If you want a form hidden then hide it, or unload it. If you do not want to hide it then that means you want it to be visible but you say you don't want it visible.

    Sounds like you need to stop and think about what it is that you are really trying to do.
    Comeon I never said "don't want it visible"
    I want all forms visible and when I call form2 only show form2 not bring all forms

  24. #24
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How Can I show Form2 Without Show all Project Forms !?

    The thing here noob is, its all as one project so without hooking (controlling windows messages) its all one big project with different windows so it will bring all forms to the front. Only way is to set form1 topmost but then that form will ALWAYS be in front unless told to not be topmost. I'm sure hooking would work in this case but it requires you to catch the right message wm_(message).

    But hooking can lead to vb crash or even windows crash, if not unhooked or controlled properly.

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Max187Boucher View Post
    The thing here noob is, its all as one project so without hooking (controlling windows messages) its all one big project with different windows so it will bring all forms to the front. Only way is to set form1 topmost but then that form will ALWAYS be in front unless told to not be topmost. I'm sure hooking would work in this case but it requires you to catch the right message wm_(message).

    But hooking can lead to vb crash or even windows crash, if not unhooked or controlled properly.
    so hard so far
    i like it simple and I think its impossible but i`ll never Quit

  26. #26
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: How Can I show Form2 Without Show all Project Forms !?

    Can you attach your project to your next post (click the Go Advanced button and then the Manage Attachments button) so we can finally understand what it is that you want to happen?
    Last edited by Bonnie West; Apr 6th, 2014 at 10:46 PM. Reason: Added instructions
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  27. #27
    Hyperactive Member
    Join Date
    Mar 2014
    Posts
    321

    Re: How Can I show Form2 Without Show all Project Forms !?

    download the attachment zip source code am sure this is what u want
    Attached Files Attached Files
    Last edited by cobraide; Apr 7th, 2014 at 05:41 AM.

  28. #28

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Simple Project Attached
    two Form Always Visible Always Active

    Now you can do this if click on control or clock form ((I feel like it`s linked together))
    Name:  04-07-14_16-22-27.jpg
Views: 234
Size:  34.0 KB

    I want click on one form show one form like this (( I can do it if I use two project ))
    Name:  04-07-14_16-22-17.jpg
Views: 233
Size:  35.5 KB
    I dont want hide anything and I want in one project

    Thank you
    Attached Images Attached Images  
    Attached Files Attached Files

  29. #29

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by cobraide View Post
    download the attachment zip source code am sure this is what u want
    No , my project is gadget all form stay Visible & active on desktop

  30. #30
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: How Can I show Form2 Without Show all Project Forms !?

    Looks like (what a thread!) you want your clock 'form' (gadget) to stay on top no matter what other MS windows a user clicks on. And I am guessing that as you add other 'gadgets' that you would want THEM to also remain on top, yet your main form (the little one in the bottom left) can be 'hidden/partially hidden' by other MS windows. Is that just about it?

  31. #31

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by SamOscarBrown View Post
    Looks like (what a thread!) you want your clock 'form' (gadget) to stay on top no matter what other MS windows a user clicks on. And I am guessing that as you add other 'gadgets' that you would want THEM to also remain on top, yet your main form (the little one in the bottom left) can be 'hidden/partially hidden' by other MS windows. Is that just about it?
    no ,just try it like this : open Project with 2 forms and cover it with anything
    now try click form1 or form2 from taskbar it will bring out form1 & form2 !
    you click only one form and the question is why all forms is bring out too ?

  32. #32
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Noob13 View Post
    you click only one form and the question is why all forms is bring out too ?
    Because when you activate any of the Forms in your app, VB automatically brings to the foreground all the other visible Forms as well. Most non-VB apps don't behave that way, so I guess you could consider that behavior as a bug. I'm afraid there's nothing you can do about it though, unless you fight VB by subclassing or via another low-level, hackish method.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  33. #33
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Bonnie West View Post
    Because when you activate any of the Forms in your app, VB automatically brings to the foreground all the other visible Forms as well.
    There is a workaround for that, but IIRC it involves setting the windows GWL_HWNDPARENT , something like...
    Code:
    Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Const GWL_HWNDPARENT As Long = -8
    
    Dim oFrm As Form2
    Set oFrm = New Form2
    oFrm.Show
    SetWindowLong oFrm.hWnd, GWL_HWNDPARENT, 0&
    Though its been years since I used that so may be incorrect,
    I got a couple tricks like that from this old thread here.

    EDIT some code I was using in my app...
    Code:
    Public Sub SetWinSelf(f As Form)
    ' this makes a form not activate other forms open on desktop when it gets the focus. 
    ' FOR COMPILED EXE.
            f.Show
            SetWindowLong f.hwnd, GWL_HWNDPARENT, CreateWindowEx( _
             &H80, "ThunderRT6Main", vbNullString, &H94000000, _
             0&, 0&, 0&, 0&, 0&, 0&, GetWindowLong(f.hwnd, GWL_HINSTANCE), 0&)
    For testing in IDE, .
    Code:
        ' **** CODE TO TEST IN IDE ONLY *******
        'SetWindowLong Chld.hWnd, _
                  GWL_HWNDPARENT, _
                  CreateWindowEx( _
                                 &H80, "ThunderMain", _
                                 vbNullString, &H94000000, _
                                 0&, 0&, 0&, 0&, 0&, 0&, _
                                 GetWindowLong(Chld.hWnd, GWL_HINSTANCE), _
                                 0&)

    I don't have VB6 installed on any PCs anymore so can't test, but I believe the above hides the form from taskbar also, don't really remember , see URL above.

    HTH.
    Last edited by Edgemeal; Apr 7th, 2014 at 12:43 PM.

  34. #34

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Edgemeal View Post
    There is a workaround for that, but IIRC it involves setting the windows GWL_HWNDPARENT , something like...
    Code:
    Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Const GWL_HWNDPARENT As Long = -8
    
    Dim oFrm As Form2
    Set oFrm = New Form2
    oFrm.Show
    SetWindowLong oFrm.hWnd, GWL_HWNDPARENT, 0&
    Though its been years since I used that so may be incorrect,
    I got a couple tricks like that from this old thread here.

    EDIT some code I was using in my app...
    Code:
    Public Sub SetWinSelf(f As Form)
    ' this makes a form not activate other forms open on desktop when it gets the focus. 
    ' FOR COMPILED EXE.
            f.Show
            SetWindowLong f.hwnd, GWL_HWNDPARENT, CreateWindowEx( _
             &H80, "ThunderRT6Main", vbNullString, &H94000000, _
             0&, 0&, 0&, 0&, 0&, 0&, GetWindowLong(f.hwnd, GWL_HINSTANCE), 0&)
    For testing in IDE, .
    Code:
        ' **** CODE TO TEST IN IDE ONLY *******
        'SetWindowLong Chld.hWnd, _
                  GWL_HWNDPARENT, _
                  CreateWindowEx( _
                                 &H80, "ThunderMain", _
                                 vbNullString, &H94000000, _
                                 0&, 0&, 0&, 0&, 0&, 0&, _
                                 GetWindowLong(Chld.hWnd, GWL_HINSTANCE), _
                                 0&)

    I don't have VB6 installed on any PCs anymore so can't test, but I believe the above hides the form from taskbar also, don't really remember , see URL above.

    HTH.
    Thank you so much
    WOW ,
    SetWindowLong Form1.hwnd, GWL_HWNDPARENT, 0&
    it working perfectly

    you can use portable vb6 ,
    PM me if you want my modern copy

    Have a nice day

  35. #35

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: [RESOLVED] How Can I show Form2 Without Show all Project Forms !?

    what if ""ShowInTaskbar = False""
    How can I keep it False ?
    When Click on Form it`s back True !

    SetWindowLong Form1.hwnd, GWL_HWNDPARENT, 0&

    Thankx

  36. #36
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: [RESOLVED] How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Noob13 View Post
    what if ""ShowInTaskbar = False""
    How can I keep it False ?
    When Click on Form it`s back True !

    SetWindowLong Form1.hwnd, GWL_HWNDPARENT, 0&

    Thankx
    Did you try using that 2nd part of that code instead?...
    SetWindowLong f.hwnd, GWL_HWNDPARENT, CreateWindowEx(.....

    Note, one was for compiled exe and other for testing in IDE.

    EDIT, just in case you need the API declares..

    Code:
    Private Const GWL_HWNDPARENT As Long = (-8)
    Private Const GWL_HINSTANCE As Long = (-6)
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
    
    Private Sub Example_Usage(f As Form)
        f.Show
        SetWindowLong f.hwnd, GWL_HWNDPARENT, CreateWindowEx(&H80, "ThunderRT6Main", vbNullString, &H94000000, 0&, 0&, 0&, 0&, 0&, 0&, GetWindowLong(f.hwnd, GWL_HINSTANCE), 0&)
    End Sub
    Last edited by Edgemeal; Apr 7th, 2014 at 06:53 PM.

  37. #37

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: [RESOLVED] How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Edgemeal View Post
    Did you try using that 2nd part of that code instead?...
    SetWindowLong f.hwnd, GWL_HWNDPARENT, CreateWindowEx(.....

    Note, one was for compiled exe and other for testing in IDE.
    Yes I test it
    Public Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
    Public Const GWL_HINSTANCE = (-6)
    Set the appropiate window classname, "ThunderMain" if you test it in the IDE, or compiled for instance in VB6 "ThunderRT6Main".

    it`s working you are my Hero
    Last edited by Noob13; Apr 7th, 2014 at 07:24 PM.

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