$include "windowssdk.inc" window win Uint fCol,bCol OPENWINDOW win,0,0,200,400,@CAPTION,0,"Vignette",&main CONTROL win,@BUTTON,"Set Top",0,0,200,22,0x50000000,1 CONTROL win,@BUTTON,"Set Bottom",0,350,200,22,0x50000000,2 fCol=RGB(255,0,0) bCol=RGB(0,0,255) Vignette(win,0,0,200,400,fCol,bCol) CheckPrinter() WaitUntil IsWindowClosed(win) end Sub main(),INT SELECT @MESSAGE CASE @IDCREATE CenterWindow win CASE @IDCLOSEWINDOW CLOSEWINDOW win CASE @IDCONTROL SELECT @CONTROLID case 1 fCol=ColorRequest(win) case 2 bCol=ColorRequest(win) EndSelect Vignette(win,0,0,200,400,fCol,bCol) ENDSELECT RETURN 0 EndSub Sub Vignette(wn as Window,x as int,y as int,w as int,h as int,fc as Uint,bc as UInt) 'linear vignette from top to bottom, fc to bc float col[3],sCol[3] int i,j 'Split the RGBColour into its components col[0]=fc%256 'Red col[1]=(fc%65536)/256 'Green col[2]=fc/65536 'Blue 'Work out the difference between the forecolour and the backcolour sCol[0]=((bc%256)-col[0])/h 'Red sCol[1]=(((bc%65536)/256)-col[1])/h 'Green sCol[2]=((bc/65536)-col[2])/h 'Blue 'Do the vignette for i=0 to h Line wn,x,y+i,x+w,y+i,RGB(int(col[0]),int(col[1]),int(col[2])) 'Adjust the base colour for j=0 to 2 col[j]+=sCol[j] next j next i EndSub SUB CheckPrinter() PRINTER_INFO_2 pi2 INT result,need=0,pEnum,I MEMORY pBuffer STRING prtName prtName=GETDEFAULTPRINTER IF LEN(prtName)=0 MESSAGEBOX(0,"There is no default printer installed","Printer error",0x0|0x30) ELSE ' If need = 0, then the API returns the number of bytes needed EnumPrintersA(2,"",2,pBuffer,need,need,pEnum) ' Now allocate a memory buffer for the table to be returned ALLOCMEM pBuffer,1,need result=EnumPrintersA(2,"",2,pBuffer,need,need,pEnum) ' pEnum contains the number of udt's FOR I=1 TO pEnum ' copy from table to local udt READMEM pBuffer,I,pi2 if prtName=pi2.#pPrinterName IF (pi2.Attributes=1600) OR (pi2.Attributes=3648) MESSAGEBOX(0,pi2.#pPrinterName+" does not appear to be switched on",pi2.#pPrinterName,0x0|0x30) endif ENDIF NEXT I FREEMEM pBuffer ENDIF ENDSUB