|
There's not a direct replacement for it because CStr() returns a different value depending on the type of value sent to it. For example, it might return True/False if the value is Boolean , or a short date if the value is a Date .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello everybody,
Is there any possiblity to declare a variable as a Variant and a Variant array?
for example in VB, we can declare
Dim rec(80) As Variant //array
Dim msg As Variant
Is there any possibility to declare like this Visual C++?
Likewise in VB,
'msg' which holds some variant value and I can display it in text box.
Text1.Text = msg3
How can I display the variant value in edit box?
Please reply me.. thanks in advance.
Dharani
|
|
|
|
|
dharani_3d wrote: Is there any possiblity to declare a variable as a Variant and a Variant array?
SAFEARRAY and VARIANT are its replacement in VC++.
dharani_3d wrote: Dim rec(80) As Variant //array
Dim msg As Variant
Is there any possibility to declare like this Visual C++?
Likewise in VB,
'msg' which holds some variant value and I can display it in text box.
Text1.Text = msg3
How can I display the variant value in edit box?
I'm not sure, but in VB variants are used for representing array.
So, its char array in terms of C++.
So you can use char array or CStringArray as its VC eqvivalent.
|
|
|
|
|
Dear All
I have to monitor a printer, and for that I have to use FindFirstPrinterChangeNotification and FindNextPrinterChangeNotification APIs. For this I have written the code, which is below. Some problems that i am facing with this code are also stated below (after the code). It will be great you can shed some light on the issues I am facing. It will be of great help.
void StartNotifications(void)
{
HANDLE hPrinter = NULL;
PRINTER_NOTIFY_OPTIONS * p_NotifyOptions = NULL;
PRINTER_NOTIFY_OPTIONS_TYPE arr_NotifyOptionsType[2];
PWORD pPrinterFields;
WORD arrJobFields[100];
HANDLE hwndNotify = NULL;
DWORD dwChanged = 0;
int i;
FILE * pFile;
TCHAR * pBuf;
DWORD * adwData;
TCHAR arrBuf[50];
pFile = _tfopen(_T("C:\\PrinterNotifications.txt"), _T("a+"));
if(pFile)
{
MessageBox(NULL, _T("Opened"), _T("File Status"), MB_OK);
}
PRINTER_NOTIFY_INFO * p_OutPut = NULL;
if(OpenPrinter(_T("\\\\NECHCLSTDC\\HP LaserJet 4345 mfp PCL 5e"),
&hPrinter, NULL))
{
i=0;
arrJobFields[i++] = JOB_NOTIFY_FIELD_PRINTER_NAME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_MACHINE_NAME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_PORT_NAME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_USER_NAME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_NOTIFY_NAME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_DATATYPE;
arrJobFields[i++] = JOB_NOTIFY_FIELD_PRINT_PROCESSOR;
arrJobFields[i++] = JOB_NOTIFY_FIELD_PARAMETERS;
arrJobFields[i++] = JOB_NOTIFY_FIELD_DRIVER_NAME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_STATUS_STRING;
arrJobFields[i++] = JOB_NOTIFY_FIELD_DOCUMENT;
arrJobFields[i++] = JOB_NOTIFY_FIELD_PRIORITY;
arrJobFields[i++] = JOB_NOTIFY_FIELD_POSITION;
arrJobFields[i++] = JOB_NOTIFY_FIELD_START_TIME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_UNTIL_TIME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_TIME;
arrJobFields[i++] = JOB_NOTIFY_FIELD_TOTAL_PAGES;
arrJobFields[i++] = JOB_NOTIFY_FIELD_PAGES_PRINTED;
arrJobFields[i++] = JOB_NOTIFY_FIELD_TOTAL_BYTES;
arrJobFields[i++] = JOB_NOTIFY_FIELD_BYTES_PRINTED;
arr_NotifyOptionsType[0].Type = JOB_NOTIFY_TYPE ;
arr_NotifyOptionsType[0].pFields = arrJobFields;
arr_NotifyOptionsType[0].Count = 20;
pPrinterFields = (PWORD)malloc(2 * sizeof(WORD));
pPrinterFields[0] = PRINTER_NOTIFY_FIELD_PRINTER_NAME;
pPrinterFields[1] = PRINTER_NOTIFY_FIELD_AVERAGE_PPM;
arr_NotifyOptionsType[1].Type = PRINTER_NOTIFY_TYPE ;
arr_NotifyOptionsType[1].pFields = pPrinterFields;
arr_NotifyOptionsType[1].Count = 2;
p_NotifyOptions = new PRINTER_NOTIFY_OPTIONS;
p_NotifyOptions->Count = 2;
p_NotifyOptions->Version = 2;
p_NotifyOptions->pTypes = arr_NotifyOptionsType;
p_NotifyOptions->Flags = PRINTER_NOTIFY_OPTIONS_REFRESH;
if((hwndNotify = FindFirstPrinterChangeNotification(hPrinter,
PRINTER_CHANGE_ALL, 0, p_NotifyOptions)) != INVALID_HANDLE_VALUE)
{
while(hwndNotify != INVALID_HANDLE_VALUE)
{
if(WaitForSingleObject(hwndNotify, INFINITE) == WAIT_OBJECT_0)
{
FindNextPrinterChangeNotification(hwndNotify, &dwChanged,
(LPVOID)p_NotifyOptions, (LPVOID*)&p_OutPut);
for (int i=0;(i<p_output->Count) && ;i++)
{
pBuf = (TCHAR*)(p_OutPut->aData[i].NotifyData.Data.pBuf);
adwData = p_OutPut->aData[i].NotifyData.adwData;
switch(p_OutPut->aData[i].Type)
{
case JOB_NOTIFY_TYPE:
{
//printf("\tジョブ通知(no.%d, id:%d)...", i,
p_OutPut->aData[i].Id);
switch(p_OutPut->aData[i].Field)
{
case JOB_NOTIFY_FIELD_PRINTER_NAME:
_fputts(_T("Printer Name "), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_MACHINE_NAME:
_fputts(_T("machine Name "), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_PORT_NAME:
_fputts(_T("Port Name "), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_USER_NAME:
_fputts(_T("User Name "), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_NOTIFY_NAME:
_fputts(_T("Notify Name "), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_DATATYPE:
_fputts(_T("Data Type "), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_PRINT_PROCESSOR:
_fputts(_T("Print Processor "), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_PARAMETERS:
_fputts(_T("Parameters"), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_DRIVER_NAME:
_fputts(_T("Driver Name "), pFile);
_fputts(pBuf, pFile);
_fputtc(_T('\n'), pFile);
break;
case JOB_NOTIFY_FIELD_DEVMODE:
// DEVMODE
break;
case JOB_NOTIFY_FIELD_STATUS:
if(adwData[0] & JOB_STATUS_PAUSED)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Paused"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_ERROR)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Error"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_DELETING)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Deleting"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_SPOOLING)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Spooling"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_PRINTING)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Printing"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_OFFLINE)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Offline"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_PAPEROUT)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("PaperOut"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_PRINTED)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Printed"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_DELETED)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Deleted"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_BLOCKED_DEVQ)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Blocked DevQ"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_USER_INTERVENTION)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("User Intervention"), pFile);
_fputtc(_T('\n'), pFile);
}
if(adwData[0] & JOB_STATUS_RESTART)
{
_fputts(_T("Status = "), pFile);
_fputts( _T("Restart"), pFile);
_fputtc(_T('\n'), pFile);
}
break;
case JOB_NOTIFY_FIELD_STATUS_STRING:
{
_fputts(_T("Status String= "), pFile);
_fputts( pBuf, pFile);
_fputtc(_T('\n'), pFile);
}
break;
case JOB_NOTIFY_FIELD_DOCUMENT:
{
_fputts(_T("Document = "), pFile);
_fputts( pBuf, pFile);
_fputtc(_T('\n'), pFile);
}
break;
case JOB_NOTIFY_FIELD_SUBMITTED:
//SYSTEMTIME
break;
case JOB_NOTIFY_FIELD_START_TIME:
memset(arrBuf, _T('\0'), 50);
_stprintf(arrBuf,_T("Start Time: %d:%d\n"), adwData[0]/60,
adwData[0]%60);
_fputts(arrBuf, pFile);
break;
case JOB_NOTIFY_FIELD_UNTIL_TIME:
memset(arrBuf, _T('\0'), 50);
_stprintf(arrBuf,_T("Until Time: %d:%d\n"), adwData[0]/60,
adwData[0]%60);
_fputts(arrBuf, pFile);
break;
case JOB_NOTIFY_FIELD_TIME:
memset(arrBuf, _T('\0'), 50);
_stprintf(arrBuf,_T("Field Time: %d: %d\n"), adwData[0]/60,
adwData[0]%60);
_fputts(arrBuf, pFile);
break;
case JOB_NOTIFY_FIELD_TOTAL_PAGES:
memset(arrBuf, _T('\0'), 50);
_stprintf(arrBuf,_T("Total Pages: %d\n"), adwData[0]);
_fputts(arrBuf, pFile);
break;
case JOB_NOTIFY_FIELD_PAGES_PRINTED:
memset(arrBuf, _T('\0'), 50);
_stprintf(arrBuf,_T("Pages Printed: %d\n"), adwData[0]);
_fputts(arrBuf, pFile);
break;
case JOB_NOTIFY_FIELD_TOTAL_BYTES:
memset(arrBuf, _T('\0'), 50);
_stprintf(arrBuf,_T("Total Bytes: %d\n"), adwData[0]);
_fputts(arrBuf, pFile);
break;
case JOB_NOTIFY_FIELD_BYTES_PRINTED:
memset(arrBuf, _T('\0'), 50);
_stprintf(arrBuf,_T("Bytes Printed: %d\n"), adwData[0]);
_fputts(arrBuf, pFile);
break;
}
break;
}
case PRINTER_NOTIFY_TYPE:
{
}
break;
}
}
}
}
}
else
{
DWORD dwError = GetLastError();
dwError += 0;
}
}
else
{
DWORD dwError = GetLastError();
dwError += 0;
}
}
I dumped the notification data in a file, and had the following
observations:
1. I never received any Status notification for any type of Print job,
i.e be it in EMF format or RAW format. In case of Status String, the
notification was there, but the pBuf was empty. So, how do we receive the status info?
2. In case of print job with EMF data type, the Total Pages and Printed
pages data was received correctly. Same case for Total Bytes and
Printed Bytes.
3. In case of print job with RAW format, Total pages was received with
correct values, but Printed Pages was always recieved with the value 0.
Total Bytes was OK, but at the end of the print job, the Total Bytes
and Printed Bytes were different, the latter being lesser then former.
So, it doesn't help in determining that whether a print job is finished
or not.
Thanks in advance.
Pankaj
|
|
|
|
|
Hello,
is here an sample how to show the caret as an hourglass?
In my project is an filter function, that filters items from a CGridCtrl,
and i like to show the caret as an hourglass during this filtering!
Thanks for any help!
break;
|
|
|
|
|
Use CWaitCursor class.
e.g
void CMyClass::foo()
{
CWaitCursor cursor;
cursor.Restore();
}
|
|
|
|
|
Ignore this answer. It was wrong!
Sorry.
I give myself a 1.
-- modified at 9:26 Friday 15th December, 2006
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Restore is meant for restoring wait cursor, if its been changed.
Sometime , during lengthy operations, it get changed to some other cursor.
This function restores it back to wait cursor. I think you misinterpreted its functionality.
kakan wrote: So the cursor automaticly gets restored when the CWaitCursor goes out of scope.
, Original cursor gets restored in this case.
|
|
|
|
|
OK, my mistake, I didn't know that. Sorry.
I will remove my post in a couple of minutes (to give you time to read this.)
Kakan
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
kakan wrote: OK, my mistake, I didn't know that. Sorry
Everybody does that, sometime.
|
|
|
|
|
kakan wrote: I give myself a 1.
Come on ! I give you 5 for this.
|
|
|
|
|
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Hello,
thanks wery much for help! Works.
And i have a next question, sometimes i see applications with rotate hourglass, how do they this,
or placed on an litle dialog, e.g, with message like "wait " and on the same litle dialog is
an rotate hourglass!?
thanks
break;
|
|
|
|
|
break; wrote: And i have a next question, sometimes i see applications with rotate hourglass, how do they this
they created a custom cursor for their application, most likely.
break; wrote: or placed on an litle dialog, e.g, with message like "wait " and on the same litle dialog is
an rotate hourglass!?
that's a 'modeless' cancel dialog. there are examples on CodeProject (look in the MFC / Dialog section).
|
|
|
|
|
Hello,
thanks very much for answer,
hmm, i can make an *.gif image, such as e.g. myhour.gif(animate gif) and
place them on the new litle dialog!? Is that the first way to solve them?
thanks
break;
|
|
|
|
|
I have an image of a classroom. I want to get the position(coordinate) of every desk in it(the color of the desk is different from that of the background).
Are there any good and simple arithmetics to deal with this problem? It doesn't have to be very precise.
Thanks!
|
|
|
|
|
Hi !!!
I have one file called acad.mns(Autocad file which contain toolbar) so how i can load this file in my application..This file will load toolbar in my application.
Thank you very much..
Shah Satish
|
|
|
|
|
Shah Satish wrote: This file will load toolbar in my application.
How ? Can you be clear in what you are saying ?
|
|
|
|
|
Hi,
I cant remember what exactly contain acad.mns but it it's a txt file and if you want to load toolbar straigth from AutoCad basis on it - forget about it - probably mission impossible
-----------
Mila
|
|
|
|
|
How to write an SQL statement to retrive just 3 columns from my table?
In CRecordset::Open(CRecordset::snapshot,"SELECT city FROM data1");
city = column
city1 = column
city2 = column
data1 = table
Database name -> Database_city1
this statement is wrong but i dont now what!
please help me !
Bravoone
|
|
|
|
|
You can declare three columns on Select statement
|
|
|
|
|
"SELECT city,city1,city2 FROM data1"
this is posible?
Bravoone
|
|
|
|
|
Select city,name From Authors
---------
Select * From Authors (I believe its not good because if we have 100,000 records how many time to reads them?)
---------
Select col1 from Authors Where number in('123','000')
---------
Select col1 From authors Where title LIKE '%book%'
|
|
|
|
|
Bravoone_2006 wrote: SELECT city,city1,city2 FROM data1"
this is posible?
yes, if city, city1 and city2 are columns of the table data1 (which is badly named if so).
BTW, your problem is a SQL question, not related to C/C++ at all, so you should have asked the SQL forum
|
|
|
|
|
Or rather, Bravoone should spend an hour with reading chapter one from any SQL book...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|