hidden hit counter
Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

About multipage Bitmap printer drive development

 
   Soft32 Home -> Windows -> Device Driver RSS
Next:  net use lpt1: in vista not working  
Author Message
vmthiru




Joined: Feb 28, 2008
Posts: 2



(Msg. 1) Posted: Thu Feb 28, 2008 7:27 pm
Post subject: About multipage Bitmap printer drive development

Cool hi, i am new one to driver programming, now i m trying to do Bitmap driver, based on WDK6000 sample Bitmap driver source.

now, i am modified the WDK6000 Bitmap drive source code(ddihook.cpp) like that:

BOOL APIENTRY OEMStartPage(SURFOBJ *pso)
{

OEMDBG(DBG_VERBOSE, L"SEND PageNo OEMEndDoc entry.");

PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev;
POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM;

//DWORD dwWritten;

INT cScans;
if (pOemPDEV->pBufStart)
{

// file creations
char buf[50];
wchar_t lpfile[50];

sprintf(buf,"C:\\BitmapPrntPages");
mbstowcs(lpfile,buf,50);
if(GetFileAttributes(lpfile)==0xFFFFFFFF)
{
::CreateDirectory(lpfile,NULL);
}
PageNo++;
sprintf(buf,"C:\\BitmapPrntPages\\page_%d.bmp",PageNo);
mbstowcs(lpfile,buf,50);
if(GetFileAttributes(lpfile)!=0xFFFFFFFF)
{
::DeleteFile(lpfile);
}
HANDLE hCfile =::CreateFile(lpfile,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
LPDWORD ByteWritten = new DWORD;

//end creation of file

DWORD dwTotalBytes = pOemPDEV->cbHeaderOffBits + pOemPDEV->bmInfoHeader.biSizeImage; // File size

pOemPDEV->bmFileHeader.bfType = 0x4d42; // Signature = 'BM'
pOemPDEV->bmFileHeader.bfSize = dwTotalBytes; // Bytes in whole file.
pOemPDEV->bmFileHeader.bfReserved1 = 0;
pOemPDEV->bmFileHeader.bfReserved2 = 0;
pOemPDEV->bmFileHeader.bfOffBits = pOemPDEV->cbHeaderOffBits; // Offset to bits in file.

if (pOemPDEV->bColorTable)
pOemPDEV->bmFileHeader.bfOffBits += pOemPDEV->cPalColors * sizeof(ULONG);

// Num of scanlines
//
cScans = pOemPDEV->bmInfoHeader.biHeight;

// Flip the biHeight member so that it denotes top-down bitmap
//
pOemPDEV->bmInfoHeader.biHeight = cScans * -1;


::WriteFile(hCfile,(void*)&(pOemPDEV->bmFileHeader),sizeof(BITMAPFILEHEADER),ByteWritten,NULL);
::WriteFile(hCfile,(void*)&(pOemPDEV->bmInfoHeader),sizeof(BITMAPINFOHEADER),ByteWritten,NULL);
if (pOemPDEV->bColorTable)
{
::WriteFile(hCfile,pOemPDEV->prgbq,pOemPDEV->cPalColors * sizeof(ULONG),ByteWritten,NULL);
}
//// Dump the data now

::WriteFile(hCfile,pOemPDEV->pBufStart,pOemPDEV->bmInfoHeader.biSizeImage,ByteWritten,NULL);

DWORD o1 = GetLastError();
CloseHandle(hCfile);
if(o1 != 0)
{
::MessageBox(NULL,L"OEMStartPage",L"WriteFile error",MB_OK);
}

vFreeBuffer(pOemPDEV);
pOemPDEV->bmInfoHeader.biHeight -= pOemPDEV->bmInfoHeader.biHeight;
pOemPDEV->bmInfoHeader.biSizeImage -= pOemPDEV->bmInfoHeader.biSizeImage;

return (pOemPDEV->m_pfnDrvStartPage)(pso);

}

Question
Is it ok?

These code gives out multiple bitmap files, but my doubts over to make unique file name. so please explain me , where? or how? to get the file name

otherwise, how to get the file name from user?

-> Smile sorry for my Eng.
Back to top
Login to vote
soft32reviewer




Joined: Dec 19, 2007
Posts: 62



(Msg. 2) Posted: Tue Mar 04, 2008 3:27 am
Post subject: Re: About multipage Bitmap printer drive development [Login to view extended thread Info.]

From what i see, you use PageNo without initializing it...
Back to top
Login to vote
vmthiru




Joined: Feb 28, 2008
Posts: 2



(Msg. 3) Posted: Tue Mar 04, 2008 5:25 am
Post subject: pageNo initialized globaly [Login to view extended thread Info.]

thx,
i just want to know WINDOWS file save dialog window;
if used below code, it gives some error ....

/****

OPENFILENAME ofn; // common dialog box structure
char szFile[260]; // buffer for file name
HWND hwnd; // owner window
HANDLE hf; // file handle

// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFile =(LPWSTR)szFile;
//
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
//
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = L"*.bmp";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

// Display the Open dialog box.

if (GetSaveFileName(&ofn)==FALSE)
{
// cont
}

error:
====

c:\winddk\6000\inc\api\commdlg.h (891): error C2062: type 'void' unexpected
c:\winddk\6000\inc\api\commdlg.h (923): error C2062: type 'void' unexpected

- - -etc

explain me , what was the problem?. bcz this Open dialog box source code is executed Visual studio2005 environment; but such a same code gives out some error WDK environment

Question srry my eng->
Back to top
Login to vote
Display posts from previous:   
       Soft32 Home -> Windows -> Device Driver All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
  Windows
 Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]