|
I've been on a customer's site a lot recently, with internet access on borrowed PCs to check emails, and that's about it.
Rumours of my death have been exagerated.
Sadly, I've only come up for air for only a few days. Then back into hiding...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Hi There,
Thanks for your response.
One more question: I'm using a ListCtrl with the LVS_EX_CHECKBOXES option. Now I get the checkbox in the first column of the list control. Is it possible to move the check box to any other column in the list control?
thanks in advance.
regards,
Rajesh
|
|
|
|
|
Rajesh_Parameswaran wrote: Is it possible to move the check box to any other column in the list control?
Nope!
Doing a search for LVS_EX_CHECKBOXES, it pointed me at the ListView_GetCheckState "function". A search of the headers showed this a macro wrapper around LVM_GETITEMSTATE. Further investigation shows this affects a list item, not a sub item.
Maybe you could use owner draw, detect mouse clicks, and use hit test messages and write your own subclasses list control that has sub-checks, but I doubt it's worth the effort when you have other controls as I described in my last email.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I need to write the ASCII (230) in XML content section using MSXML 4.0.
Premise: XML incompatible with third party tool.
Under MSXML I am converting my string to BSTR (wide char), and it end’s up in the XML file back into the ASCII equivalent. Unfortunately it does not work for the accented characters when in the content section of an element. Instead that part of the string stays in wide-char in the xml file.
This is trouble since the XML file is passed to a third party utility that does not support this wide-char, nor the usual mapping like [& eaccent;] nor a XML header indicating UTF-8 or other.
For example:
I save the string:
<Test>Char é</Test>
It will actually be saved as:
<Test>Char Ç</Test>
Where 'Ç' is an example of some accented char (not necessarily 'é').
Note that you must open the XML in binary to see this. Notepad, Visual Studio or XmlPad all display the accented character fine (they detects the wide char, unlike my third party tool).
If I open the XML using a hex editor to replace the 2 characters by the ASCII # 230, the third party tool works fine.
So my question is: How can I force a char-230 (or other bad char) to actually be into the XML file using MSXML 4.0?
My code to create the XML node:
Example: CreateElementNode( myXmlDoc, "Node_Name", "Test é" );
BSTR AsciiToBSTR( LPCTSTR pszFText )
{
BSTR bsText = NULL;
WCHAR *wszURL = NULL;
int wSize = strlen( pszFText );
::MultiByteToWideChar( CP_ACP, 0, pszFText, -1, wszURL, wSize );
bsText = SysAllocString( wszURL );
free( wszURL );
return bsText;
}
MSXML2::IXMLDOMNodePtr CreateElementNode( MSXML2::IXMLDOMDocument2Ptr pXMLDoc, string sName, string sNamespaceURI )
{
MSXML2::IXMLDOMNodePtr node;
BSTR bsName = NULL;
bsName = AsciiToBSTR( sName );
BSTR bsNamespaceURI = NULL;
bsNamespaceURI = AsciiToBSTR( sNamespaceURI );
VARIANT vtype;
vtype.vt = VT_I4;
V_I4( &vtype ) = (int)MSXML2::NODE_ELEMENT;
node = pXMLDoc->createNode( vtype, bsName, bsNamespaceURI );
return node;
}
|
|
|
|
|
I am not trying to nitpick (honestly ) but there is no char 230 in ASCII. ASCII is a 7-bit encoding and covers only values 0-127.
What you are doing there is basically using the computer's system code page (CP_ACP) which is really a configurable thing, so it may work on your machine, but not on someone else's.
Anyway, Ç is just a UTF-8 representation of your accented character. UTF-8 is the default encoding for XML files. If the 3rd party tool does not recognize UTF-8, you'll need to explicitelly save your XML document in the encoding it will recognize. Also, you'll need to insert the "encoding" instruction accordingly.
|
|
|
|
|
“you'll need to explicitelly save your XML document in the encoding it will recognize”
That’s what I am trying to do, here is an example in binary: (the HEX values are almost random, not sure if they map to an actual accented char).
I have the string: “54, 65, 73, 74, 3a”
The BSTR becomes: “54, 00, 65, 00, 73, 00, 74, 00, 3a, 00”
The XML file opened in Binary is: “54, 65, 73, 74, 00, 3a, 00”
So a mix of ASCII and Wide Char (???). If I replace (manually) “74, 00, 3a, 00” by “74, 3a” then all is fine.
Certainly their must be a way to force the “extended” chars to be re-mapped like all other chars? Is that what you mean by “you'll need to insert the "encoding" instruction accordingly”? But how can I do this thru MSXML?
|
|
|
|
|
You really just need to add the processing instruction to specify the correct encoding, and MSXML will save it correctly.
For the details on how to do it, take a look at this MSDN article[^]
|
|
|
|
|
I already tried to no avail. The solution indicated is to add a header like
but the third party tool does not support this. If the line is present the tool craps on me.
=> Saving the character "E9" (é) it becomes "E9 00" in BSTR (no problem) but MSXML writes "C3 A9" in the actual XML file.
Why is it doing this at all?
Then if I edit the XML to replace "C3 A9" for "E9" everything works!
How can I force MSXML to write "E9" (what I pass to it) instead of translating my "E9" into "C3 A9"?
|
|
|
|
|
So if I understand you correctly - if you add the processing instruction encoding='ISO-8859-1' , MSXML outputs just E9 and not C3 A9, but the third party tool crashes? If that is the case, it is really the problem with the tool - MSXML's output is good.
Having said that, if you want to get output encoded as windows cp1252 or ISO-8859-1 (still not sure what you mean by 'extended ascii' - there are numerous encodings that extend ascii) without the processing instruction, one way I can think of is to write your XML document to a temp UTF-8 file and then convert that file from UTF-8 to Windows CP 1252 (or whatever encoding you really want) in a separate step. Just remember - this will actually be an invalid XML file (because it lacks the processing instruction), but this tool may be happy with it.
|
|
|
|
|
A reply to myself for does not followingthe secondary thread:
=> Saving the character "E9" (é) it becomes "E9 00" in BSTR (no problem) but MSXML writes "C3 A9" in the actual XML file.
Why is it doing this at all?
Then if I edit the XML to replace "C3 A9" for "E9" everything works!
How can I force MSXML to write "E9" (what I pass to it) instead of translating my "E9" into "C3 A9"?
|
|
|
|
|
OK, so now I know that C3 A9 is the UTF-8 for my extended ascii. What I need to know is how to force MSXML to write extended ASCII, without writing the at the start of the page (if present the external tool crashes).
|
|
|
|
|
Dear all,
How can I be notified of date changes in vc? my program wants to know whether the clock is passed 00:00 or not. It should create a folder for each new day while it's running.
|
|
|
|
|
Can you explain what you want to do and which folder you want to create.
If you want to create folder with date e.g Folder_MM_DD_YY
Then why you need date change notification.
Everytime you need to create/access the folder you can take system date check if folder exists fro that date and create if it doesnt exist.
I hope you are getting my point.
Regards,
Sandip.
modified on Wednesday, June 25, 2008 9:55 AM
|
|
|
|
|
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;
}
|
|
|
|
|