Click here to Skip to main content
15,902,445 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How 2 communicate with other objects. Pin
valikac8-Aug-04 10:05
valikac8-Aug-04 10:05 
GeneralRe: How 2 communicate with other objects. Pin
Anonymous8-Aug-04 10:44
Anonymous8-Aug-04 10:44 
GeneralCEditView re-sets caret position on save Pin
sschilachi8-Aug-04 0:29
sschilachi8-Aug-04 0:29 
Generalloading resource only dlls Pin
Ted Podelnyk7-Aug-04 20:28
Ted Podelnyk7-Aug-04 20:28 
GeneralRe: loading resource only dlls Pin
bikram singh7-Aug-04 22:09
bikram singh7-Aug-04 22:09 
GeneralRe: loading resource only dlls Pin
Michael Dunn8-Aug-04 7:12
sitebuilderMichael Dunn8-Aug-04 7:12 
QuestionAny way to programmatically select a printer? Pin
DanYELL7-Aug-04 15:08
DanYELL7-Aug-04 15:08 
AnswerRe: Any way to programmatically select a printer? Pin
7-Aug-04 18:59
suss7-Aug-04 18:59 
// simply copied from MSDN
BOOL CMyApp::SetPrinterDevice(LPTSTR pszDeviceName)
{
   // Open printer and obtain PRINTER_INFO_2 structure.
   HANDLE hPrinter;
   if (OpenPrinter(pszDeviceName, &hPrinter, NULL) == FALSE)
       return FALSE;
   DWORD dwBytesReturned, dwBytesNeeded;
   GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded);
   PRINTER_INFO_2* p2 = (PRINTER_INFO_2*)GlobalAlloc(GPTR,
       dwBytesNeeded);
   if (GetPrinter(hPrinter, 2, (LPBYTE)p2, dwBytesNeeded,
       &dwBytesReturned) == 0)
   {
	   GlobalFree(p2);
	   ClosePrinter(hPrinter);
	   return FALSE;
   }
   ClosePrinter(hPrinter);

// Allocate a global handle for DEVMODE and copy DEVMODE data.
   HGLOBAL  hDevMode = GlobalAlloc(GHND, sizeof(*p2->pDevMode) +
      p2->pDevMode->dmDriverExtra);
   DEVMODE* pDevMode = (DEVMODE*)GlobalLock(hDevMode);
   memcpy(pDevMode, p2->pDevMode, sizeof(*p2->pDevMode) +
      p2->pDevMode->dmDriverExtra);
   GlobalUnlock(hDevMode);

// Compute size of DEVNAMES structure you'll need.
   DWORD drvNameLen = _tcslen(p2->pDriverName);  // driver name
   DWORD ptrNameLen = _tcslen(p2->pPrinterName); // printer name
   DWORD porNameLen = _tcslen(p2->pPortName);    // port name
   DWORD devNameSize = sizeof(DEVNAMES) +
       (ptrNameLen + porNameLen + drvNameLen + 3)*sizeof(TCHAR);

   // Allocate a global handle big enough to hold DEVNAMES.
   HGLOBAL   hDevNames = GlobalAlloc(GHND, devNameSize);
   DEVNAMES* pDevNames = (DEVNAMES*)GlobalLock(hDevNames);

   // Copy the DEVNAMES information from PRINTER_INFO_2 structure.
   pDevNames->wDriverOffset = sizeof(DEVNAMES)/sizeof(TCHAR);
   memcpy((LPTSTR)pDevNames + pDevNames->wDriverOffset,
       p2->pDriverName, drvNameLen*sizeof(TCHAR));

   pDevNames->wDeviceOffset = (WORD)(pDevNames->wDriverOffset + drvNameLen + 1);
   memcpy((LPTSTR)pDevNames + pDevNames->wDeviceOffset,
       p2->pPrinterName, ptrNameLen*sizeof(TCHAR));

   pDevNames->wOutputOffset = (WORD)(pDevNames->wDeviceOffset + ptrNameLen + 1);
   memcpy((LPTSTR)pDevNames + pDevNames->wOutputOffset,
       p2->pPortName, porNameLen*sizeof(TCHAR));

   pDevNames->wDefault = 0;

   GlobalUnlock(hDevNames);
   GlobalFree(p2);   // free PRINTER_INFO_2

   m_hDevMode = hDevMode;
   m_hDevNames = hDevNames;
   return TRUE;
}


Igor Green
http://www.grigsoft.com[^]
Compare It! + Synchronize It! : Files and folders comparison never was easier!
GeneralMapi doesn't work Pin
Spiritofamerica7-Aug-04 11:16
Spiritofamerica7-Aug-04 11:16 
GeneralRe: Mapi doesn't work Pin
David Crow9-Aug-04 3:49
David Crow9-Aug-04 3:49 
GeneralRe: Mapi doesn't work Pin
me also but I didn't log in9-Aug-04 9:24
sussme also but I didn't log in9-Aug-04 9:24 
GeneralRe: Mapi doesn't work Pin
David Crow9-Aug-04 10:58
David Crow9-Aug-04 10:58 
GeneralNEED HELP -- Win 32 MP3 ripper project Pin
Link26007-Aug-04 10:57
Link26007-Aug-04 10:57 
GeneralRe: NEED HELP -- Win 32 MP3 ripper project Pin
Ravi Bhavnani7-Aug-04 13:16
professionalRavi Bhavnani7-Aug-04 13:16 
GeneralRe: NEED HELP -- Win 32 MP3 ripper project Pin
Link26007-Aug-04 13:20
Link26007-Aug-04 13:20 
GeneralRe: NEED HELP -- Win 32 MP3 ripper project Pin
Ravi Bhavnani7-Aug-04 13:21
professionalRavi Bhavnani7-Aug-04 13:21 
GeneralRe: NEED HELP -- Win 32 MP3 ripper project Pin
Link26007-Aug-04 13:22
Link26007-Aug-04 13:22 
GeneralList Box Pin
Timothy Grabrian7-Aug-04 9:13
professionalTimothy Grabrian7-Aug-04 9:13 
GeneralRe: List Box Pin
Ravi Bhavnani7-Aug-04 9:35
professionalRavi Bhavnani7-Aug-04 9:35 
GeneralRe: List Box Pin
David Crow9-Aug-04 3:55
David Crow9-Aug-04 3:55 
GeneralManipulating rows and columns of an Image!! Pin
SR777-Aug-04 7:29
SR777-Aug-04 7:29 
GeneralTooltip in disabled buttons Pin
Rico Zuñiga7-Aug-04 7:07
Rico Zuñiga7-Aug-04 7:07 
Generalhoking functions Pin
gamitech7-Aug-04 5:59
gamitech7-Aug-04 5:59 
GeneralRe: hoking functions Pin
Ryan Binns8-Aug-04 18:31
Ryan Binns8-Aug-04 18:31 
GeneralNeed Help Pin
single647-Aug-04 5:10
single647-Aug-04 5:10 

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.