Code : Tout sélectionner
#STYLE_DEFAULT          = 32
#STYLE_LINENUMBER       = 33
#SCI_STYLESETSIZE       = 2055
#SCI_STYLESETFONT       = 2056
#SCI_STYLESETFORE       = 2051
#SCI_STYLESETBACK       = 2052
#SCI_STYLECLEARALL      = 2050
#SCI_SETMARGINWIDTHN    = 2242
#SCI_INSERTTEXT         = 2003
#SCI_SETSELBACK         = 2068
#SCI_SETSELFORE         = 2067
#SCI_SETCARETFORE       = 2069
#SCI_SETCARETWIDTH      = 2188
#SCI_STARTSTYLING       = 2032
#SCI_SETSTYLING         = 2033
#SCI_MARKERDEFINE       = 2040
#SC_MARK_ARROW          = 2
#SC_MARK_ARROWDOWN      = 6
#SCI_MARKERADD          = 2043
#SCI_MARKERDELETE       = 2044
#SCI_SHOWLINES          = 2226
#SCI_HIDELINES          = 2227
#SCI_SETFOLDEXPANDED    = 2229
#SCN_MARGINCLICK        = 2010
#SCI_LINEFROMPOSITION   = 2166
#SCI_MARKERGET          = 2046
#SCI_SETINDENTATIONGUIDES=2132
#SCI_SETINDENT          = 2122
#SCI_SETFOLDFLAGS       = 2233
#SCI_SETLINEINDENTATION = 2126
#SCI_SETMARGINSENSITIVEN= 2246
#SCI_SETMARGINMASKN     = 2244
#SC_MASK_FOLDERS        = $FE000000
#SCI_SETFOLDLEVEL       = 2222
#SC_FOLDLEVELHEADERFLAG = $2000
Structure NotifyHeader
     hwndFrom.l
     idFrom.l
     code.l
EndStructure
Structure SCNotification
     NMHDR.NotifyHeader
     position.l;   // SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND
     ch.l;      // SCN_CHARADDED, SCN_KEY
     modifiers.l;   // SCN_KEY
     modificationType.l;   // SCN_MODIFIED
     text.l;         // SCN_MODIFIED
     length.l;      // SCN_MODIFIED
     linesAdded.l;    // SCN_MODIFIED
     message.l;         // SCN_MACRORECORD
     wParam.l;         // SCN_MACRORECORD
     lParam.l;       // SCN_MACRORECORD
     line.l;      // SCN_MODIFIED
     foldLevelNow.l;   // SCN_MODIFIED
     foldLevelPrev.l;   // SCN_MODIFIED
     margin.l;      // SCN_MARGINCLICK
     listType.l;   // SCN_USERLISTSELECTION
     x.l;         // SCN_DWELLSTART, SCN_DWELLEND
     y.l;      // SCN_DWELLSTART, SCN_DWELLEND
