cannot view forms (urgent) thanks.

i start my program with a login script. after verifying, the screen resolution will change to 640 X 480 with the main form.

when i click on the control to active form 3, it was hidden at the back of main form.

how can i make it appear in front of the main form without unloading it.
tancy1Asked:
Who is Participating?
 
coopzzConnect With a Mentor Commented:
Can I see you other hook functions and stuff  to get my window always on top I've used the function successfully.. it always brought the window I wanted to the front


Private Declare Sub 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)

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40

Public Sub WindowOnTop(oForm As Form, Optional bTop As Boolean = True)
    With oForm
        If (bTop) Then
            SetWindowPos .hWnd, HWND_TOPMOST, .Left / 15, _
                        .Top / 15, .Width / 15, _
                        .Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
        Else
            SetWindowPos .hWnd, HWND_NOTOPMOST, .Left / 15, _
                        .Top / 15, .Width / 15, _
                        .Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
        End If
    End With

End Sub
0
 
Farzad AkbarnejadDeveloperCommented:
Hi,

Try to use ZOrder method of showed form:

    Load Form1
    Form1.ZOrder
    Form1.Show

-FA
0
 
tancy1Author Commented:
still the same.. tq
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Farzad AkbarnejadDeveloperCommented:
Try to run

Form3.left = 0
Form3.top = 0

Before activating form 3

-FA
0
 
tancy1Author Commented:
cannot also....
0
 
Farzad AkbarnejadDeveloperCommented:
If you can post your code here or zip file of your project to the Net.

-FA
0
 
tancy1Author Commented:
Option Explicit
' Warning... Alt-Tabbing to VB will be
' messy, since it's linked to the form!

Private lOldWidth As Long
Private lOldHeight As Long
Private lOldDepth As Long
Private mLoaded As Boolean
Public Sub Verifylevel()
If m_level = "admin" Then
    frmAdmin.Show
ElseIf m_level = "manager" Or m_level = "inquiry" Or m_level = "user" Then
    AdminWarn.Show
End If
End Sub
Private Sub AdminImg_Click()
Verifylevel
End Sub
Private Sub CreateImg_Click()
If m_level = "inquiry" Or m_level = "manager" Then
MsgBox "Your Roles Does Not Permit You To Create Bills"
Else
frmcreate.Show
End If
End Sub
Private Sub PaymentImg_Click()
If m_level = "admin" Or m_level = "inquiry" Then
    Payment.ZOrder
    Payment.Show
ElseIf m_level = "manager" Or m_level = "user" Then
    MsgBox "You Are Not Authorised To Access This Module"
End If
End Sub
Private Sub QueryImg_Click()
frmQuery.Show
End Sub
Private Sub EditImg_Click()
If m_level = "inquiry" Or m_level = "manager" Then
MsgBox "Your Roles Does Not Permit You To Edit Bills"
Else
frmBillEdit.Show
End If
End Sub
Private Sub logout_Click()
MsgBox "Have A Nice Day"
Unload Me
End Sub
Private Sub ToolImg_Click()
MsgBox "This Module is not available yet"
End Sub
Private Sub form_load()
    ' Size the window
    Me.Left = 0
    Me.Top = 0
    Me.Width = 640 * Screen.TwipsPerPixelX
    Me.Height = 480 * Screen.TwipsPerPixelY
    ' Get the current screen resolution and store it
    GetScreenRes lOldWidth, lOldHeight, lOldDepth
    ' Set to our new resoution
    ' BitDepth could be 4, 8, 16, 24, or 32 (24 + 8bits alpha)
    ' but we'll just use the existing color depth
    If SetScreenRes(640, 480, lOldDepth) Then ' If the set worked
        SetTopMost Me.hWnd ' Self-explanatory (I hope;)
        Hook Me ' Start handling GotFocus/LostFocus messages
        mLoaded = True ' Set a loaded flag (see Form_Unload)
    Else
        ' It didn't work!?
        ' Either the system must reboot to change to this resolution,
        ' which we don't want it to do, or the specified resolution
        ' is unavailable on the current device (*frown*)
        MsgBox "Aww... too bad. And this would have really rocked!"
        Unload Me
    End If
End Sub

Public Sub FormLostFocus()
    SetTopMost Me.hWnd, False ' Ah, why not
    Me.WindowState = vbMinimized ' Get shrunk!
    SetScreenRes lOldWidth, lOldHeight, lOldDepth ' Return to original resolution
End Sub

Public Sub FormGotFocus()
    GetScreenRes lOldWidth, lOldHeight, lOldDepth ' In case the user changed something
    SetScreenRes 640, 480, lOldDepth ' Return to our mode
    SetTopMost Me.hWnd ' Just in case
End Sub

Private Sub Form_Unload(cancel As Integer)
    If mLoaded Then ' If we actually have stuff to undo
        Unhook ' Stop getting focus messages
        SetScreenRes lOldWidth, lOldHeight, lOldDepth ' Return to the original resolution
    End If
End Sub
0
 
Farzad AkbarnejadDeveloperCommented:
I haven't SetScreenRes and GetScreenRes function.

-FA
0
 
coopzzCommented:
Have you tried

Form1.SetFocus
0
 
coopzzCommented:
Actually if's hidden I think you need to make it visible too. So:

Form1.visible = true
Form1.SetFocus
0
 
tancy1Author Commented:
cannot...thanks..
0
 
tancy1Author Commented:
i already have the functions.
0
 
tancy1Author Commented:
anyone have ideas
0
 
coopzzCommented:
if you want it to be the only one to be hit in the program at the time you can set it to vbModal when you show the form

ie:
Form1.show vbModal

also if the form is loaded in memory the .show method will set the visibility to true and show.
with the vbModal your form will react like a msgbox.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.