Visual Basic Foro

Programación => Visual Basic 6 => Mensaje iniciado por: E N T E R en Noviembre 01, 2012, 02:12:19 pm

Título: ucTextBox igual a esta (Practicando)
Publicado por: E N T E R en Noviembre 01, 2012, 02:12:19 pm
Siguiendo lo que postee aca: http://leandroascierto.com/foro/index.php?topic=1930.0

Esta función dibuja un cuadro con las puntas redondeadas.
Código: (VB) [Seleccionar]
Private Sub DrawButton()

    Dim PT As POINTAPI, Pen As Long, hPen As Long
    Dim i As Long, ColorR As Long, ColorG As Long, ColorB As Long
    Dim hBrush As Long
       
    UserControl.Cls
       
    With UserControl
   
      'hBrush = CreateSolidBrush(RGB(0, 60, 116))
      hBrush = CreateSolidBrush(RGB(194, 193, 193))
      FrameRect UserControl.hdc, rc, hBrush
      DeleteObject hBrush
     
      'Left top corner
      SetPixel .hdc, l, t + 1, RGB(205, 207, 209)
      SetPixel .hdc, l + 1, t + 1, RGB(232, 232, 234)
      SetPixel .hdc, l + 1, t, RGB(205, 207, 209)
     
      'right top corner
      SetPixel .hdc, r - 1, t, RGB(205, 207, 209)
      SetPixel .hdc, r - 1, t + 1, RGB(232, 232, 234)
      SetPixel .hdc, r, t + 1, RGB(205, 207, 209)
     
      'left bottom corner
      SetPixel .hdc, l, B - 2, RGB(205, 207, 209)
      SetPixel .hdc, l + 1, B - 2, RGB(232, 232, 234)
      SetPixel .hdc, l + 1, B - 1, RGB(205, 207, 209)
     
      'right bottom corner
      SetPixel .hdc, r, B - 2, RGB(205, 207, 209)
      SetPixel .hdc, r - 1, B - 2, RGB(232, 232, 234)
      SetPixel .hdc, r - 1, B - 1, RGB(205, 207, 209)
           
    End With
   
    DeleteObject regMain
    regMain = CreateRectRgn(0, 0, w, h)
    rgn1 = CreateRectRgn(0, 0, 1, 1)              'Left top coner
    CombineRgn regMain, regMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(0, h - 1, 1, h)          'Left bottom corner
    CombineRgn regMain, regMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(w - 1, 0, w, 1)          'Right top corner
    CombineRgn regMain, regMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(w - 1, h - 1, w, h)      'Right bottom corner
    CombineRgn regMain, regMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    SetWindowRgn UserControl.hwnd, regMain, True
 
End Sub

A partir de acá como puedo pintar la linea roja y el verde.

