|
Tried with an example the way you have explained. its working fine for me.
|
|
|
|
|
Could it be that the parent of your second modal dialog is your main window rather then the first modal dialog?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
manohar_balu wrote: another modal dialog using DoModal() function. When I open the dialog (modal) from the parent modal dialog, it opens fine. But when I click on the Parent modal dialog I am able to gain focus on the Parent modal dialog which is not supposed to be.
Is this the problem?
http://www.codeproject.com/KB/dialog/notmodaldialogs.aspx[^]
|
|
|
|
|
NOTE: I'm using an "Intel" machine to test the following codes.
I have an array of 48 Bytes named aArray and as you know it looks like some thing like this in memory:
100011011001110110110101 ...
Now, I want to separate six-bit chunks from the begin, useing bit fields as the follow:
struct CHUNKS
{
unsigend __int32 FirstChunk:6;
unsigend __int32 SecondChunk:6;
unsigend __int32 ThirdChunk:6;
unsigend __int32 FourthChunk:6;
}*pChunk = NULL;
for(int iCountor=0; iCountor<48; iCountor+=3)
{
pChunk = (CHUNKS*) (aArray + iCountor);
...
}
What I expect is this:
Suppose aArray = 10001101 10011101 10110101 ...
and Say iCountor is equal to 0 at the moment.
pChunk->FirstChunk ... pChunk->FourthChunk should be as follow:
100011 011001 110110 110101
But that's not the case! pChunk->FirstChunk ... pChunk->FourthChunk are as follow:
pChunk->FirstChunk is equal to 001101 as follow:<br />
10<big>001101</big> 10011101 10110101<br />
<br />
pChunk->SecondChunk is equal to 110110 as follow:<br />
<big>10</big>001101 1001<big>1101</big> 10110101<br />
<br />
pChunk->ThirdChunk is equal to 011001 as follow:<br />
10001101 <big>1001</big>1101 101101<big>01</big><br />
<br />
pChunk->FourthChunk is equal to 101101 as follow:<br />
10001101 10011101 <big>101101</big>01
As you can see and I guess, no body can make anything of this situation.
Thank you masters!
|
|
|
|
|
Please read about LSB und MSB this is also to tricky for me.
Greetings from Germany
|
|
|
|
|
the struct CHUNKS, i guess will require no more than 24 bits, i.e one single unsigned int(32 bits = 4 bytes) will be enough.
give a try for this one,
CHUNKS st;
memcpy(&st, aArray, 4);
pChunk = &st;
now try to access
pChunk->FirstChunk & pChunk->FourthChunk
|
|
|
|
|
Due to bit alignment in bytes, I think you cannot avoid a bit of bitwise manipulation.
For instance
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
unsigned char aArray[]={0x8D, 0x9D, 0xB5, 0xFE, 0xDC, 0xBA};
unsigned char bChunk[4];
cout << setbase(16);
for(int iIndex=0; iIndex<6; iIndex+=3)
{
bChunk[0] = aArray[iIndex] >> 2;
bChunk[1] = (aArray[iIndex] << 4) & 0x3F | aArray[iIndex+1] >> 4;
bChunk[2] = (aArray[iIndex+1] << 2 ) & 0x3F | aArray[iIndex+2] >> 6;
bChunk[3] = aArray[iIndex+2] & 0x3F;
cout << (int)bChunk[0] << " " << (int)bChunk[1] << " " << (int)bChunk[2] << " " << (int)bChunk[3] << endl;
}
}
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]
|
|
|
|
|
Like you, this behaviour seems a little unintuitive to me. Intel chips are little-endian (i.e. least-significant bytes first), but I thought that within a byte, a bit-field would extract the most significant bits first. Obviously not - as documented[^], Microsoft treat bytes as least-significant bit first as well.
Your only way round this is to do some bit manipulation yourself - the easiest way is probably to use bit-fields to extract the bits and glue them together again in methods of the struct - something like this:
struct CHUNKS
{
unsigned int FirstChunk() const { return firstChunk; }
unsigned int SecondChunk() const { return (secondChunkMSB<<4)|secondChunkLSB; }
unsigned int ThirdChunk() const { return (thirdChunkMSB<<2)|thirdChunkLSB; }
unsigned int FourthChunk() const { return fourthChunk; }
private:
unsigned int secondChunkMSB:2;
unsigned int firstChunk:6;
unsigned int thirdChunkMSB:4;
unsigned int secondChunkLSB:4;
unsigned int fourthChunk:6;
unsigned int thirdChunkLSB:2;
}*pChunk = NULL; This does give the expected results for your test data.
|
|
|
|
|
What is the relevance of these code in C#? Thanks
unsigned char HartSendBuffer [200];
memset(SendBuffer,'\0',sizeof(SendBuffer));
|
|
|
|
|
sorry, they are should be :
unsigned char SendBuffer [200];
memset(SendBuffer,'\0',sizeof(SendBuffer));
|
|
|
|
|
an82 wrote: What is the relevance of these code in C#?
It is the relevance that C code has to C# language...
BTW: What about documentation [^]?
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]
|
|
|
|
|
are you using unmanaged programming in the C#. anyways it make whole sendbuffer to zero!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I have created modal dialog using DoModal() function. But my dialog loses focus when I click on the Parent dialog. How to prevent this..?
|
|
|
|
|
manohar_balu wrote: How to prevent this..?
By using Spy++ to see what window the dialog is modal to.
"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
|
|
|
|
|
Hi All
How can i check file is Exists or not?I am creating a file but before create a file i want to check File name is exists or not.Plz help me
|
|
|
|
|
|
You can use of FindFirstFile .
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
if you find a file you got to close the handle.
Greetings from Germany
|
|
|
|
|
Sure!
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hamid. wrote: Sure!
hummm
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
ccpptrain wrote: _taccess()
good! but i think, if i use it, it will increase my dependency on C runtime library. though they are fast but more error prone so beware while using it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
How to create a custom list control in MFC which has following implemented :
Multicolumn sorting(time , text , numbers) .
Column coloring and dragging .
Set cell padding.
Subitem editing .
Please provide me with the code for the custom list control.
|
|
|
|
|
Is this[^] helpful?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|