开发者

VB6: why doesn't full screen load while Inet is running?

Basically I have a form that goes full screen automatically. But while Inet runs, this doesn't happen. After Inet finishes, app goes to full screen.

      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 Declare Function ShowCursor Lib "user32" _
              (ByVal bShow As Long) As Long

Private Sub Form_Load()

Dim x As Integer

Call AlwaysOnTop(Me, True)

x = ShowCursor(True)


Dim Download() As Byte

Download() = Inet1.OpenURL("http://www.site.com/23423/server.txt)
Open ("server.txt") For Binary Access Write As #1
Put #1, , DownloadData()
Close #1

End Sub

Sub AlwaysOnTop(FrmID As Form, OnT开发者_Go百科op As Boolean)

         Const SWP_NOMOVE = 2

         Const SWP_NOSIZE = 1

         Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE

         Const HWND_TOPMOST = -1

         Const HWND_NOTOPMOST = -2



         If OnTop Then

            OnTop = SetWindowPos(FrmID.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)

         Else

            OnTop = SetWindowPos(FrmID.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)

         End If
End Sub


It is not specifically about Inet - the form is redrawn only when the Form_Load method is done - VB6 has time to do its own stuff and update the user interface.

You can try DoEvents like in this example and I think it should help: http://www.daniweb.com/forums/thread65362.html


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 Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

Private Sub Form_Load()
  AlwaysOnTop Me, True
  ShowCursor True
  DoEvents '' <---- This is what you need.

  Dim Download() As Byte
  Dim FileHandle As Long
  Download() = Inet1.OpenURL("http://www.site.com/23423/server.txt")
  FileHandle = FreeFile()
  Open ("server.txt") For Binary Access Write As FileHandle
  Put FileHandle, , DownloadData()
  Close FileHandle
End Sub

Sub AlwaysOnTop(FrmID As Form, OnTop As Boolean)
  Const SWP_NOMOVE = 2
  Const SWP_NOSIZE = 1
  Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
  Const HWND_TOPMOST = -1
  Const HWND_NOTOPMOST = -2
  SetWindowPos FrmID.hwnd, Iif(OnTop, HWND_TOPMOST, HWND_NOTOPMOST), 0, 0, 0, 0, FLAGS
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