|
Hi all,
I've got 8 boolean vars that I have to store. It will obviously be alot more efficient to store these 8 bools as a single byte but I don't know how to go about this task. Does VC++ provide any built in functionality for this or could anyone please tell me how to acheive this task.
Thanks in advance
Richie
|
|
|
|
|
easy
bool b0, b1, b2, b3, b4, b5, b6, b7; <font color=green>
<font color=blue>char</font> c = b0 * 0x01 |
b1 * 0x02 |
b2 * 0x04 |
b3 * 0x08 |
b4 * 0x10 |
b5 * 0x20 |
b6 * 0x40 |
b7 * 0x80;
as you know that to obtain the value of a byte with once bit set to 1, the remaining unset (set to 0), the mask formula is : bn * 2^n
---------------------------------------------------------
| b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
---------------------------------------------------------
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
0x80 0x40 0x20 0x10 0x08 0x04 0x02 0x01
(ps:this was not a managed C++ question to my sense because you can easily convert bool s to boolean s and char s to byte s)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thanks,
I know it's not really a managed c++ question but I needed a quick answer and just posted. I promise I won't be so hasty in the future.
|
|
|
|
|
<?xml version="1.0" standalone="yes"?>
<CDList>
<CDList>
<cdid>11</cdid>
<Name>Halo - Combat Evolved</Name>
<Type>Igre</Type>
<Comment />
</CDList>
</CDList>
Code Snipset:
XmlDocument *xmlCDList = new XmlDocument;<br />
xmlCDList->Load(strCDListFileName);<br />
<br />
XmlElement *nodRoot = xmlCDList->DocumentElement;<br />
XmlNodeList *nodCDListCDID = nodRoot->GetElementsByTagName(S"CDID");
The problem is:
nodCDListCDID->Count is always 0 (zero)
Please help. Thanks in advance.
i think that i have crashed Will you forgave me, because i have crashed the forum
// I have already send email to webmasters
|
|
|
|
|
Saksida Bojan wrote:
because i have crashed the forum
Yes, it appears you have. And I was coming to follow up on another one of your questions, too....
Why use 'GetElementsByTagName' ? I think the 'tagname' is the ID element. Try nodRoot->SelectNodes, with this: "/CDList/CDList/cdid", or this: "//cdid". These are valid xpaths. Why does the CDList node nest a copy of itself ?
Also, XML is case sensitive, if the above code was to work, you'd nee to make "CDID" the same case as in the XML.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks. That helped. But i have still a question.
Why does this one worke. Oh yeah i Have change from cdid to CDID
XmlNodeList *nodCDListName = nodRoot->GetElementsByTagName(S"Name");
PS: First CDList is database, Second CDList is table.
|
|
|
|
|
Saksida Bojan wrote:
Why does this one
Why wouldn't it ? It's correct case.
Saksida Bojan wrote:
First CDList is database, Second CDList is table.
Well, isn't that a little silly ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Now i got werious problems. and i will backtrack. but can you tell me where can i find a good Xml Guide or tutorial.
|
|
|
|
|
I bought SAMS XML Unleashed, it was a good book. MSPress have a good XML book as well.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
The xml File:
<cdlist>
<cdlist>
<cdid>11
<name>Halo - Combat Evolved
<type>Igre
<comment>
Code snipset:
XmlDocument *xmlCDList = new XmlDocument;<br />
xmlCDList->Load(strCDListFileName);<br />
XmlElement *nodRoot = xmlCDList->DocumentElement;<br />
<br />
XmlNodeList *nodCDListCDID = nodRoot->GetElementsByTagName(S"CDID");
Now the problem is:
nodCDListCDID->Count is always 0 (zero)
Can anybody help. And thanks in the advance
|
|
|
|
|
Ain't it cool? Poor ol' Saksida broke the forum, but this post fixes it 'till the Site Admins get around to doin' it up right.
Yeah, i rock...
You must be careful in the forest
Broken glass and rusty nails
If you're to bring back something for us
I have bullets for sale...
|
|
|
|
|
I'm trying to use resetText () to reset values of some text boxes to their default. I'm using it as follows,
<br />
myTextbox->ResetText ();<br />
but all this seems to be doing is clearing the text instead of resetting defaults.
Any ideas???? Because I'm stuck.
|
|
|
|
|
Try Any of these. ResetText it says it will reset Text. Reset functions are listed below.
textBox1->ResetBackColor();
textBox1->ResetBindings();
textBox1->ResetCursor();
textBox1->ResetFont();
textBox1->ResetForeColor();
textBox1->ResetImeMode();
textBox1->ResetText();
if you still haven't found right Function create yourself a function to restore to default.
Example:
void TextBoxResetToDefault(TextBox *txtBox)<br />
{<br />
txtBox->Text = S"";<br />
txtBox->Enabled = true;<br />
}
|
|
|
|
|
I have Form1 And Form2. Form2 is child. It is posible to Send from form1 to form2. But how can i send From form2 to Form1.
|
|
|
|
|
|
I will not use SendMessage, because it is Win32 and MFC Command, I am using .NET Framework.
This thread was posted on Managed C++
|
|
|
|
|
Pass form2 a pointer to form1.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If i pass poitner to Form1, Form1 would have access to form2. This is also working without passing a pointer.
If i pass Pointer of Form1 to Form2 As Form member, i can't accsess public function on form1
|
|
|
|
|
yes you can :
into your form2, you create a member that is a pointer to a form...
then you allow the constructor of form2 to receive a pointer to a form (form1 for example) that will be copied in its member...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Still i can't do it. Here is snipset from a code. Tell me what am i doing wrong.
Form1:
private: System::Void Form1_Load(System::Object * sender, System::EventArgs * e)<br />
{<br />
Form2 te = new Form2(this);<br />
Form2->Show();<br />
}<br />
public: void test()<br />
{<br />
MessageBox::Show(S"Hello from Form1");<br />
}
Form2:
public:
Form2(Form *test)<br />
{<br />
InitializeComponent();<br />
frmTest = test;<br />
}<br />
Form *frmTest;
Form2::
i use
frmTest->test();
i got compiling error
c:\Projecti\t3\t33.h(86): error C2039: 'test' : is not a member of 'System::Windows::Forms::Form'
Please help me.
|
|
|
|
|
Is your first Form called Form ? Or is Form a base class ? If it's a base class, of course you can only see the base class members.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
It supposted to be name Form1. If i use like Form1 *test;. then i get verious errors.
|
|
|
|
|
I had a similar problem. I just created a class that I pointed both forms to and used it to pass information between the forms.
So creat a new __gc class. From form1 create an object of that class. then point it to form2's object.
Pass is the class i'm using to pass information.
Declare Pass *pass
<br />
Pass *pass = new Pass();<br />
Form2 *input = new Form2(); <br />
input->pass1 = pass;<br />
input->ShowDialog();<br />
<br />
label_InputSomthing->Text = pass->somthing;<br />
Invalidate();<br />
<br />
Pass *pass1;<br />
pass1->something = textBox_something->Text;<br />
<br />
Close();<br />
|
|
|
|
|
How Does the Class Pass look like. can i also execute a function in Parent Form. It's easy to pass to Child Form than to Parent Form.
|
|
|
|