Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di x69asterix
    Registrato dal
    Jan 2005
    Messaggi
    1,303

    colorare un pixel

    ciao,
    stò cercando di colorare un pixel senza risultato , come codice uso:


    chiaramente conosco sia x che y con

    codice:
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Dim Pt As POINTAPI
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        'redirect all mouse input to this form
        SetCapture Me.hwnd
    End Sub
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        ReleaseCapture
        SetCapture Me.hwnd
    End Sub
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        'Get the current cursor position
        GetCursorPos Pt
        Me.CurrentX = 0
        Me.CurrentY = 0
        'Clear the screen
        Me.Cls
       ' Me.Print "Cursor position:"
        'Print the mouse coördinates to the form
        Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y)
     '   Me.Print " (Press ALT-F4 to unload this form)"
        SetCapture Me.hwnd
    End Sub
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        ReleaseCapture
        SetCapture Me.hwnd
    End Sub
    per colorare senza risultato:
    codice:
    Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
    
    
    Private Sub Command4_Click()
    
    Picture1.PSet (x, y), vbGreen
    
    End Sub
    qualche suggerimento?

  2. #2
    Utente di HTML.it L'avatar di hkproj
    Registrato dal
    Jul 2006
    Messaggi
    250
    magari la proprietà backcolor del tuo form è uguale a quella del pixel da colorare...

    e poi, questi X e Y dove li hai presi?
    Picture1.PSet (X, y), vbGreen
    magari sono cieco io,a ma controlla anche tu

    e cmq a me il codice funziona...

    Private Sub Command4_Click()

    Picture1.PSet (90, 50), vbGreen

    End Sub
    ciao, credo che l'errore sia facile da capire, infatti tu dici al commandbutton di colorare l'area della picturebox che è sotto al mouse, ma come fai a colorare la picture box se il tuo mouse è sopra il command button per cliccare

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.