Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cannot view forms (urgent) thanks.

Posted on 2004-08-25
16
Medium Priority
?
177 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
Industry Leaders: 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!

 

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 220 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

715 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