|
You need to use the dmDefaultSource (and dmFields) members of the DEVMODE structure. If you look in MSDN under DEVMODE (for Windows GDI: Platform SDK) you will see the values that are defined. In newer versions of C++, this has been phased out and is now unsupported (although it still 'works'). This is problematic because printer manufacturers never decided on a standard convention for numbering the trays of a printer. Some numbers will work for all drivers (if memory servers 4 = Manual Feed for all known printer drivers). I would suggest getting a Win32 SDK programming book. Know that although this may work for YOUR version of the printer and driver, it MAY or MAY not work for other printer/driver combinations. It may not even work with different versions of the same driver for the same printer. This is a use at your own risk type of feature. I implemented something similar to this for a company that I worked for. It was very problematic. We had to update all of the customer databases with the printer/driver specific information for this to work.
I would get a copy of Win32 SDK Programming (a big blue book). Unfortunatly I don't recall the authors names.......Hope I could help.
|
|
|
|
|
I want to use HTML View in my application, but the HTML file is loaded from database, and there is some picture, how to load it to HTML VIEW?
|
|
|
|
|
Some ideas:
1) save the picture to a temp file, then change each reference to that picture in the HTML source
2) use a .mht file, that has embedded pictures
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
However, If I know how IE works, I think it will help me more.
Thanks your help!!!
What I needed maybe you have, so let's help each other.
|
|
|
|
|
Well, I would be glad to help you, if I could, but I can't see how.
If all you do is reading from the database, and you can convert each "HTML+pictures" record to a ".mht" record, then no problem.
If you need to write such records from your program, obviously you have to know how to produce a ".mht". What I know about it is that it's a multipart MIME message, in fact if you rename it to .eml you can open it with OutlookExpress.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hello,
I am trying to figure out the best way to go about implementing timers in a list control.. What I need to do (as far as I can tell) is get the total number of items currently in the list and then "on the fly" assign a timer member variable to each item in lets say row 5.. anyone know where I should start.. Getting the total numbers of items is easy but I cant figure out how I can assign a member variable to each of these items in row 5 so my timer can keep track of the time remaining.
Rob
|
|
|
|
|
One way to do this would be to derive a new class from CList. The new class would override the list maintenance methods (AddTail, SetAt etc.) that you use. Your new methods could then store the necessary values in an array of some sort.
Hope this helps ,
Bill
|
|
|
|
|
Once again I find date conversions rearing their ugly head.
Maybe I'm just having a bad day, but I can't find/think of a sensible algorithm to convert a day of year and year into a day of month, month and year.
e.g. Day of Year = 5 Year = 1980 => Day = 5, Month = 1, Year = 1980.
Please help
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
Does it really have to be particularly efficient?
void FormatDate( int nDay, int nYear)
{
int nLeapYear;
nDay-=31;
if (nDay <= 0) {
}
if (( (nYear /4) * 4) == nYear) nLeapYear=1
nDay= nDay - 28 - nLeapYear;
if (nDay <= 0) {
}
}
not tested that, but shouldn't be too far from the correct one
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
[edited message]
This will not work for 2100, 1900, 1800. The rule is:
If the year is divisible by 4, it’s a leap year.
But—if the year is also divisible by 100, it’s not a leap year.
Double but—if the year is also divisible by 400, it is a leap year.
BTW: just use % operator instead of dividing/multiplying by 4
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
2000 *was* a leap year... so my original suggestion worked from 1901 until 2099 !
We all have to work together for another arbitrary date limitation in the software we write: this way, we can be sure that we get consultancy fees a la Y2K !!!!!
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
2000 *was* a leap year
Yes it was - I've already edited my first response.
this way, we can be sure that we get consultancy fees a la Y2K
January 18, 2038 is the day when time_t stops working. Now imagine how TV 'experts' would try to explain the problem to average Joe Viewer.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I do that:
struct tm tpTime = { 0, 0, 0, 1, 0, 80};
time_t newtime;
tpTime.tm_mday += nDays;
newtime = mktime(&tpTime);
in newtime you have the time 1/1/1980 + nDays
and you have the correct date in the newtime struct
nDayofMonth = newtimw.tm_mday;
nMonth = newtime.tm_mon + 1; //(Jan = 0)
nYear = newtime.tm_year + 1900;
Good Luck...
note
Thiscode can fail because I wrote the code directly in codeproject. (I don't have a compiler here for test bugs....)
Carlos Antollini.
|
|
|
|
|
I need to send text to another running program, such as Notepad.. I've done this so far:
CWnd* notepad;
if ( notepad = FindWindow(NULL,"Untitled - Notepad")) {
notepad->SetForegroundWindow();
//This is where I'm stumped.
}
I'm simply trying to send something like "Hello" to the main Notepad edit box.
Thanks. -Sinoth
|
|
|
|
|
First, use FindWindow is not good, beause you can find more than one window with the same text. For this is better to search for each handle starting with the desktop handle looking ever for the next handle.
When you found the Notepad, ypu need to find the handle of the edit, the handle that you found is the window handle, if you send a message to that handle the text wil be changed in the title bar, and not in the edit.
I hope to help you.
Carlos Antollini.
|
|
|
|
|
use EnumChildWindows to enumerate all the child windows
now call GetWindowLong on each of those child handles and try and figure out which is the edit box. using the GWL_STYLE try and see if you can get the window having the ES_MULTILINE style. that will inall probability be notepad's edit window. Now use SetWindowText()
I hope this helped....
Regards
Nish [BusterBoy]
|
|
|
|
|
Hi All,
I'm happy to get responce of my earlier problem. I'll look into that. I appreciate you all.
Here I've another problem. I want the text of an edit box to be hilighted when focus goes onto it. Suppose one has selected a Radio button then I want the Edit Box to be focused with it's text content hilighted. So that pressing any key would delete the entire old text, and write a new what ever is pressed.
Thanks
Dhirendra Mishra
|
|
|
|
|
Handle the EN_SETFOCUS notification for the edit control.
Put this in the event handler:
m_Edit.SetSel(0,-1,TRUE);
where m_Edit is the name of your control.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
You need to use the CEdit::SetSel(); function
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Hi, I have a function to download a file using FTP. Maybe, sometimes, the server is too busy, and the operation is too long, how can I limit the download time to abort if it is necessary?
This is the function I have:
void getMetar()
{
CString strServerName;
CString strObject;
INTERNET_PORT nPort;
DWORD dwServiceType;
CFtpConnection* pConn = NULL;
CInternetSession* m_pInetSession;
CString fileMetar;
CString vacio ="";
CWaitCursor EsperaRaton;
fileMetar =vacio+ selEstacion + ".TXT";
m_pInetSession = new CInternetSession("Unknown",1,INTERNET_OPEN_TYPE_PRECONFIG);
if(!m_pInetSession)
AfxMessageBox("Not valid session found");
AfxParseURL("ftp://tgftp.nws.noaa.gov", dwServiceType, strServerName, strObject, nPort);
if((dwServiceType==INTERNET_SERVICE_FTP)&&!strServerName.IsEmpty())
{
try
{
pConn = m_pInetSession->GetFtpConnection(strServerName, "", "", nPort, FALSE);
}
catch(CInternetException* pEx)
{
char szErr[1024];
pEx->GetErrorMessage(szErr,1024);
AfxMessageBox(szErr);
pEx->Delete();
pConn = NULL;
}
}
else
AfxMessageBox("Invalid URL");
pConn->SetCurrentDirectory("/data/observations/metar/stations/");
if(!pConn->GetFile(fileMetar, "tempMet.txt",INTERNET_FLAG_RESYNCHRONIZE|INTERNET_FLAG_RELOAD ,FALSE))
AfxMessageBox("File not found");
if(m_pInetSession!=NULL)
{
m_pInetSession->Close();
delete m_pInetSession;
}
if (pConn!=NULL)
pConn->Close();
}
|
|
|
|
|
We're developing our first internet application and there's something I'd like to know. The problem is that when debugging asp in the server, only one person can be debugging at a time. What I'd like to know is if there's any way to know (using Visual C++) if somebody is debugging at the moment, because we're having problems when two persons try to debug at the same time.
Thanks for the answer,
|
|
|
|
|
Hi All,
May be it's a basic thing for u guys... but I'm new, How can I remove all the files in a folder. I can give path to the folder. I'm not in position to give the names of all the files. Had it been possible, I would have used Remove(). I want to remove the files, what ever they are.....
Looking forward for a quick solutions from all of u.......
Dhirendra Mishra
|
|
|
|
|
look up CFilefind. You can iterate through a directory. Of course you can also step above it and delete it, I reckon you could also use shellexecute to del *.*
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
if you don't wanna use mfc there is an api - possibility
FindFirstFile and FindNextFile
Have fun
Bernhard
"I went on a diet, swore off drinking and heavy eating, and in fourteen days I had lost exactly two weeks." Joe E. Lewis [American humorist]
|
|
|
|
|
There's an easier way than enumerating files and deleting them one at the time. SHFileOperation with FO_DELETE command supports wildcards, so you should add *.* to folder name and call SHFileOperation. FOF_SILENT and FOF_NOCONFIRMATION will block any dialogs/messages displayed during delete.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|