Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente di HTML.it L'avatar di poves
    Registrato dal
    Dec 2010
    Messaggi
    17

    [VB6] Oscurare schermo

    Esiste un modo per oscurare lo schermo?? (tipo quando in xp si clicca su spegni il computer) grz in anticipo

  2. #2
    Utente di HTML.it L'avatar di yyzyyz
    Registrato dal
    Oct 2001
    Messaggi
    1,653
    simula uno screensaver.
    imposta su form1, Form1.BorderStyle = 0
    codice:
    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
        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
    
       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
    
    Private Sub Form_Load()
    Form1.WindowState = 2
    Form1.BackColor = RGB(0, 0, 0)
    
    Dim X As Integer
    Call AlwaysOnTop(Me, True)
    X = ShowCursor(False)
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    Dim X As Integer
    X = ShowCursor(True)
    End Sub
    
    Private Sub Form_Terminate()
    Dim X As Integer
    X = ShowCursor(True)
    End Sub

  3. #3
    Utente di HTML.it L'avatar di poves
    Registrato dal
    Dec 2010
    Messaggi
    17
    mah non è l'effetto k desideravo...lo skermo è del tutto nero e la finestra in qst modo è a tt skermo...grz cmq x l'aiuto aspetto altri suggerimenti...

  4. #4
    Utente di HTML.it L'avatar di gibra
    Registrato dal
    Apr 2008
    residenza
    Italy
    Messaggi
    4,244
    Originariamente inviato da poves
    mah non è l'effetto k desideravo...lo skermo è del tutto nero e la finestra in qst modo è a tt skermo...grz cmq x l'aiuto aspetto altri suggerimenti...
    Al codice che hai già ricevuto aggiungi questo codice:

    codice:
    ' nelle Dichiarazioni del form
    Const LWA_COLORKEY = &H1
    Const LWA_ALPHA = &H2
    Const GWL_EXSTYLE = (-20)
    Const WS_EX_LAYERED = &H80000
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    
    ' nell'evento Form_Load()
    Dim Ret As Long
    'Set the window style to 'Layered'
    Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
    Ret = Ret Or WS_EX_LAYERED
    SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
    SetLayeredWindowAttributes Me.hWnd, 0, 128, LWA_ALPHA
    per migliorarlo ulteriormente puoi impostare il Form con
    BorderStyle=0

    ma poi devi anche usare
    codice:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyEscape Then
            Unload Me
        End If
    End Sub
    così premendo ESC puoi uscire, altrimenti sei bloccato.

    Voilà! Il gioco è fatto.


    P.S.
    Per cortesia evita il linguaggio SMS, sappi che sui forum tecnici non è tollerato.

  5. #5
    Utente di HTML.it L'avatar di poves
    Registrato dal
    Dec 2010
    Messaggi
    17
    ok scusa per il linguaggio...comunque grazie mille è perfetto!!

  6. #6
    Utente di HTML.it
    Registrato dal
    Mar 2011
    Messaggi
    4
    ma va anche con windows 7 64 bit?
    mi da errore nel codice con visual basic 2010

  7. #7
    Utente di HTML.it L'avatar di gibra
    Registrato dal
    Apr 2008
    residenza
    Italy
    Messaggi
    4,244
    Originariamente inviato da Stellsl
    ma va anche con windows 7 64 bit?
    mi da errore nel codice con visual basic 2010
    Cosa c'entra VB 2010?
    Ovvio che non funziona.

    Come è indicato nel titolo il codce è per VB6 .

    Comunque il codice (in VB6!) funziona anche su Windows 7.


  8. #8
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,472

    Moderazione

    Originariamente inviato da Stellsl
    ma va anche con windows 7 64 bit?
    mi da errore nel codice con visual basic 2010
    La discussione si riferisce a un altro linguaggio, quindi è inutile risollevarla per porre una domanda di questo tipo: tanto vale aprire una nuova discussione in cui parlare del proprio problema specifico (tenendo conto che VB6 e VB.NET, nonostante l'assonanza del nome, sono agli antipodi).
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.