 |
|
 |
Hi..
Can anyone tell me how to use EnumPrinters In MFC appliaction.. I need to get the names of all the installed printers .. In Win32 Application EnumPrinters Api works fine but m facing some problem in MFC aplication.. It says EnumPrinters identifier not found even after adding its respective .h file i.e.(windows.h)..
can anyone help me out..??
thanks,
vinay
|
|
|
|
 |
|
 |
I need watch job on printer.
For example name of document printing.
Do you have a sample to get this.
Thank very much
|
|
|
|
 |
|
 |
Thanks for the write up and the code. I have a challenge: I can't control the source code for the application. I want to set this application so that it will print to a "virtual printer" I installed in Windows. The virtual printer is something my company co-develops.
Scenario:
- My printer X is my Windows default printer
- My printer Y is my weird dot matrix printer I use only with one application
- I want my one application to use only the Y printer, to make it easier for computer illiterates to just "print", and they do so with the right printer.
What do you recommend?
- Are there any utilities that can start with my one program to force it to use only this printer (the non-default dot matrix printer)?
- Can a utility be created to run and scan for a windows print event coming from the one program?
- Are there any .INI modifications I could use?
- Are there any other tweaks I can make in Windows?
Your help is much appreciated. I Googled for 3 hours yesterday and couldn't find what I was looking for. I am not an expert in printing technology.
Run to the hills!
|
|
|
|
 |
|
 |
Very Nice!!!
It's always nice to have a nice example in an area of windows programming that can be tricky, and is "not well" covered by most documentation/books.
Warren
|
|
|
|
 |
|
 |
The MSDN says "The framework calls OnSettingChange for all top-level windows when the Win32 SystemParametersInfo function changes a system-wide setting."
It is important in the context of this small project to note that this also happens when the user add/removes printers in the control panel.
You need to include this handler in your view
BEGIN_MESSAGE_MAP(CAOMView, CFormView)
...
ON_WM_SETTINGCHANGE() // printers might have changed
...
END_MESSAGE_MAP()
void CMyView::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
{
__super::OnSettingChange(uFlags, lpszSection);
// printers might have changed
if (lstrcmpi(lpszSection, _T("devices")) == 0)
theApp.m_PrinterControl.ReadLocalPrinters();
}
However you need to fix ReadLocalPrinters() to be able to be called more than once.
Does anyone know more about this window message and its implication for the EnumPrinters thingy ?
|
|
|
|
 |
|
|
 |
|
 |
Can this EnumPrinters be used in an application where the Document/View Framework is not used? I'm trying to set this up be I'm having a hard time. the variables _hDevMode & m_hDevNames are considered to be undeclared identifiers by the compiler. I am using the Printer function found on this webpage by Roger Allen to Print without the document/view framework. Where can i call the SetNewPrinter function from so that this works?
|
|
|
|
 |
|
 |
I have two printers. The default printer is HP 3600 and
I also use a PDF995 driver.
I execute the Printer Settings demo program that you posted
and the printername shown in the printer 1 and printer 2
boxes is HP 3600 Series. I click on choose and I select
the PDF driver. In the Status box, it says
printer 1 PDF995
I click on that and then click on the Set Global Printer
button and it says
Global settings for printer1 changed!
I exit the program and go back in and the printername
shown in the printer 1 and printer 2 boxes is still
HP 3600 series. If I select the PDF995 driver again for
printer 1, click Set Global Printer and then go to a
different program, any program, and try to print something
it still wants to print through the HP 3600 printer.
Changing the printer was temporary and only through
this one-program.
How can I change the default printer that all programs
on that particular computer utilize? Is it possible?
Please, any response you can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
 |
|
 |
Please can someone help. I am trying to set a printer in the background using the
command AfxGetApp()->SelectPrinter(hDevNames, hDevMode, TRUE). I am pulling hDevName and hDevMode from the system in the usual way. My problem is that a lot of my printers usual defaults are being ignored. If, however, I go through a print dialog and just hit OK, everything is fine. I am missing something obvious but I am not sure what. Thanks.
|
|
|
|
 |
|
 |
How exactly do i call SetPrintOrientaion? I want to change my printer's default orientation to Landscape, but i'm not sure what to use for the HANDLE hDevMode? I think it has something to do with selecting and telling the SetPrintOrientation funcion which printer to change. Can someone please give me hand in setting this up?
|
|
|
|
 |
