|
Ali Tavakol wrote: How can I be notified of date changes in vc?
You can't that I know of. What you could do is call SetTimer() with a one-minute resolution. Each time the timer procedure is called, check the current time.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
Well, what I've once done in a situation like that goes at follows:-
At Startup, read the time and calculate the timespan untill 00:00:00 Next.
{time_t Now=time(NULL); long Delay=86400-(Now-(Now/86400)*86400));}
Then Set a timer for this Delay(*1000) (timers work in mS!).
When the Timer Fires, first set a New one for 86400 Seconds. Then do the bits you need to do, and kill the old timer.
Depending on your needs, there are thousands of methods to skin this particular cat. The problem branches various ways, depending on what you want to do retrospectively with days where the system was not running for several days, and also what must happen if the user changes the Clock or Timezone, What about DST. None of that is difficult to resolve, provided one is aware of these 'imponderable' actions.
Hope this is helpfull,
Regards
Bram van Kampen
|
|
|
|
|
Hello,
I have develpoed an application on windows 2003sp1 which has to do with font. I have drawn text and set the font size as 36 and I have opend the same application in windos vita using cleartype enabled I could see the size of the font has reduced to 1 that is the font size has become 35.This is because in windows vista does font smoothing when cleartype is enabled due to which the font size reduces.
Here is the code
SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &IsEnabled, 0);
templfQuality = td->lf.lfQuality;
if( IsEnabled && templfQuality != NONANTIALIASED_QUALITY ) {
td->lf.lfQuality = NONANTIALIASED_QUALITY;
}
I am checking this way but its not working properly
Regards
|
|
|
|
|
I want to get user input when a user clicks a item in list control. Is there any easier or better way to achieve this than to use an edit box, display it where user has clicked, then read the data from edit box and display it into list control?
Thanks.
the fruits of your success will be in direct ratio to the honesty and sincerity of your own efforts in keeping your own records, doing your own thinking and, reaching your own conclusions.
..surviving in autumn..in love with spring..
|
|
|
|
|
I don't quite get your requirement. Can you explain?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I am sorry for being ambiguous.
I want to show 10 numbers to user and corresponsing to each number, I need a string from user.
For this, I am using a list control inside a dialog box and in first column, 1-10 numbers will be placed in 10 rows and in second column, user will enter text corresponding to each number.
Then I need to store all this data.
My problems are - If I use list control, then the sub items(second column) does not appear to editable.
Second, I am wondering whether xml is the right way to store this data or do I have other options?
I expect the number of items to grow.
Thanks for any inputs.
the fruits of your success will be in direct ratio to the honesty and sincerity of your own efforts in keeping your own records, doing your own thinking and, reaching your own conclusions.
..surviving in autumn..in love with spring..
|
|
|
|
|
For in-place editing, Steen Krogsgaard has given you the idea.
theCPkid wrote: Second, I am wondering whether xml is the right way to store this data or do I have other options?
Well, that totally depends on your choice. You can put it in the registry as well. If it is in an XML or inf file, it becomes easily portable (if such a thing is desired).
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Instead of using a list control, use a list-view control with LVS_EDITLABELS style set. See MSDN List-view control or LVS_EDITLABELS for details.
Cheers
Steen.
"Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006
"Of course, the next day it automatically updates, and your quick'n'dirty patches cause the new binaries to segfault all over your linoleum. If only you'd had the source..." Shog, 10/18/2006
"One day I realized that sadness is just another word for not enough coffee" Wally, 10/18/2006
|
|
|
|
|
I want to write C++ executable (console application), which will prompt the user to enter user name and password. The problem I am facing is when the user enter his/her password it is visible, so how to hide the password entry. Which means user can enter the password but it should not be displayed in the console.
Can any once help to achieve this? (That is hiding the password entry when it prompts for pw)
Thanks,
Nandu
|
|
|
|
|
In a console application, how are you obtaining the password from user? Use getch() to get the character and then do not display that character on screen or display '*' instead.
I did not exactly get your question.
the fruits of your success will be in direct ratio to the honesty and sincerity of your own efforts in keeping your own records, doing your own thinking and, reaching your own conclusions.
..surviving in autumn..in love with spring..
|
|
|
|
|
Can you show us your code?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Below is the code
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
using namespace std;
string XOR(string value,string key)
{
string retval(value);
short unsigned int klen=key.length();
short unsigned int vlen=value.length();
short unsigned int k=0;
short unsigned int v=0;
for(v;v<vlen;v++)
{
retval[v]=value[v]^key[k];
k=(++k<klen?k );
}
return retval;
}
/******************************************************************************/
/* Here's a Test Program */
/******************************************************************************/
int main()
{
//string value("just for fun");
string key = "TERADATA";
string username;
string password;
string cnfpassword;
ofstream myfile;
cout<<"Enter user name::";
cin>>username;
cout<<"Enter Password\n";
cout<<"NOTE:\n"<<"1) Password can be alphanumeric or numeric or alphabets\n"
<<"2) Blank spaces not allowed\n"<<"::";
cin>>password;
cout<<"Confirm Password::";
cin>>cnfpassword;
if (password.compare(cnfpassword) != 0)
{
cout<<"Sorry Password dose not match....try again"<<"\n";
return 1;
}
else
{
password=XOR(password,key);
}
cout<<"Encrypted Password ::"<<"\n";
cout<<password<<"\n\n";
myfile.open("Test_SSOpw.txt", ios::out);
if( !myfile )
cout<<"Error opening file";
else
{
myfile.write("#USERNAME#", 10);
myfile.write(username.c_str(), username.length());
myfile <<'\n';
myfile <<"#PASSWORD#"<<password;
myfile.close();
cout<<"Functional SSO password encryption success!!"<<'\n';
}
password=XOR(password,"TERADATA");
cout<<"Decrypted Password ::"<<password<<"\n";
getch();
return 0;
}
|
|
|
|
|
Below is the code
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
using namespace std;
string XOR(string value,string key)
{
string retval(value);
short unsigned int klen=key.length();
short unsigned int vlen=value.length();
short unsigned int k=0;
short unsigned int v=0;
for(v;v<vlen;v++)
{
retval[v]=value[v]^key[k];
k=(++k<klen?k);
}
return retval;
}
/******************************************************************************/
/* Here's a Test Program */
/******************************************************************************/
int main()
{
//string value("just for fun");
string key = "TERADATA";
string username;
string password;
string cnfpassword;
ofstream myfile;
cout<<"Enter user name::";
cin>>username;
cout<<"Enter Password\n";
cout<<"NOTE:\n"<<"1) Password can be alphanumeric or numeric or alphabets\n"
<<"2) Blank spaces not allowed\n"<<"::";
cin>>password;
cout<<"Confirm Password::";
cin>>cnfpassword;
if (password.compare(cnfpassword) != 0)
{
cout<<"Sorry Password dose not match....try again"<<"\n";
return 1;
}
else
{
password=XOR(password,key);
}
cout<<"Encrypted Password ::"<<"\n";
cout<<password<<"\n\n";
myfile.open("Test_SSOpw.txt", ios::out);
if( !myfile )
cout<<"Error opening file";
else
{
myfile.write("#USERNAME#", 10);
myfile.write(username.c_str(), username.length());
myfile <<'\n';
myfile <<"#PASSWORD#"<<password;
myfile.close();
cout<<"Functional SSO password encryption success!!"<<'\n';
}
password=XOR(password,"TERADATA");
cout<<"Decrypted Password ::"<<password<<"\n";
getch();
return 0;
}
|
|
|
|
|
Nandu_77b wrote: cin>>cnfpassword;
Use getc() in a while loop to get the password characters and display an asterisk with cout for each character.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have tried with the below code, but I am getting some junk value in password.
int i = 0;
char ch;
char password[20];
do
{
ch = getch();
cerr<<"*";
password[i++] = ch;
}
while(ch != '\r');
|
|
|
|
|
This works for me:
std::string str;
char c;
cout<<"Please enter password:";
while(true)
{
c = _getch();
if(c == 32 || c == 13 || c == 27)
break;
else
{
str += c;
std::cout<<"*";
}
}
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Hi,
I am writing some character bytes in to File using
fprintf(fp,"%c",data);
if data is 26 then while reading it is read as -1,
if other than 26 it is able to read correctly.
What will be the problem?
Any idea?
Regards,
Sunil Kumar
|
|
|
|
|
how is data populated ?
also, how do you read the file back ?
|
|
|
|
|
Hi,
I read using
int c=getc(fp);
until I read the complete bytes.
Regards,
Sunil Kumar
|
|
|
|
|
sunilkumar.d wrote: Hi,
I read using
int c=getc(fp);
until I read the complete bytes.
thanks. and then i ask back my second question, which was :
how do you read back the file ?
just a guess. wouldn't it work better if you write (with fprintf() using the %d parameter rather than %c (as you're handling an int and not a char) ?
also, doesn't fscanf() work better than getc() ?
|
|
|
|
|
Well, good luck Tox.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I did nt try that way.
Actually the code is already written.Now I am maintaining it.
So I did nt change it.
Regards,
Sunil Kumar
|
|
|
|
|
please make tries and use your debugger...if you don't make tries, how can you tell what's wrong !
man, if you're on a maintenance team, it your every day job. you should already be able to have such reflex
|
|
|
|
|
Could this be related with ASCII value? 26 corresponds to substitute, so as toxcct says you would be having some problem with the way you read from the file.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|