Form showing

Posted on 2003-03-04
Medium Priority
Last Modified: 2010-05-01
I am trying to create a form to print, i have set the visibility to false on the formload & on the properties,
But it still shows, i have even tried to disenable it but it still F*****k shows

Question by:Tiger2345
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

Cimperiali earned 200 total points
ID: 8063876
If you need a loaded but invisible form, do not use the Show method. Use the Load one
form2.show ' this will make form visible
Load form2  'this will execute the form_load sub, but will not show the form.
LVL 26

Expert Comment

ID: 8063893
If you don't want your form show on taskbar then set showintaskbar to false

If you don't want to show on process tab on task manager
then paste the following code on your form

Option Explicit

' hide window from task manager
Const SW_HIDE = 0
Const GW_OWNER = 4

'Window always on top
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
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 Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long

Private Sub Form_Load()

    On Error Resume Next
    ShowWindow GetWindow(hwnd, GW_OWNER), SW_HIDE
    SetWindowPos hwnd, -1, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOMOVE Or SWP_NOSIZE
End Sub

Private Sub Form_Unload(Cancel As Integer)

    On Error Resume Next
End Sub

Expert Comment

ID: 8063910
If you have to make it invisible in any case after it has been called with the show method, you can:
show and make infisible after ie:
'in form1
Form2.Visible = False

'or, in form2:
'code it in the resize event:
Private Sub Form_Resize()
    Me.Visible = False
End Sub

'Or even:
'put a timer enabled, intervak 50 msec.
'in timer event code:
Private sub Timer1_Timer()
     Timer1.enabled = False
     me.visible = False
end sub
Point is: the load event occurs before form is completely shown, thus, as last command of the Show method make your form visible, if you want to set it as invisible, you have to do it after the load event completed.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question