Solved

cannot view forms (urgent) thanks.

Posted on 2004-08-25
16
174 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
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
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.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
mirrorEnds challenge 6 142
mapBully challenge 6 154
word0 challenge 4 71
Problem to Alipay 10 46
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…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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