另外弹出的form不要用有模式方式

解决方案 »

  1.   

    请详细一点, ltpao(啊炮)兄
      

  2.   


    请在程序中加个  DoEvents 
      

  3.   

    举个例子:
    有Form1 和 Form2'form1
    Private Sub Command1_Click()
        Form2.Show 0, Form1
        form1.enabled=false
        '添加你的代码
       '不要忘记在使用进度条的时候添加Doevents
        unload form2
        form1.enabled=true
        form1.setfoces
    End Sub
      

  4.   

    '在程序中显示进度条
        Load frmProgress
        frmProgress.pProgressStatus = 0
        For i = 1 To 10000
            frmProgress.pStatusCaption = "Progress" & i
            frmProgress.pProgressStatus = Int((i / 10000) * 100)
            DoEvents
            DoEvents
        Next i
        Unload frmProgress'进度条窗体代码 frmProgress.frm
    VERSION 5.00
    Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
    Begin VB.Form frmProgress 
       BorderStyle     =   3  'Fixed Dialog
       ClientHeight    =   405
       ClientLeft      =   255
       ClientTop       =   1410
       ClientWidth     =   7380
       ClipControls    =   0   'False
       ControlBox      =   0   'False
       Icon            =   "frmProgress.frx":0000
       KeyPreview      =   -1  'True
       LinkTopic       =   "Form2"
       MaxButton       =   0   'False
       MinButton       =   0   'False
       ScaleHeight     =   405
       ScaleWidth      =   7380
       ShowInTaskbar   =   0   'False
       StartUpPosition =   2  '屏幕中心
       Begin MSComctlLib.ProgressBar pbrStatus 
          Height          =   405
          Left            =   2880
          TabIndex        =   0
          Top             =   0
          Width           =   4500
          _ExtentX        =   7938
          _ExtentY        =   714
          _Version        =   393216
          Appearance      =   0
          Scrolling       =   1
       End
       Begin MSComctlLib.StatusBar sbrStatus 
          Align           =   2  'Align Bottom
          Height          =   420
          Left            =   0
          TabIndex        =   1
          Top             =   -15
          Width           =   7380
          _ExtentX        =   13018
          _ExtentY        =   741
          _Version        =   393216
          BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
             NumPanels       =   1
             BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
                AutoSize        =   2
                Object.Width           =   5027
                MinWidth        =   5027
             EndProperty
          EndProperty
          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
             Name            =   "宋体"
             Size            =   15.75
             Charset         =   134
             Weight          =   700
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
       End
    End
    Attribute VB_Name = "frmProgress"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option Explicit
    Private Declare Function 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) As Long
    Private Const SWP_NOACTIVATE = &H10
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_SHOWSPLASH = (SWP_NOACTIVATE Or SWP_NOMOVE Or SWP_NOSIZE)
    Private Const HWND_TOPMOST = -1Public Property Get pProgressStatus() As Long
        On Error Resume Next
        pProgressStatus = pbrStatus.Value
    End PropertyPublic Property Let pProgressStatus(vData As Long)
        On Error Resume Next
        If vData >= 0 And vData <= 100 Then
            pbrStatus.Value = vData
        End If
    End PropertyPublic Property Let pStatusCaption(vData As String)
        On Error Resume Next
        sbrStatus.Panels(1).Text = vData
    End PropertyPrivate Sub Form_Load()
        Me.Show
        Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWSPLASH)
    End Sub
      

  5.   

    为什么我在Form1中Show Form2时报错:
    Can't show non-modal form when modal form is displayed另外谁能解释一下DoEnvens吗?
      

  6.   

    因為你調用精度條窗體的窗體是用模式方式打開的,在模式窗體中不能再打開一個非模式窗體
    模式窗口:  frm.show ,1
    非模式窗口 frm.show ,0
      

  7.   

    DoEnvens
    將程序控制權釋放給系統,讓系統先完成任務序列中的其他指令
      

  8.   

    为什么我在Form1中Show Form2时报错:
    Can't show non-modal form when modal form is displayed另外谁能解释一下DoEnvens吗? 
    报这个错误的原因是打开Form2的那个窗口(暂且叫他Form1)是作为由模式窗口打开的.
    show form1 1 -> show form1
      

  9.   

    但form1是在其他form上的不用模式的话,不能让他在其他form上了
      

  10.   

    不要用模式打開form1
    如果要讓它在上方可以這樣做
    Private Sub Form_Deactivate()
        me.SetFocus 
    End Sub