New userlibs in B+ has stretched the life of it as well...
I needed CD burning support in one of my apps, so I made my own (Granted, it's not IMAPI, but it works well)
I know what you mean about simple(ish) things that could be made native... like printer support:-
//Printer DLL
//Written By Michael Denathorn 2005
//Sends text to the printer, also handle page breaks too
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
//Globals
PRINTDLG pd;
DOCINFO di;
ULONG_PTR gdiToken;
#define BBDECL extern "C" _declspec(dllexport)
#define BBCALL _stdcall
BBDECL int BBCALL _DabzOpenPrinter(void)
{
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&gdiToken, &gdiplusStartupInput, NULL);
ZeroMemory(&di, sizeof(di));
di.cbSize = sizeof(di);
di.lpszDocName = "Dabz Printer Lib";
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.Flags = PD_RETURNDC;
if(!PrintDlg(&pd))
{
printf("Failure\n");
return(0);
}
return(1);
}
BBDECL int BBCALL _DabzStartDoc(void)
{
StartDoc(pd.hDC, &di);
return(1);
}
BBDECL int BBCALL _DabzStartPage(void)
{
StartPage(pd.hDC);
return(1);
}
BBDECL int BBCALL _DabzEndPage(void)
{
EndPage(pd.hDC);
return(1);
}
BBDECL int BBCALL _DabzEndDoc(void)
{
EndDoc(pd.hDC);
return(1);
}
BBDECL int BBCALL _DabzClosePrinter(void)
{
if(pd.hDevMode)
GlobalFree(pd.hDevMode);
if(pd.hDevNames)
GlobalFree(pd.hDevNames);
if(pd.hDC)
DeleteDC(pd.hDC);
GdiplusShutdown(gdiToken);
return(1);
}
BBDECL int BBCALL _DabzPrintText( const char *str, int posX, int posY)
{
TextOut(pd.hDC,posX,posY,str,strlen(str));
return(1);
}
/*DECLS file
.lib "PrintDLL.dll"
OpenPrinter%():"__DabzOpenPrinter@0"
StartDoc%():"__DabzStartDoc@0"
StartPage%():"__DabzStartPage@0"
EndPage%():"__DabzEndPage@0"
EndDoc%():"__DabzEndDoc@0"
ClosePrinter%():"__DabzClosePrinter@0"
PrintText%(string$,xPos,yPos):"__DabzPrintText@12"*/
BlitzSource
;PrintDLL.DLL Example
;Written by Michael Denathorn 2005
;This example shows how you can use the DLL to print the contents
;of a Blitz+ Text Area
;Standard Blitz+ stuff
win = CreateWindow ("Print Text Area Example",20,20,230,280,Desktop(),5)
txtbox = CreateTextArea(10,15,200,200,win,1)
;Menu
menu = WindowMenu(win)
file=CreateMenu("File",0,menu)
CreateMenu "Print",1,file
CreateMenu "",0,file
CreateMenu "Quit",2,file
UpdateWindowMenu win
;Event Constants
Const CLOSE_WINDOW_EVENT = $803
Const MENU_EVENT = $1001
;Menu content ID's
Const PRINT_ID = 1
Const QUIT_ID = 2
Repeat
event = WaitEvent()
If event = CLOSE_WINDOW_EVENT
End
End If
If event=MENU_EVENT
menuID=EventData()
Select menuID
Case PRINT_ID
If TextAreaLen(txtbox) <> 0
PrintTextArea(txtbox)
Else
Notify "Erm... Type summit then!!! :/"
End If
Case QUIT_ID
End
End Select
End If
Forever
;---------------------------------------------------------------------------
;Note: The function only prints lines that are 90 characters in length, I'll
; fix this later, but for now, just bare it in mind!
;---------------------------------------------------------------------------
Function PrintTextArea(txtArea)
;Some local variables
Local LINES_PER_PAGE = 78
;Create a tempory new file in the users tempdir
;and save the text there first (There is a reason for this, see bottom of function))
file$ = SystemProperty$("tempdir")+"tempprint.txt"
fileout = WriteFile(file$)
WriteLine(fileout,TextAreaText(txtArea))
CloseFile fileout
;Open the file and the printer
filein = ReadFile(file$)
OpenPrinter()
;Tell the printer there is a new document on the way,
;and also notify the printer we are going to print on a
;new page
StartDoc()
StartPage()
;Reset line counter
lineCounter = 0
;Printing loop
Repeat
;Read in line of text from file, and then send to printer
PrintText(ReadLine$(filein),50,(lineCounter*50))
;Increment the line counter
lineCounter = lineCounter + 1
;If the printer reaches the bottom of the page
;reset the line counter, tell the printer to end the
;current page, and start a new one
If lineCounter = LINES_PER_PAGE
lineCounter = 0
EndPage()
StartPage()
End If
;Exit when we have reached the end of the file
Until Eof(filein)
;Instruct the printer to end the page, and then the document
EndPage()
EndDoc()
;Close the printer
ClosePrinter()
;Close the file and delete it
CloseFile filein
DeleteFile(file$)
End Function
;Writing the contents of a text area to file first, then reading in each line
;saves me from trying to format the text internally within the function.
;If I tried to print straight from the text area, I would end up with something
;from this:-
;
; Hello, my name is Michael
; and I like nothing better than
; sitting on by backside.
;
;
;To this (Which is what it would look like on the paper):-
;
; Hello, my name is Michaeland I like nothing better thansitting on by backside.
;
;As you can see, it's a bit @#!*ty, The reason this happens is that when
;Blitz+ reads in the line, it automatically chops the carriage return from the
;line... so, I don't really have to do much, apart from a couple of simple IO
;routines... Canny!!!
It took me a couple of days to learn how to do that, and I know it's not great... but it works!
I could easily incorporate images in there... but I don't need to yet.. so! But if BR sorted something as easy as that (And it would be a popular segment of the command set)and incorporated it into the language, I'd be happy!
Though, if I need anything, I'm just going to roll up my sleeves and make it myself... That will stop me getting lazy in my old age! :D
Dabz
*EDIT - How the hell do you make the boxes smaller! :/
*EDIT - Got it... F'ing codebox! :)