Click here to Skip to main content
15,917,641 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestioniContextMenu on x64, inside CFileDialog Pin
Chris Losinger11-Aug-09 8:57
professionalChris Losinger11-Aug-09 8:57 
GeneralRe: iContextMenu on x64, inside CFileDialog Pin
Randor 11-Aug-09 11:05
professional Randor 11-Aug-09 11:05 
GeneralRe: iContextMenu on x64, inside CFileDialog Pin
Chris Losinger11-Aug-09 11:21
professionalChris Losinger11-Aug-09 11:21 
GeneralRe: iContextMenu on x64, inside CFileDialog Pin
harold aptroot11-Aug-09 11:21
harold aptroot11-Aug-09 11:21 
Questioncompile error on this open printer statement Pin
Robert V. Klein11-Aug-09 8:06
Robert V. Klein11-Aug-09 8:06 
AnswerRe: compile error on this open printer statement Pin
Cedric Moonen11-Aug-09 8:19
Cedric Moonen11-Aug-09 8:19 
GeneralRe: compile error on this open printer statement Pin
Robert V. Klein11-Aug-09 8:35
Robert V. Klein11-Aug-09 8:35 
AnswerRe: compile error on this open printer statement [modified] Pin
Randor 11-Aug-09 10:32
professional Randor 11-Aug-09 10:32 
The OpenPrinter Function[^] expects the second argument to be a HANDLE not an HDC.

Here is an example of using OpenPrinter to open the default printer using the GetDefaultPrinter Function[^]

#include <Winspool.h>
HANDLE OpenDefaultPrinter(ACCESS_MASK dwMask)
{
	HANDLE hPrinter = INVALID_HANDLE_VALUE;
	PRINTER_DEFAULTS pDef = {0};
	DWORD dwSize;

	GetDefaultPrinter(NULL, &dwSize);
	TCHAR* szBuffer = (TCHAR *)alloca(sizeof(TCHAR) * dwSize);

	if(NULL != szBuffer)
	{
		if(GetDefaultPrinter(szBuffer, &dwSize))
		{
			pDef.DesiredAccess = dwMask;
			OpenPrinter(szBuffer, &hPrinter, &pDef);
		}
	}
	return hPrinter;
}

//Usage:
OpenDefaultPrinter(PRINTER_ALL_ACCESS);


Best Wishes,
-David Delaune

[UPDATE]
You should remove my call to alloca and use heap-based memory allocation with the new/delete operators. My personal projects usually have structured exception handler for stack overflows and I inadvertently used alloca in this comment.


modified on Tuesday, August 11, 2009 4:46 PM

QuestionRead 1000 Lines from text file in a single shot ........ Pin
spalanivel11-Aug-09 6:51
spalanivel11-Aug-09 6:51 
AnswerRe: Read 1000 Lines from text file in a single shot ........ Pin
Stuart Dootson11-Aug-09 7:31
professionalStuart Dootson11-Aug-09 7:31 
AnswerRe: Read 1000 Lines from text file in a single shot ........ Pin
David Crow11-Aug-09 8:56
David Crow11-Aug-09 8:56 
QuestionHow to set a PDF fields? Pin
Hadi Dayvary11-Aug-09 6:21
professionalHadi Dayvary11-Aug-09 6:21 
AnswerRe: How to set a PDF fields? Pin
Bacon Ultimate Cheeseburger11-Aug-09 14:08
Bacon Ultimate Cheeseburger11-Aug-09 14:08 
GeneralRe: How to set a PDF fields? Pin
Hadi Dayvary11-Aug-09 20:13
professionalHadi Dayvary11-Aug-09 20:13 
GeneralRe: How to set a PDF fields? Pin
Hadi Dayvary11-Aug-09 20:14
professionalHadi Dayvary11-Aug-09 20:14 
GeneralRe: How to set a PDF fields? Pin
Bacon Ultimate Cheeseburger11-Aug-09 21:36
Bacon Ultimate Cheeseburger11-Aug-09 21:36 
GeneralRe: How to set a PDF fields? Pin
ThatsAlok11-Aug-09 22:19
ThatsAlok11-Aug-09 22:19 
Questiondelete [] problem, and extra char(s) showing up in substring? Pin
Mike the Red11-Aug-09 2:11
Mike the Red11-Aug-09 2:11 
AnswerRe: delete [] problem, and extra char(s) showing up in substring? Pin
CPallini11-Aug-09 2:26
mveCPallini11-Aug-09 2:26 
GeneralDeath is in the details... Thanks pallini! -nt- Pin
Mike the Red11-Aug-09 2:31
Mike the Red11-Aug-09 2:31 
GeneralYou are welcome. Pin
CPallini11-Aug-09 2:36
mveCPallini11-Aug-09 2:36 
AnswerRe: delete [] problem, and extra char(s) showing up in substring? Pin
David Crow11-Aug-09 2:53
David Crow11-Aug-09 2:53 
AnswerRe: delete [] problem, and extra char(s) showing up in substring? Pin
Cedric Moonen11-Aug-09 3:10
Cedric Moonen11-Aug-09 3:10 
Generalomfg -or- Thank you, Cedric Pin
Mike the Red11-Aug-09 4:03
Mike the Red11-Aug-09 4:03 
QuestionFSCTL_EXTEND_VOLUME fails Pin
Madan Chauhan11-Aug-09 1:30
Madan Chauhan11-Aug-09 1:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.