Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.lang.visual-basic > #19105

Re: VB6 usare le forme

From SB <stNOOObenevSPAM@tin.it>
Newsgroups it.comp.lang.visual-basic
Subject Re: VB6 usare le forme
Date 2017-07-31 19:39 +0200
Organization Aioe.org NNTP Server
Message-ID <ubpunctn7q4snndu9hgtjt5uj4uves3v4d@4ax.com> (permalink)
References <oln34g$hg7$1@solani.org>

Show all headers | View raw


Il giorno Mon, 31 Jul 2017 13:09:03 +0200, Greg <greg@alicie.com> ha scritto:

>C'è un modo di usare, o costruire, una forma sullo stile di quelle contenute in word?
>Nello specifico mi servirebbe avre un rettanfolo dove ci possa scrivere dentro e impostare il
>colore di sfondo - e mi andrebbe bene una labl - ma anche che assomigli ad una freccia. Merci e
>buone vacanze a tutti :)


Quelle cose si fanno velocemente con le API, disegnando su un Form o una
Picturebox.
Si usa la FillRect un paio di volte per il bordo e lo sfondo e poi la DrawText
per il testo.


Esempio al volo, sono in ferie, non ho molto tempo
e non ho nemmeno il vb per provare  :-)

Comunque ho accesso web al mio software VB

Crea un form con una PictureBox di nome Pic

Le API che ti servono sono queste:
____________________________________________-



Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As
Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat
As Long) As Long

Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long,
ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As
RECT, ByVal hBrush As Long) As Long

Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As
Long

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Dim R As RECT, hBrush  as Long, Flgs as Long, TxB as String

Const DT_SINGLELINE As Long = &H20& 
Const DT_NOCLIP As Long = &H100&  
Const DT_CENTER As Long = &H1& 

Const C_DT_FLAGS = DT_SINGLELINE Or DT_NOCLIP Or DT_CENTER

    hBrush = CreateSolidBrush(vbBlack)

    SetRect R, 0, 0, 100, 100
    FillRect Pic.hdc, R, hBrush     'DISEGNA RETTANGOLO NERO

    SetRect R, 10,10, 90, 90 

    hBrush = CreateSolidBrush(vbCyan)
    FillRect Pic.hdc, R, hBrush     'DISEGNA RETTANGOLO SFONDO CIANO

TxB ="PROVA"
Flgs = C_DT_FLAGS

     SetRect R, 20,20, 80, 80 

      i = DrawText(Pic.hdc, TxB, Len(TxB), R, Flgs)


Chiaramente la DrawText userà il font della Pic con tutti i suoi attributi.

Non posso provare niente qui adesso ma ti dovrebbe bastare come spunto.



-- 
ciao
  Stefano

Back to it.comp.lang.visual-basic | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

VB6 usare le forme Greg <greg@alicie.com> - 2017-07-31 13:09 +0200
  Re: VB6 usare le forme SB <stNOOObenevSPAM@tin.it> - 2017-07-31 19:39 +0200
    Re: VB6 usare le forme Greg <greg@alicie.com> - 2017-07-31 21:46 +0200
      Re: VB6 usare le forme SB <stNOOObenevSPAM@tin.it> - 2017-08-01 19:22 +0200
        Re: VB6 usare le forme Paperino <non_te@lo.dico.invalid> - 2017-08-02 15:25 +0200
          Re: VB6 usare le forme SB <stNOOObenevSPAM@tin.it> - 2017-08-02 19:10 +0200
            Re: VB6 usare le forme Paperino <non_te@lo.dico.invalid> - 2017-08-02 19:23 +0200
  Re: VB6 usare le forme Paperino <non_te@lo.dico.invalid> - 2017-08-01 01:09 +0200
    Re: VB6 usare le forme Greg <greg@alicie.com> - 2017-08-01 08:05 +0200

csiph-web