🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #842

Re: MsgBox

#842
From: News
Date: Tue, 03 May 2005 10:11
63 lines
2792 bytes
In data Thu, 28 Apr 2005 09:22:47 +0200, Giovanni Menichetti  
<giovannimenichetti1@virgilio.it> ha scritto:

> Salve
>
> ho una MSGBOX con il solo pulsante "OK", e vorrei che dopo 5 sec si
> chiudesse da sola.
>
> E' possibile?
>

Inserisci in un modulo bas il seguente codice:

Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal  
nIDEvent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"  
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As  
Long) As Long

Public Const NV_CLOSEMSGBOX As Long = &H5000&

Public Sub TimerProc(ByVal hWnd As Long, ByVal uMsg As Long, _
                      ByVal idEvent As Long, ByVal dwTime As Long)

     KillTimer hWnd, idEvent

     Select Case idEvent
     Case NV_CLOSEMSGBOX
         Dim hMessageBox As Long

         hMessageBox = FindWindow("#32770", App.EXEName)

         If hMessageBox Then
             Call SetForegroundWindow(hMessageBox)

             SendKeys "{enter}"
         End If
     End Select
End Sub



Poi , nel punto dove ti serve, la chiami in questo modo:

      SetTimer hWnd, NV_CLOSEMSGBOX, 1000, AddressOf TimerProc

e di seguito scrivi la msgbox come preferisci
      MsgBox "Codice Oggetto non trovato.", vbInformation

Questo codice � stato prelevato da un mio progetto scritto in VB6 e che  
gira su WinXp e quindi in questo ambiente funziona; se usi vb Net non  
saprei dirti se va bene lo stesso.

Ciao.

N.B.
con 1000 si intende il tempo, espresso in millisecondi, di visualizzazione  
della MsgBox
Se vuoi che passino 5 secondi devi modificare tale valore in 5000
-- 
Creato con il rivoluzionario client e-mail di Opera:  
http://www.opera.com/m2/
Technical Details
Message-ID: <op.sp62lornsk78dr@game-fae1b40ae6>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.tin.it!news-in.tin.it!news4.tin.it.POSTED!not-for-mail
References: <bb0ce.833486$b5.36965168@news3.tin.it>

Show Full Headers
Complete Article Headers
X-Google-Thread: f94ee,e1a674f7070633b6
X-Google-Attributes: gidf94ee,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.tin.it!news-in.tin.it!news4.tin.it.POSTED!not-for-mail
Newsgroups: free.it.visual-basic
Subject: Re: MsgBox
References: <bb0ce.833486$b5.36965168@news3.tin.it>
Message-ID: <op.sp62lornsk78dr@game-fae1b40ae6>
From: News <etsero2NOSPAM@tin.it>
Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
User-Agent: Opera M2/8.0 (Win32, build 7561)
Lines: 63
Date: Tue, 03 May 2005 10:11:53 GMT
NNTP-Posting-Host: 82.54.133.87
X-Complaints-To: "Please send abuse reports to abuse@tin.it and technical notifications to newsmaster@tin.it"
X-Trace: news4.tin.it 1115115113 82.54.133.87 (Tue, 03 May 2005 12:11:53 MET DST)
NNTP-Posting-Date: Tue, 03 May 2005 12:11:53 MET DST
Organization: TIN