|
koumodaki wrote: Is this correct?
Shouldn't you be answering that question? Does the code compile? Does it produce the expected results?
koumodaki wrote: I am not able to get the Handle to window to the Property Sheet
So if GetActiveWindow() is not returning the correct handle, why bother calling PropSheet_GetCurrentPageHwnd() and SetDlgItemText() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hello !
I have some hexadecimal data, say
0x0A, 0x1F, 0x33 ...
Now what is the easiest way to caculate 2's complement of the above?
i know the procedure:
add all the numbers in binary fomat, take ones complement , add 1 to it.
but how to add them in binary format ??
Thanks !
|
|
|
|
|
If you want to calculate it in 32bit, you just use shift and or operator.
BYTE b[] = { 0x0a, 0x1f, 0x33, ... };
DWORD value = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3])
or
DWORD value = 0;
for(int i=0; i<4; ++i)
{
value <<= 8;
value |= b[i];
}
|
|
|
|
|
kapardhi wrote: Now what is the easiest way to caculate 2's complement of the above?
kapardhi wrote: add all the numbers in binary fomat
I don't understand. You want to add all the numbers and then calculate 2's complement ? Or you want to calculate the 2's complement of each number ?
kapardhi wrote: but how to add them in binary format ??
There's no such thing as a binary number. A number is a number and is independant of the way you represent it. If you have integers, then those are integers. You can display them to the user in decimal format, binary format, hexa format, ... but the integer values are still the same.
|
|
|
|
|
If I got you then you need the two's complement of the sum (without considering overwerflow) of the numbers, i.e. some sort of checksum. Hence (supposing, for instance, a 16-bit sum):
unsigned short chks = 0;
unsigned char data[] = { 0x0A, 0x1F, 0x33};
for (int i = 0; i < sizeof(data) / sizeof(data[0]); i++)
{
chks += data[i];
}
chks = ~chks;
chks++;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The standard C operators work in 'binary' format. Also, unary minus is a 2's complement..so:
<code><pre>int nums[3] = {0x0A, 0x1F, 0x33};
int sum = 0;
for(int i=0;i<3;++i)
{
sum += nums[i];
}
int twos_complemented_sum = -sum;
</pre></code>
|
|
|
|
|
Stuart Dootson wrote: int twos_complemented_sum = -sum;
I don't think this is quite right. You first have to negate each bit of sum and then add 1.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Read this[^]. On an x86 architecture (and pretty much all other processors), negative numbers are represented using *2s complement*. Which means that the 2s complement of a number can be determined by applying the negation operator.
|
|
|
|
|
Stuart Dootson wrote: ...by applying the negation operator.
To each bit, not the whole number.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Do some simple examples with bit-patterns (the page I pointed you at had some examples using 4-bit numbers).
There's a difference between numeric negation (- ) and the bit-wise operator (~ ). ~ does indeed just invert bits, while - performs numeric negation, which does that and then adds one to the number - that'll be the 2s complement of the number you first thought of.
|
|
|
|
|
Perhaps the difference is sign and magnitude vs. two's complement.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
i want to integrate ms word in my asp.net web application like i want to use the ms word tools in my asp.net web applicaiotn like " bold, italic, alignment doc save...etc
plz help me its very urgent
Thabkx in advance
uniq_vyas@yahoo.com
|
|
|
|
|
You do realize there is an asp.net forum, right?
|
|
|
|
|
Well do you think your question has c++ answer?
|
|
|
|
|
Hi all,
I have a form,in that i have a static label ..i want to make it italic...as in c# we have a property in font section .. but i didnt find it in VC++,now onit screen i have to make it italic can any budy help me..
i googled it and find a link in code project .. but there is no source code for that ...
please help me here ....
vikas da
|
|
|
|
|
You can use of CreateFont(....DWORD fdwItalic,// italic attribute option,...) and then use of <code>SetFont for set font to your control.
|
|
|
|
|
can you please tell me how to set the font to my text..
CFont font;
font.CreateFont(16,0,0,0,FW_BOLD,TRUE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,"Tahoma");
i can have my static text like GetDlgItem(IDC_STATIC10);
can you help me again please...
vikas da
|
|
|
|
|
GetDlgItem(IDC_STATIC10)->SetFont(&font);
|
|
|
|
|
Hi. This Error is make me crazy please helpme.
I dont know where ir the IID_IADsUser
Thanks
ompiling resources...
Compiling...
StdAfx.cpp
Compiling...
ADFind.cpp
D:\Erith\PROGRAMING C++\ADFind\ADFind.cpp(45) : warning C4101: 'bstrName' : unreferenced local variable
Linking...
ADFind.obj : error LNK2001: unresolved external symbol _IID_IADsUser
Debug/ADFind.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
ADFind.exe - 2 error(s), 1 warning(s)
|
|
|
|
|
Please consider the following declarations:
class base1 {<br />
public:<br />
virtual int f1() = 0;<br />
};<br />
<br />
int<br />
base1::f1()<br />
{<br />
return 1;<br />
}<br />
<br />
class dev1 : public base1 {<br />
public:<br />
int f1();<br />
};<br />
<br />
int<br />
dev1::f1()<br />
{<br />
return 2;<br />
}
Since the class base1 cannot be instantiated, is there anyway to call base1::f1()? If so, please tell me how?
Thanks
Bob
|
|
|
|
|
what about calling the base class in the derived method of f1 ?
int dev1::f1()
{
return base1::f1();
}
This signature was proudly tested on animals.
|
|
|
|
|
Thanks for the response and your response works. I just checked it. I should have thought of that myself.
Bob
|
|
|
|
|
Yes! You could call it by using the pointer of derived object. For instance,
dev1* pDerived = new dev1;
pDerived->base1::f1();
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi everybody...
this is my first question here,... hope someone can help me!
I have following problem: I have programmed an own file transfer protocol for a network,
but i do not check the rights for accessing directories; the groups are organized with active directory, so i need to check if the user is allowed to access the directory, which he requested.
I have never worked with active directory before, so i am a absolutely newbie!
But i am learning fast, so if someone could tell me how to get the directorie's, which the logged on user is allwowed to access i would be proud of it!
You could also also help me, by answering this question:
How can I read the yet blue database, so i could read the active directory database and check it with a own function... But mybe someone knows a better way to solve my problem,...
If you do so please answer this question!
Greetz BI0sSt@R
|
|
|
|
|
Hi folks,
I'm in a bit of a pickle here. I have been working on a dll that runs in debug and also runs in release mode when the executable is started from Visual Studio, but it causes a crash when invoked from the command prompt.
I have did my homework and read a lot of useful information on this site as well as others but failed to find the culprit.
I can go as far as dumbing down the code so much that commenting a single line makes it run. I'm using a map container.
I can also post the header file, but first I thought that someone might be able to offer some insight about map containers gotchas...
Here is the code:
typedef std::map<int,> ObjectMap;
ObjectMap s_objectMap;
CLINKAGE
DLLFUNC void STDCALL SOMEFUNCTION(int *id, int *init)
{
ObjectMap::const_iterator it = s_objectMap.find(*id);
if (*init)
{
if ( it == s_objectMap.end())
{
int ti = (int)s_objectMap.size()+1;
mbdObject *pTheObject = new mbdObject(ti, id);
}
}
}
basically if I comment out the creation of the new object the code would not do anything useful but it would run. As soon as the 'new' operator is back in. BOOM....
Any help *greatly* appreciated!
Andrea.
|
|
|
|