Click here to Skip to main content
15,907,687 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionrelated to Socket Pin
baldha rakesh15-Jan-06 17:21
baldha rakesh15-Jan-06 17:21 
AnswerRe: related to Socket Pin
kevincwong15-Jan-06 18:20
kevincwong15-Jan-06 18:20 
AnswerRe: related to Socket Pin
sunit515-Jan-06 19:28
sunit515-Jan-06 19:28 
AnswerRe: related to Socket Pin
Prakash Nadar15-Jan-06 19:30
Prakash Nadar15-Jan-06 19:30 
AnswerRe: related to Socket Pin
vikas amin16-Jan-06 0:47
vikas amin16-Jan-06 0:47 
Questioncall FindFirstPrinterChangeNotification() Get Error 997? Pin
szcococut15-Jan-06 16:30
szcococut15-Jan-06 16:30 
AnswerRe: call FindFirstPrinterChangeNotification() Get Error 997? Pin
Prakash Nadar15-Jan-06 19:32
Prakash Nadar15-Jan-06 19:32 
GeneralRe: call FindFirstPrinterChangeNotification() Get Error 997? Pin
szcococut15-Jan-06 20:11
szcococut15-Jan-06 20:11 
/* reinitialize the Termination Event so we can proceed */
ResetEvent(g_hTerminateEvent);

hPrinterNotification = FindFirstPrinterChangeNotification(
ThreadParam.hPrinter, /* The printer of interest */
PRINTER_CHANGE_DELETE_JOB, /* We need to know when a job is removed */
0, /* reserved */
&NotificationOptions); /* The details of what notifications that are needed */

/* Check for an error */
if (hPrinterNotification == INVALID_HANDLE_VALUE)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
return 0;
}


/*
* Loop on the Notifications, a terminate event, or a refresh event
*/

/* setup for a WaitForMultipleObjects */
Handles[0] = hPrinterNotification;
Handles[1] = g_hTerminateEvent;
Handles[2] = g_hForceRefreshEvent;

/* Initialize for our local data structure */
ZeroMemory(&Queue, sizeof(Queue));
Queue.Printer.hPrinter = ThreadParam.hPrinter;

/* Initialize the display and our local copy of the printer queue data */
CPrinterJob::Refresh(ThreadParam.hWnd, &Queue);

/*
* Loop while we are stilling waiting on Notifications.
*/
while (hPrinterNotification != INVALID_HANDLE_VALUE)
{
/* wait for a printer notification, terminate event, or refresh event */
WaitForMultipleObjects(3, Handles, FALSE, INFINITE);

/* check to see if the thread needs to quit. */
if (WaitForSingleObject(g_hTerminateEvent, 0) == WAIT_OBJECT_0)
{
/* This should be the only way out of the loop */
FindClosePrinterChangeNotification(hPrinterNotification);
hPrinterNotification = INVALID_HANDLE_VALUE;
}

/* or check to see if the notification object for the printer queue is signaled */
else if (WaitForSingleObject(hPrinterNotification, 0) == WAIT_OBJECT_0)
{
/* get the changes and reset the notification */
if (!FindNextPrinterChangeNotification(hPrinterNotification,
&WaitResult, /* for the PRINTER_CHANGE_DELETE_JOB notice */
&NotificationOptions, /* The notifications */
(void **)&pNotification)) /* address of pointer that gets what changed */
{
//ErrorBox(GetLastError(), "FindNextPrinterChangeNotification");
int iiii = 0;
}

/* Did a notification overflow occur? */
if (pNotification && pNotification->Flags & PRINTER_NOTIFY_INFO_DISCARDED)
{
/* An overflow of notifications occured, must refresh to continue */

OldFlags = NotificationOptions.Flags;

NotificationOptions.Flags = PRINTER_NOTIFY_OPTIONS_REFRESH;

FreePrinterNotifyInfo(pNotification);
if (!FindNextPrinterChangeNotification(hPrinterNotification,
&WaitResult,
&NotificationOptions,
(void **)&pNotification))
{
//ErrorBox(GetLastError(), "FindNextPrinterChangeNotification refresh call.");
int jjjj = 0;
}
NotificationOptions.Flags = OldFlags;

/* Start Over with Refreshed Data */
CPrinterJob::Refresh(ThreadParam.hWnd, &Queue);

}

/* process the notification of changes */
if (WaitResult & PRINTER_CHANGE_DELETE_JOB)
{
/* a job was deleted so start over clean */
CPrinterJob::Refresh(ThreadParam.hWnd, &Queue);
}
else
{
/* track and show the changes */
CPrinterJob::RefreshFromNotification(ThreadParam.hWnd, &Queue, pNotification);
}
FreePrinterNotifyInfo(pNotification);
pNotification = NULL;
}

/* Or, maybe the user wants to refresh the view of the print queue */
else if (WaitForSingleObject(g_hForceRefreshEvent, 0) == WAIT_OBJECT_0)
{
CPrinterJob::Refresh(ThreadParam.hWnd, &Queue);
ResetEvent(g_hForceRefreshEvent);
}

Sleep(5);
}

