|
|
|
Your welcome
Regards,
Brian Dela
|
|
|
|
|
After you get a little familiar with MFC, definitely check out MFC Internals.
|
|
|
|
|
Hi Gang,
I was just wondering if anybody has a vertically aligned Cedit control out there.
Thanks,
Nick
|
|
|
|
|
Anybody know of a class to just validate an XML Document. I don't need to read or write to an XML file. Just validate it.
Any ideas?
Regards,
Brian Dela
|
|
|
|
|
Brian,
The Xerces (XML4C) parser is small, fast and free. I chose it over (ugh) MSXML.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
What is 0x0a and 0x0d in programming? What does it do?
Mark J Jackson
|
|
|
|
|
in what context ?
all alone like that, they are hex values
0x0a = 10 (decimal)
0x0d = 13 (decimal)
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
that mean carriage return and line feed (\r and \n).
onwards and upwards...
|
|
|
|
|
Hello,
I was just wondering if anyone else was getting this type of error.
Basically, in the last little while I have created my own versions of two common Windows controls and I would like to put them all in one project. My first control was a masked text box and everything work fine except that I would lose certain properties that I set in design after I compiled. For example, I had a "Mask Type" enum property that could be set at design time but when I ran the program and I went back to Visual Studio (while the program was still running) the "Masked Type" property would reset to its default state. The program ran properly the first time with the masked type but as soon as I closed it and ran it again, it would use the default value that it had been reset to. This problem frusterated me to no end as I couldn't do anything to save that property but I did narrow it down to that fact that it was because the property was an enum type. As a result, I found that if I moved that enum type to a different class, it would save properly and I could finally move on (although not as happily as I would have hoped). Recently, I have created a customized tab control that would allow me to change the style and colours of the pages. Again everything seemed to work fine but as I neared completion, I noticed that the design view was again not saving the changes that I was making in it after I had compiled. This time is was the pages collection that was losing its settings. Again, if I moved the collection outside of the class and into it's own class, the design time properties saved properly and I could use it normally.
My question is: Does anyone know what I am doing wrong (or possibly doing wrong) Has anyone had this problem with the designer and if so, how did you fix it. I would appreciate any and all help that I could get in this matter. Thanks in advance.
Cheers,
Mike
|
|
|
|
|
Excuse me if this question is really basic, I'm pretty new to C++ programming --
What is the difference between these two ways of declaring the value of a char data type?
Method 1 --
char myvar[21] = "text";
Method 2 --
char myvar[21];
myvar[21] = "text";
The second method seems to cause problems with my compiler (Dev-C++) when used in certain situations. I sometimes receive the error "assignment to 'char' from 'const char *' lacks a cast."
|
|
|
|
|
yashraj1215 wrote:
char myvar[21];
myvar[21] = "text";
The second method seems to cause problems with my compiler (Dev-C++) when used in certain situations.
It's actually problematic in all situations. What is says is that the 22nd "position" of myvar points to "text", but since myvar only has 21 characters (0-20) to begin with, whatever happens to follow myvar in memory is being stepped on.
|
|
|
|
|
yashraj1215 wrote:
myvar[21] = "text";
this pasically is saying
put "text" into the myvar at position 22
Remember that char myvar[21] has 21 characters accessed by myvar[0] to myvar[20]
Hoep this helps.
Regards,
Brian Dela
|
|
|
|
|
yashraj1215 wrote:
char myvar[21] = "text";
This means "myvar is an array of 21 char s, and initialize the first five elements to the characters 't' 'e' 'x' 't' '\0' "
yashraj1215 wrote:
char myvar[21];
myvar[21] = "text";
This is incorrect code, that's why it doesn't compile. It's trying to assign an array of characters to one element in a character array.
It is also overrunning the array bounds. The elements are myvar[0] thru myvar[20] . Storing something in myvar[21] will overwrite other data.
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I have successfully created a program to edit the value of a key in the registry... finally! However, I still have a few questions about my code.
The following is one of the lines in my code:
RegSetValueEx(hKey, TEXT("LegalNoticeCaption"), 0, REG_SZ, (LPBYTE) mycaption, 51);
I used this code to set the value of the LegalNoticeCaption key to the value of mycaption, a previously declared char.
Question 1 --
I do not understand what purpose "(LPBYTE)" serves in this code; the code will not compile without it. I found "(LPBYTE)" in the MSDN library, but it never explained what it does or what it means... does anyone know?
Question 2 --
The last parameter of the RegSetValueEx function is supposed to be the size of the buffer. Is the buffer size equal to one byte per character?
Question 3 --
What is the difference between a signed char, an unsigned char, and a char? What are their individual purposes?
Thanks for your help.
|
|
|
|
|
I start with #3
#3 signed char and char are the same thing
unsigned char and BYTE are the same. char being an integer data type needs unsigned version.
#1 since unsigned char has smallest size(1 byte) it is usually used to pass data buffers
LPBYTE == unsigned char*
#2 this one is tricky
for strings its == sizeof(TCHAR) * strlen
|
|
|
|
|
Thanks for replying! But I have questions about your response.
1) Does LPBYTE automatically allow the use of an unsigned char version of "myname," which was preiously declared as a char?
2) What is TCHAR?
Thanks again.
|
|
|
|
|
yashraj1215 wrote:
2) What is TCHAR?
It is a Win32 character string data type that can be used to describe ANSI, DBCS, or Unicode strings.
|
|
|
|
|
1. not automatically, but using static_cast or old C cast. The idea here is that any datatype could be treated as array of bytes in memory (arguably smallest unit allowed in C++) example "int" datatype occupies exactly the same space in memory as "unsigned char[4]". It is more convention than a rule of C/C++.
2. TCHAR is a Windows convention when you compile ANSI it converts to "char" (1 byte), when you compile UNICODE it compile it converts to wchar_t (2 bytes). Therefore, when you deal with string sizes in bytes it is important to remember size of the basic unit (1 or 2 bytes)
|
|
|
|
|
yashraj1215 wrote:
I do not understand what purpose "(LPBYTE)" serves in this code; the code will not compile without it. I found "(LPBYTE)" in the MSDN library, but it never explained what it does or what it means... does anyone know?
While you did not indicate, I would imagine you have mycaption defined as a char, rather than a BYTE. For example, using:
LPBYTE mycaption = "Some Caption Here";
or
BYTE mycaption[32] = "Some Caption Here";
you could have called RegSetValueEx() like:
RegSetValueEx(hKey, TEXT("LegalNoticeCaption"), 0, REG_SZ, mycaption, _tcslen(mycaption) * sizeof(TCHAR));
yashraj1215 wrote:
The last parameter of the RegSetValueEx function is supposed to be the size of the buffer. Is the buffer size equal to one byte per character?
Yes, unless you are dealing with DBCS (i.e., Unicode). In that case, every character uses two bytes.
yashraj1215 wrote:
What is the difference between a signed char, an unsigned char, and a char? What are their individual purposes?
A char and signed char are the same thing (i.e., they use the sign bit). If a type does not have the unsigned qualifier, it is assumed signed.
yashraj1215 wrote:
What are their individual purposes?
It actually depends on what you are storing. ASCII characters (0-127) can be stored in a char, whereas extended ASCII (0-255) must use an unsigned char.
|
|
|
|
|
um, i was thinking of writing a server for something and suddenly something bothered me, like this:
If you have a router between your network and the internet that has a built in firewall, and you have lets say.. port 3000 open, and someone tries to establish a tcp connection with your computer on the network... a syn packet will be sent to the ip address of your internet connection, so it arrives at the router, and the router sees its destined for port 3000 and lets it pass..but then, what if two computers on the network both have their port 3000 listening.. how does it know which should reply, or for what computer the connection was ment???? I'm sure the sollution is pretty simple but i just couldn't think of it, and its bugging me.
Kuniva
--------------------------------------------
|
|
|
|
|
You have to explicity tell the router that an incoming port 3000 get routed to port 3000 on that computer. If you make a connection outbound, then there is information there to route the response back to you. It can't magically determine where an inbound port is routed to.
Joel Lucsy
|
|
|
|
|
Standard port forwarding...
onwards and upwards...
|
|
|
|
|
erm...right. But the thing is, our router uses DHCP, so one time my PC will have this ip, the other it will get another assigned. So you see, i can't specify a forewarding ip address.... (btw i'm not administering our router due to technical restrictions, otherwise i'd know all this)
Kuniva
--------------------------------------------
|
|
|
|