|
|
Like the title says, I want to add some printing functions to my code, a NON-MFC windows app, without having a printer installed on my system. Oh what a crazy world we live in.
Is there some way to fool my PC into thinking there is a printer installed? Every time I try to call one of the Common Dialog print routines I am faced with a "Please install a printer you cheap artist" message.
Hey I do all my printing at work, what do I wanna go and spend a few hundred bucks on a printer I will never use for?
|
|
|
|
|
Pdf995 Printer Driver
It works like a printer, only it sends output to a .pdf file. It has an annoying ad in it though - there's another free pdf writer available without ads, but I can't remember the name of it. (cutepdf?)
"My dog worries about the economy. Alpo is up to 99 cents a can. That's almost seven dollars in dog money" - Wacky humour found in a business magazine
|
|
|
|
|
Thanks for the tip, I never thought of using a print to pdf driver.
Having a little trouble with the pdf995 website, but I am downloading the cutepdf alternative you mentioned.
|
|
|
|
|
You can install a printer without actually having the printer. I've done it lots of times. Just tell it to print to a file instead of a port.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I tried to create a process(notepad.exe) using the CreateProcess method. But the method failes throwing a Exception.
Could any one please tell why this following code snippet is failing.
PROCESS_INFORMATION pProcessInfo;
BOOL bStatus = CreateProcess("C:\\WINDOWS\\Notepad.exe",NULL,NULL,NULL,NULL,CREATE_NEW_CONSOLE,NULL,NULL,NULL,&pProcessInfo);
Regards
|
|
|
|
|
PROCESS_INFORMATION pProcessInfo;
STARTUPINFO si= {0};
si.cb = sizeof(STARTUPINFO);
BOOL bStatus = CreateProcess("c:\\WINDOWS\\Notepad.exe",NULL,NULL,NULL,NULL,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pProcessInfo);
|
|
|
|
|
WhiteSky wrote:
("c:\\WINDOWS\\Notepad.exe",NULL,NULL,NULL,NULL,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pProcessInfo);
The Windows directory should not be hard coded.
|
|
|
|
|
|
Hi Subramaniam,
I don't know what's wrong with your code but I did it like this:
<br />
STARTUPINFO si;<br />
PROCESS_INFORMATION pi;<br />
<br />
CreateProcess( NULL,
TEXT("C:\\Windows\\system32\\notepad.exe"),
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi );
It works on my computer.
Best regards,
Chris
|
|
|
|
|
When you do get it to work remember no to leak HANDLE s. After the CreateProcess call you need to close some HANDLES it returns if you don't plan on using them:
PROCESS_INFORMATION pi;
BOOL bOK = CreateProcess(..., &pi);
if (bOK)
{
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
Not closing these handles is a common mistake people calling CreateProcess make.
Also you use the wart "p" on the variable "pProcessInfo" - This is normally used for pointers. You'll confuse people using it on a variable that isn't a pointer.
Steve
|
|
|
|
|
Hi Steve,
I even didn't think about this at all!
Thanks!!
Chris
|
|
|
|
|
Hi All,
First of all many thanks to all who have given their valuable suggestion. I am not getting the Exception now but I get an Access Violation error like this in my output window and my notepad doesnt launch.
ChristopherAtCodeProject wrote: First-chance exception in Threading Sample.exe (NTDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in Threading Sample.exe (NTDLL.DLL): 0xC0000005: Access Violation.
Any help on this please. Do I need to give some security descriptors or something. To the best of my knowledge its not required I suppose as even if we pass NULL to them it will consider the default Security.
Many Thanks
|
|
|
|
|
Hi All,
Its working fine now. I had to fill in the STARTUPINFO struture.
Thanks
|
|
|
|
|
hi all
i want to image processing.i want to load image to the picturebox and then extract the values from it. i m loading image on the picturebox through the code loadimage and variable of picbox.setbitmap.
After loading this image i want to perfrom data extraction i mean read RGB values.what is fastest method of it
either use the device context and and perform the data extraction or use the cimage atl class for this purpose.
ddd+
|
|
|
|
|
Hmm the fastest way to load files into memory that I know if is by using memory mapped files. Map the entire file into your process address space. I assume that you are using a bitmap file format?? You could do something like this:
HANDLE hFile;
HANDLE hFileMappingObject;
BYTE * lpBaseAddress;
BITMAPFILEHEADER * lpBitmapFileHeader;
BITMAPINFOHEADER * lpBitmapInfoHeader;
RGBQUAD * lpRGBQuad;
BYTE * lpColorIndexArray;
if(OpenDialog1->Execute())
{
hFile=CreateFile(OpenDialog1->FileName.c_str(),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile==INVALID_HANDLE_VALUE)
{
MessageBox(Handle,"Could not open file","Error",MB_OK|MB_ICONERROR);
return;
}
hFileMappingObject=CreateFileMapping(hFile,NULL,PAGE_READWRITE|SEC_COMMIT,0,0,NULL);
if(hFileMappingObject==NULL)
{
MessageBox(Handle,"Could not create file mapping object","Error",MB_OK|MB_ICONERROR);
CloseHandle(hFile);
return;
}
lpBaseAddress=(BYTE*)MapViewOfFile(hFileMappingObject,FILE_MAP_WRITE,0,0,0);
if(lpBaseAddress==NULL)
{
MessageBox(Handle,"Could not map view of file","Error",MB_OK|MB_ICONERROR);
CloseHandle(hFileMappingObject);
CloseHandle(hFile);
return;
}
lpBitmapFileHeader=(BITMAPFILEHEADER*)&lpBaseAddress[0];
lpBitmapInfoHeader=(BITMAPINFOHEADER*)&lpBaseAddress[sizeof(BITMAPFILEHEADER)];
lpRGBQuad=(RGBQUAD*)&lpBaseAddress[sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)];
lpColorIndexArray=&lpBaseAddress[lpBitmapFileHeader->bfOffBits];
//Use lpColorIndexArray to acces your RGB values
UnmapViewOfFile(lpBaseAddress);
CloseHandle(hFileMappingObject);
CloseHandle(hFile);
}
|
|
|
|
|
I am writing a dialog based MFC prog.
I dont want the "close" button in title bar of that dialog. But I want the icon in the title bar. Thats why I cannot disable the entire title bar or sys menu. Is there any procedure so that i can disable the close button, but icon is still there in the title bar?
|
|
|
|
|
Look here[^]
Nibu thomas
Software Developer
|
|
|
|
|
If your dialog have only the close button add this to OnInitDialog just before return..
<br />
((CMenu*)GetSystemMenu(FALSE))->DeleteMenu(1, 1024);<br />
|
|
|
|
|
Hi
I am working with excel automation. I need to write an excel file from VC++. The format of the excel file should be
Events Table
Date&Time,Source,Cause,Description,Fault - 3rd row
Mar 13 2006 12:25:05.000078,HMI,H-0001,Startup,N
Mar 13 2006 12:25:05.000187,HMI,H-0005,Caution,Y
ect...
Footer
I used excel automation as shown below.
CoInitialize(NULL);
try
{
Excel::_ApplicationPtr excel;
// Initialize Excel and make sure it's initialized
HRESULT hr = excel.CreateInstance(L"Excel.Application");
Excel::_WorkbookPtr workbook = excel->Workbooks->Add(static_cast<long> (Excel::xlWorksheet));
Excel::_WorksheetPtr worksheet = excel->ActiveSheet;
worksheet->Range["A1"]->Value = "Header1";
worksheet->Range["A2"]->Value = "Header2";
worksheet->SaveAs("c:\\test1.xls"); // Save it
workbook->Close(); // Close the workbook
excel->Quit(); // Quit excel
}
catch(_com_error &ce)
{
AfxMessageBox("Error");
}
CoUninitialize();
Now the problem is, since I don't have the number of cells varry , I want to run a ForLoop where I can input the values in the Range function as shown here.....worksheet->Range["A1"]->Value = "Header1";
I am facing some problems when I try to give the values here as
char* str = new char(3);
str = "B3";
worksheet->Range[str]->Value = "Header1";
Can anyone please help me with some sample code for doing this?
Thanks
Madhavi..
|
|
|
|
|
What exacty are the problems you are getting?
I have excel up and running in my current project, but I used a slightly different method. I created a DLL coded in Visual Basic and included it into my project.
As for your problem, instead of inserting the value using the range method, why not try the cell method instead?
worksheet->Cell[inty,intX]->Value = "Header";
|
|
|
|
|
What does the below line mean?
CCheckPoint():m_cRef(0), m_pConnection(NULL){}
where
CCheckPoint is a class,
m_cRef is ULONG,
m_pConnection is IConnectionPoint*
Can anyone help me in understanding what the bove code means?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
it is the default constructor of the class CCheckPoint , which invokes in its initializer list the copy constructors for the members m_cRef and m_pConnection .
it is quite equivalent to this (but not equal though) :
CCheckPoint() {
this->m_cRef = ULONG(0);
this->m_pConnection = (IConnection*)NULL;
}
the constructors initializer list is particularly mandatory when initializing constant data members which cannot be assigned in the constructor body.
it is also useful when a class inherits from a base class. the base class members must be initialized before the members of the child. the initialization list can so be used to call the base class constructor :
class A {
int m_i;
public:
A(void) : m_i(0) { }
A(const A& a) : m_i(a.m_i) { }
A(int i) : m_i(i) { }
};
class B : public A {
public:
B() : A() { }
B(const B& b) : A(b) { }
};
|
|
|
|
|
Thanks...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
|