/* Done watching for notifications, cleanup */
ClosePrinter(ThreadParam.hPrinter);
CPrinterQueue::FreeQueueData(&Queue);

/* Thread posts the close message when the application is going away so the
* the application willattempt to close down again and succeed since the
* thread has died.
*/
if (bCloseApp)
PostMessage(ThreadParam.hWnd, WM_CLOSE, 0, 0);
return TRUE;
QuestionInvisible/Visible Button Pin
DanYELL15-Jan-06 13:05
DanYELL15-Jan-06 13:05 
AnswerRe: Invisible/Visible Button Pin
Maximilien15-Jan-06 13:54
Maximilien15-Jan-06 13:54 
QuestionResizing dialog-based app and its controls Pin
Jamaica15-Jan-06 11:15
Jamaica15-Jan-06 11:15 
AnswerRe: Resizing dialog-based app and its controls Pin
Christian Graus15-Jan-06 12:13
protectorChristian Graus15-Jan-06 12:13 
AnswerRe: Resizing dialog-based app and its controls Pin
Anilkumar K V15-Jan-06 18:16
Anilkumar K V15-Jan-06 18:16 
AnswerRe: Resizing dialog-based app and its controls Pin
David Crow16-Jan-06 3:12
David Crow16-Jan-06 3:12 
GeneralRe: Resizing dialog-based app and its controls Pin
Jamaica16-Jan-06 8:02
Jamaica16-Jan-06 8:02 
GeneralRe: Resizing dialog-based app and its controls Pin
Shraddhan22-Jan-06 22:56
Shraddhan22-Jan-06 22:56 
QuestionProblem with std::list Pin
Mateusz Karbowy15-Jan-06 10:36
Mateusz Karbowy15-Jan-06 10:36 
AnswerRe: Problem with std::list Pin
Christian Graus15-Jan-06 11:12
protectorChristian Graus15-Jan-06 11:12 
GeneralRe: Problem with std::list Pin
Stephen Hewitt15-Jan-06 11:51
Stephen Hewitt15-Jan-06 11:51 
GeneralRe: Problem with std::list Pin
Christian Graus15-Jan-06 11:53
protectorChristian Graus15-Jan-06 11:53 
GeneralRe: Problem with std::list Pin
Stephen Hewitt15-Jan-06 12:04
Stephen Hewitt15-Jan-06 12:04 
GeneralRe: Problem with std::list Pin
Christian Graus15-Jan-06 12:12
protectorChristian Graus15-Jan-06 12:12 
AnswerRe: Problem with std::list Pin
Christian Graus15-Jan-06 12:14
protectorChristian Graus15-Jan-06 12:14 
AnswerRe: Problem with std::list Pin
Stephen Hewitt15-Jan-06 12:22
Stephen Hewitt15-Jan-06 12:22 
GeneralRe: Problem with std::list Pin
Mateusz Karbowy15-Jan-06 14:07
Mateusz Karbowy15-Jan-06 14:07 

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.