|
 |
The hDevMode handle is a member variable of CWinApp which is initialised during the construction of the CWinApp object. In later versions of MFC you have to call UpdatePrinterSelection(TRUE); in your InitInstance() to make sure the printer is initialised correctly.
So you could do:
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
UpdatePrinterSelection(TRUE);
m_PrinterControl.SetPrinterOrientation(m_hDevMode, DMORIENT_LANDSCAPE);
If you set the code up like in the example application.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
 |
|
 |
Thanks that works great, but can I use this in a Dialog Based Application, and if so, what changes do I need to make to get it running?
|
|
|
|
 |
|
 |
Please, can someone who know if it is possible answer? Roger Allen?
/Felix
|
|
|
|
 |
|
 |
Just what I needed! It's really a plug & play class.
include it, compile, and it works.
Just had to add some NULL handle checks.
Keep up your good articles about printing
|
|
|
|
 |
|
 |
Thanks for sharing this code ! This worked out just fine !
|
|
|
|
 |
|
 |
Hi, Roger Allen,
You have done a great simple code. I have tried many MFC books, but no one tell any useful info about printing.
Thanks Roger Allen.
John
Later
|
|
|
|
 |
|
 |
Very nice,This is what I want.
---------------------
http://www.aooa.net
http://thexstudio.yeah.net
|
|
|
|
 |
|
 |
hi
I want to get the maximum size of paper(millimeter) that my printer suport it.I used "DeviceCapabilities" by "DC_MAXEXTENT" value ,but I did not successful. !!!
please help me and send to me ur code by this address : p_kh807@yahoo.com
thank u
P-KH
|
|
|
|
 |
|
 |
I was wondering if we have to support UNICODE strings for DEVNAMES structure?
eran
|
|
|
|
 |
|
 |
b>why can't it setting pagesize?<</b>
=SigSize
|
|
|
|
 |
|
 |
I made simple program for geting information about printing jobs. It is work fine on all programs but not on Microsoft Word 2000 (or MS WORD 2002) when I select option "Copies" and put more then "1".
How can I solve this?
If there is no normal way maybe you now how to DISABLE option for printion multiple copies since it gives me faulty results.
|
|
|
|
 |
|
 |
Hi.
That I need to know how to make a program that receives all requests of impression of several machines in network and administers these like for example whichever leaves imprimio, etc. Thanks.
|
|
|
|
 |
|
 |
Someone posted a question about how to identify the currently selected printer, but the message seems to have disappeared. Anyway, I developed this additional function for the CEnumPrinters class:
int IdentifyCurrentPrinter(HANDLE &hDevMode, HANDLE& hDevNames) const ;
int CEnumPrinters::IdentifyCurrentPrinter(HANDLE &hDevMode, HANDLE& hDevNames) const
{
if (hDevNames == NULL || hDevNames == INVALID_HANDLE_VALUE)
{
if (hDevMode != NULL && hDevMode != INVALID_HANDLE_VALUE)
{
ASSERT(::GlobalFlags(hDevMode) != GMEM_INVALID_HANDLE);
UINT nCount = ::GlobalFlags(hDevMode) & GMEM_LOCKCOUNT;
while (nCount--)
::GlobalUnlock(hDevMode);
::GlobalFree(hDevMode);
hDevMode = INVALID_HANDLE_VALUE ;
}
CPrintDialog pd(TRUE);
pd.GetDefaults();
hDevMode = pd.m_pd.hDevMode;
hDevNames = pd.m_pd.hDevNames;
}
LPDEVNAMES lpDevNames = (LPDEVNAMES)::GlobalLock(hDevNames) ; CString name((char*)((char*)lpDevNames + lpDevNames->wDeviceOffset)) ;
GlobalUnlock(hDevNames);
for (int i = 0 ; i < GetPrinterCount() ; i++)
{
if (name == GetPrinterName(i))
return i ; }
return -1 ; }
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
 |
|
 |
Good Article, with one possible enhancement...
I may have missed something, but this appears to work only with local printers.
How can it be modified to allow networked printers?
Paresh Solanki
There is no substitute for genuine lack of preparation.
|
|
|
|
 |
|
 |
Damn, just read it under future enhancements
Paresh Solanki
There is no substitute for genuine lack of preparation.
|
|
|
|
 |