Solved

cannot view forms (urgent) thanks.

Posted on 2004-08-25
16
163 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
  • 6
  • 4
  • 4
16 Comments
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
Comment Utility
Hi,

Try to use ZOrder method of showed form:

    Load Form1
    Form1.ZOrder
    Form1.Show

-FA
0
 

Author Comment

by:tancy1
Comment Utility
still the same.. tq
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
Comment Utility
Try to run

Form3.left = 0
Form3.top = 0

Before activating form 3

-FA
0
 

Author Comment

by:tancy1
Comment Utility
cannot also....
0
 
LVL 14

Expert Comment

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

-FA
0
 

Author Comment

by:tancy1
Comment Utility
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
Comment Utility
I haven't SetScreenRes and GetScreenRes function.

-FA
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:coopzz
Comment Utility
Have you tried

Form1.SetFocus
0
 
LVL 11

Expert Comment

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

Form1.visible = true
Form1.SetFocus
0
 

Author Comment

by:tancy1
Comment Utility
cannot...thanks..
0
 

Author Comment

by:tancy1
Comment Utility
i already have the functions.
0
 

Author Comment

by:tancy1
Comment Utility
anyone have ideas
0
 
LVL 11

Expert Comment

by:coopzz
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now