(http://www.mediafire.com/conv/b009bc08c724471c894e8a10fe1a4804c6def44f7faedbb0e791e7033909137d4g.jpg) (http://www.mediafire.com/view/?5jv31ztx72qgdgn)

SOURCE DEL PROYECTO
http://www.mediafire.com/?4nmcc54d59d56cc
Título: Re:ucTextBox igual a esta (Practicando)
Publicado por: 79137913 en Noviembre 01, 2012, 03:00:48 pm
HOLA!!!

Mira, yo lo encararia de esta manera (mucho menos codigo)

fijate:

http://www.mediafire.com/?ftew4xfcy075csr

GRACIAS POR LEER!!!
Título: Re:ucTextBox igual a esta (Practicando)
Publicado por: E N T E R en Noviembre 01, 2012, 03:29:48 pm
Interesante 79137913, vamos a mirar a ver que sale.
Título: Re:ucTextBox igual a esta (Practicando)
Publicado por: LeandroA en Noviembre 01, 2012, 03:44:08 pm
Hola ENTER, va queriendo, hay muchas formas que se me ocurren pero bueno, dale como lo estas haciendo, por lo que preguntas agregas estas dos lineas


Código: [Seleccionar]
      UserControl.Line (0, 0)-(23, UserControl.ScaleHeight), RGB(238, 238, 238), BF
      UserControl.Line (23, 0)-(23, UserControl.ScaleHeight), RGB(194, 193, 193)


Código: [Seleccionar]
Private Sub DrawButton()

    Dim PT As POINTAPI, Pen As Long, hPen As Long
    Dim i As Long, ColorR As Long, ColorG As Long, ColorB As Long
    Dim hBrush As Long
       
    UserControl.Cls
       
    With UserControl
   
      UserControl.Line (0, 0)-(23, UserControl.ScaleHeight), RGB(238, 238, 238), BF
      UserControl.Line (23, 0)-(23, UserControl.ScaleHeight), RGB(194, 193, 193)
   
      'hBrush = CreateSolidBrush(RGB(0, 60, 116))
      hBrush = CreateSolidBrush(RGB(194, 193, 193))
      FrameRect UserControl.hdc, rc, hBrush
      DeleteObject hBrush
     
      'Left top corner
      SetPixel .hdc, l, t + 1, RGB(205, 207, 209)
      SetPixel .hdc, l + 1, t + 1, RGB(232, 232, 234)
      SetPixel .hdc, l + 1, t, RGB(205, 207, 209)
     
      'right top corner
      SetPixel .hdc, r - 1, t, RGB(205, 207, 209)
      SetPixel .hdc, r - 1, t + 1, RGB(232, 232, 234)
      SetPixel .hdc, r, t + 1, RGB(205, 207, 209)
     
      'left bottom corner
      SetPixel .hdc, l, B - 2, RGB(205, 207, 209)
      SetPixel .hdc, l + 1, B - 2, RGB(232, 232, 234)
      SetPixel .hdc, l + 1, B - 1, RGB(205, 207, 209)
     
      'right bottom corner
      SetPixel .hdc, r, B - 2, RGB(205, 207, 209)
      SetPixel .hdc, r - 1, B - 2, RGB(232, 232, 234)
      SetPixel .hdc, r - 1, B - 1, RGB(205, 207, 209)
     

           
    End With
   
    DeleteObject regMain
    regMain = CreateRectRgn(0, 0, w, h)
    rgn1 = CreateRectRgn(0, 0, 1, 1)              'Left top coner
    CombineRgn regMain, regMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(0, h - 1, 1, h)          'Left bottom corner
    CombineRgn regMain, regMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(w - 1, 0, w, 1)          'Right top corner
    CombineRgn regMain, regMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(w - 1, h - 1, w, h)      'Right bottom corner
    CombineRgn regMain, regMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    SetWindowRgn UserControl.hwnd, regMain, True
 
End Sub

Saludos.
Título: Re:ucTextBox igual a esta (Practicando)
Publicado por: 79137913 en Noviembre 01, 2012, 03:45:43 pm
HOLA!!!

Te diria que guardes la funcion que coloque es muy util, redondeas las puntas de cualquier control (incluso el form)

GRACIAS POR LEER!!!
Título: Re:ucTextBox igual a esta (Practicando)
Publicado por: E N T E R en Noviembre 01, 2012, 03:51:55 pm
Buenisimo Leandro, gracias bro...
Título: Re:ucTextBox igual a esta (Practicando)
Publicado por: E N T E R en Noviembre 01, 2012, 03:53:03 pm

Te diria que guardes la funcion que coloque es muy util, redondeas las puntas de cualquier control (incluso el form)


Claro man ya se me ocurrio para un proyecto que tube dibujar en paint cada picture
Título: Re:ucTextBox igual a esta (Practicando)
Publicado por: Cudder en Noviembre 16, 2012, 04:22:17 pm
HOLA!!!

Mira, yo lo encararia de esta manera (mucho menos codigo)

fijate:

http://www.mediafire.com/?ftew4xfcy075csr

GRACIAS POR LEER!!!

Hola I like your example and I wondered if you could make a txtBox like this one:

(https://dl.dropbox.com/u/85935699/1.PNG)
Título: Re:ucTextBox igual a esta (Practicando)
Publicado por: 79137913 en Noviembre 19, 2012, 06:41:49 am
HOLA!!!

Picture DOWN plz re-Upload

GRACIAS POR LEER!!!