Solved

cannot view forms (urgent) thanks.

Posted on 2004-08-25
16
176 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:tancy1
[X]
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
  • 6
  • 4
  • 4
16 Comments
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 11889852
Hi,

Try to use ZOrder method of showed form:

    Load Form1
    Form1.ZOrder
    Form1.Show

-FA
0
 

Author Comment

by:tancy1
ID: 11889893
still the same.. tq
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 11890088
Try to run

Form3.left = 0
Form3.top = 0

Before activating form 3

-FA
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:tancy1
ID: 11890215
cannot also....
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 11890229
If you can post your code here or zip file of your project to the Net.

-FA
0
 

Author Comment

by:tancy1
ID: 11890337
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
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 11890560
I haven't SetScreenRes and GetScreenRes function.

-FA
0
 
LVL 11

Expert Comment

by:coopzz
ID: 11898460
Have you tried

Form1.SetFocus
0
 
LVL 11

Expert Comment

by:coopzz
ID: 11898465
Actually if's hidden I think you need to make it visible too. So:

Form1.visible = true
Form1.SetFocus
0
 

Author Comment

by:tancy1
ID: 11899270
cannot...thanks..
0
 

Author Comment

by:tancy1
ID: 11899279
i already have the functions.
0
 

Author Comment

by:tancy1
ID: 11900377
anyone have ideas
0
 
LVL 11

Expert Comment

by:coopzz
ID: 11900434
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
 
LVL 11

Accepted Solution

by:
coopzz earned 55 total points
ID: 11900542
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

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This video teaches viewers about errors in exception handling.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

628 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