• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 138
  • Last Modified:

Form showing

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

HELP!!!!
0
Tiger2345
Asked:
Tiger2345
  • 2
1 Solution
 
CimperialiCommented:
If you need a loaded but invisible form, do not use the Show method. Use the Load one
ie:
form2.show ' this will make form visible
Load form2  'this will execute the form_load sub, but will not show the form.
0
 
EDDYKTCommented:
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_NOACTIVATE = &H10
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
0
 
CimperialiCommented:
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.Show
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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now