Under New Management
0 Members and 3 Guests are viewing this topic.
The only thing I found in the windows sdk about numbering in the rich edit control had to do with paragraph numbering and not line numbering.I know that I and others who come from the IB STD/IB PRO background now use IWBasic and use the scintilla editor dll to create child windows with line numbering, keyword highlighting, and the likes.
Sub CreateGreenBars int i, iLines, iFirstChar, iLastChar iLines = SendMessage(hSci, %SCI_GetLineCount, 0, 0) For i = 0 to iLines - 1 iFirstChar = SendMessage(hSci, %SCI_PositionFromLine, i, 0) iLastChar = SendMessage(hSci, %SCI_GetLineEndPosition, i, 0) Select Case i % 6 Case 0 Case& 1 Case& 2 SendMessage(hSci, %SCI_StartStyling, iFirstChar, 31) SendMessage(hSci, %SCI_SetStyling, iLastChar-iFirstChar+2, %Style_Gray) Case 3 Case& 4 Case& 5 SendMessage(hSci, %SCI_StartStyling, iFirstChar,31) SendMessage(hSci, %SCI_SetStyling, iLastChar-iFirstChar+2, %Style_Default) EndSelect Next iEndSub
'a simple SDI editor (like notepad)'using a multiline richedit control sized to the windowdef win:windowdef left,top,width,height,hprinter:intdef startpg,endpg,copies,collate:intdef filename,ln,printer:stringdef file1:FILEdef buffer[32766]:ISTRINGConst EC_LEFTMARGIN = 0x1Const EM_SETMARGINS = 0xD3run = 0'Open our main window, get its client size and create the controlwindow win,0,0,640,400,@SIZE|@MINBOX|@MAXBOX|@MAXIMIZED,0,"EDITOR V1.1",mainwindowgetclientsize win,left,top,width,heightCONTROL win,"RE,,left,top,width,height,@CTEDITMULTI|@HSCROLL|@VSCROLL,1"SETFONT win,"Courier New",10,400,0,1 SendMessage win, EM_SETMARGINS,EC_LEFTMARGIN,80,1menu win,"T,&File,0,0","I,&Load,0,1","I,&Save,0,2","I,&Print,0,4","I,&Quit,0,3"insertmenu win,1,"T,&Options,0,0","I,Change Font,0,5"SETCONTROLCOLOR win,1,0,RGB(255,255,255)'process messages until somebody closes usrun = 1waituntil run=0closewindow winend'this is the handler subroutine for the window'process @IDSIZE to size the edit control'process the menus'process @IDCLOSEWINDOW to quit the programsub mainwindowselect @CLASS case @IDCLOSEWINDOW run = 0 case @IDSIZE 'size the edit control to match the client size of the window 'we use CONTROLEXISTS to verify the existance of the edit control 'because the first @IDSIZE message is sent while the window is being created 'but before we have a chance to add the edit control. if CONTROLEXISTS(win,1) getclientsize win,left,top,width,height setsize win,left,top,width,height,1 endif case @IDMENUPICK select @MENUNUM case 5 GOSUB changefont case 4 'dump the edit control to the printer GOSUB doprint case 3 'quit the program run = 0 case 2 'save the file GOSUB dosave case 1 'open a file GOSUB doopen endselectendselectreturn'------------- DOOPEN ----------------SUB doopen filename = filerequest("Load File",win,1) if(len(filename) > 0) buffer = "" if( openfile(file1,filename,"R") = 0) do if(read(file1,ln) = 0) if(len(ln) <> 0) buffer = buffer + ln + chr$(13) + chr$(10) endif endif until eof(file1) closefile file1 setcontroltext win,1,buffer endif endifRETURN'------------- DOSAVE -----------------SUB dosave filename = filerequest("Save File",win,0) if(len(filename) > 0) if(openfile(file1,filename,"W") = 0) buffer = getcontroltext(win,1) REM EDIT controls insert extra carriage returns at in every line REM so remove them before saving GOSUB RemoveCR write file1,buffer closefile file1 endif endifRETURN'------------- DOPRINT ----------------SUB doprint startpg = 1 endpg = 1 copies = 1 collate = 1 printer = PRTDIALOG(win,startpg,endpg,copies,collate) hprinter = OPENPRINTER(printer,"Document","TEXT") if(hprinter) buffer = getcontroltext(win,1) WRITEPRINTER hprinter, buffer CLOSEPRINTER hprinter endif RETURN'------------- CHANGEFONT -------------SUB changefontDEF size,weight,flags,col:intDEF fontname:string fontname = FONTREQUEST(win,size,weight,flags,col) if(fontname <> "") SETFONT win,fontname,size,weight,flags,1 endif SETCONTROLCOLOR win,1,col,RGB(255,255,255)RETURN'------------- REMOVECR ----------------SUB RemoveCRdef pos:INTdef buffer2[32766]:ISTRING pos = INSTR(buffer,CHR$(13)) while(pos) if(mid$(buffer,pos,1) = CHR$(13)) buffer2 = left$(buffer,pos-1) buffer2 = buffer2 + mid$(buffer,pos+1) buffer = buffer2 endif pos = INSTR(pos+1,buffer,chr$(13)) endwhilereturn
DECLARE "user32",GetDlgItem(hwnd:INT,id:INT),INTCONST WM_COMMAND = &H111CONST EN_UPDATE = &H400def myrichedit:intdef mywin:windowwindow mywin.......................,handlercontrol mywin,".....,myrichedit" handler:select @CLASS case @IDCLOSEWINDOW case @IDCONTROL '<---- WM_COMMAND select @CONTROLID case myrichedit if @CODE/&hFFFF = EN_UPDATE int hRichEdit=GetDlgItem(mywin.hwnd,myrichedit) int hdc = GetDC( hRichEdit ) makeLineNumber( hRichEdit, hdc ) ReleaseDC( hRichEdit, hdc ) endif endselectendselectreturnsub makeLineNumber(int hr,int hd) blah blahreturn
To link to us use this code/button on your site