EndStructure
Global hLib,hwnd,Brosse,hScintilla
Procedure WindowCallback(WindowId, message, wParam, lParam)
     Result = #PB_ProcessPureBasicEvents
     Select message
      Case #wm_notify
               *msg.SCNotification=lParam
               If *msg\NMHDR\hwndFrom = hScintilla
                    Select *msg\NMHDR\code
                         Case #SCN_MARGINCLICK
                              If *msg\margin=1
                     Ligne = SendMessage_(hScintilla,#SCI_LINEFROMPOSITION,*msg\position,0)
                     Marker = SendMessage_(hScintilla,#SCI_MARKERGET,Ligne,0)
                     Debug Marker
                     If Marker & 1
                                        SendMessage_(hScintilla,#SCI_SETFOLDEXPANDED,0,1)
                                        SendMessage_(hScintilla,#SCI_MARKERDELETE,Ligne,0)
                                        SendMessage_(hScintilla,#SCI_MARKERADD,Ligne,1)
                                        SendMessage_(hScintilla,#SCI_SHOWLINES,1,6)
                                   ElseIf Marker & 2
                                        SendMessage_(hScintilla,#SCI_SETFOLDEXPANDED,0,1)
                                        SendMessage_(hScintilla,#SCI_MARKERDELETE,Ligne,1)
                                        SendMessage_(hScintilla,#SCI_MARKERADD,Ligne,0)
                                        SendMessage_(hScintilla,#SCI_HIDELINES,1,6)
                                   EndIf
                              EndIf
                    EndSelect
               EndIf
     EndSelect
     ProcedureReturn Result
EndProcedure
hLib = OpenLibrary(1,"SciLexer.dll")
hwnd = OpenWindow(0,0,0,600,400,#PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible,"Scintilla")
SetWindowCallback(@WindowCallback())
If hLib
     hInstance = GetModuleHandle_(0)
     hScintilla = CreateWindowEx_(0, "Scintilla"," ", #WS_CHILD|#WS_VISIBLE|#WS_TABSTOP,10,10,580,380,hwnd,0,hInstance,0)
Else
     MessageRequester( "Erreur Scintilla", "La DLL n'est pas chargé.", #MB_OK | #MB_ICONERROR)
     End
EndIf
;Brosse = CreateSolidBrush_(RGB(55, 82, 55))
;SetClassLong_(WindowID(0), #GCL_HBRBackGround, Brosse)
; SendMessage_(hScintilla,#SCI_STYLESETFONT,#STYLE_DEFAULT,"Verdana"); police par défaut
; SendMessage_(hScintilla,#SCI_STYLESETSIZE,#STYLE_DEFAULT,12) ;taille par défaut
; SendMessage_(hScintilla,#SCI_STYLESETFORE,#STYLE_DEFAULT,RGB(250,250,250)) ; couleur de la police
; SendMessage_(hScintilla,#SCI_STYLESETBACK,#STYLE_DEFAULT,RGB(40,40,80)) ; couleur du fond
 SendMessage_(hScintilla,#SCI_STYLECLEARALL,0,0);
 SendMessage_(hScintilla,#SCI_STYLESETFORE,1,RGB(0,250,0)); définti une liste de couleur comme en rtf
 SendMessage_(hScintilla,#SCI_STYLESETFORE,2,RGB(0,250,250));
 SendMessage_(hScintilla,#SCI_STYLESETFORE,3,RGB(250,250,0));
 SendMessage_(hScintilla,#SCI_STYLESETFORE,4,RGB(250,100,0));
 SendMessage_(hScintilla,#SCI_STYLESETBACK,#STYLE_LINENUMBER,RGB(80,80,160)) ; fond
 SendMessage_(hScintilla,#SCI_STYLESETFORE,#STYLE_LINENUMBER,RGB(250,250,250)); écriture
 SendMessage_(hScintilla,#SCI_SETMARGINWIDTHN,0,30);  Affiche les numero des lignes
 SendMessage_(hScintilla,#SCI_SETSELBACK,#True,RGB(0,100,150)); Détermine la couleur de fond de la sélection
 SendMessage_(hScintilla,#SCI_SETSELFORE,#False,0); La couleur du texte sélectionné est inchangée
 SendMessage_(hScintilla,#SCI_SETCARETFORE,RGB(250,200,100),0); Couleur du curseur
 SendMessage_(hScintilla,#SCI_SETCARETWIDTH,2,0); Largeur du curseur
 SendMessage_(hScintilla,#SCI_SETINDENTATIONGUIDES,#True,0) ; Affiche le guide d'indentation
 SendMessage_(hScintilla,#SCI_SETINDENT,8,0) ; Détermine la longueur de la tabulation
Texte$ = "Ouvre le PLIAGE pour voir ma REPONSE..."+Chr(13)
Texte$ + "Je ne vois pas en quoi s'est"+Chr(13)
Texte$ + "une blague ?"+Chr(13)
Texte$ + "Si c'est une ruse pour obtenir du code,"+Chr(13)
Texte$ + "elle est de mauvais goût..."+Chr(13)
Texte$ + "Forcer quelqu'un à te donner son code en l'agressant,"+Chr(13)
Texte$ + "ce n'est pas bien... et te fera du tort..."+Chr(13)
Texte$ + "Fin de la REPONSE"
SendMessage_(hScintilla,#SCI_INSERTTEXT,-1,Texte$) ; insère le texte à la fin !
  For t=1 To 6
       SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,t,8) ; indente  le texte de 8 espaces
  Next
 ;SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,2,16)
 ;SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,4,16)
 ;SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,6,16)
 
  SendMessage_(hScintilla,#SCI_STARTSTYLING,9,$FF);x=début de la coloration y=??
  SendMessage_(hScintilla,#SCI_SETSTYLING,8,1) ;x=nombre de caractère y : numéro de couleur dans le dico
  SendMessage_(hScintilla,#SCI_STARTSTYLING,29,$FF)
  SendMessage_(hScintilla,#SCI_SETSTYLING,7,2)
  SendMessage_(hScintilla,#SCI_STARTSTYLING,40,$FF)
  SendMessage_(hScintilla,#SCI_SETSTYLING,213,4)
  SendMessage_(hScintilla,#SCI_STARTSTYLING,266,$FF)
  SendMessage_(hScintilla,#SCI_SETSTYLING,7,4)
 
 SendMessage_(hScintilla,#SCI_SETMARGINSENSITIVEN,1,#True); active le folding
 SendMessage_(hScintilla,#SCI_SETMARGINMASKN,1,~#SC_MASK_FOLDERS);masque la couleur différente du folding
 SendMessage_(hScintilla,#SCI_MARKERDEFINE,0,#SC_MARK_ARROW) ; définit la fleche pour le droite (replié)
 SendMessage_(hScintilla,#SCI_MARKERDEFINE,1,#SC_MARK_ARROWDOWN) ; définti la fleche pour le bas (déplié)
 
 SendMessage_(hScintilla,#SCI_SETFOLDFLAGS,16,0)
 SendMessage_(hScintilla,#SCI_SETFOLDLEVEL,0,#SC_FOLDLEVELHEADERFLAG)
 SendMessage_(hScintilla,#SCI_MARKERADD,0,0) ; ajoute le petit triangle : y0 triangle pointé vers la gauche 1vers le bas
 SendMessage_(hScintilla,#SCI_HIDELINES,1,6); Cacher des lignes : ligne de départ, ombre de lignes
 SendMessage_(hScintilla,#SCI_SETFOLDEXPANDED,1,1); x ? y fait une ligne endessous du folder
  Debug SendMessage_(hScintilla,#SCI_GETLEXER,0,0)
HideWindow(0,0)
Repeat
     message = WaitWindowEvent()
     Select  message
          Case #PB_Event_CloseWindow
;               DeleteObject_(Brosse)
               End
     EndSelect
ForEver