|
Joan Murt wrote:
hope this helps.
I never asked a question!
All I had to do was prevent one app from being closed. Task Manager was disabled by system policies, so all I had to do was prevent Alt+F4 and Escape (it was a dialog app). Setting a system-wide keyboard hook would have been massive overkill.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I was under the impression (according to my programming book) that a left shift on a byte caused the bits on the left to "fall off" and zeros inserted to the right:
eg. 0x1F << 2 = 0xC0
but it equals 0x7C0
Why is this?
My reason for asking this question is that I am trying to find a four byte sequence within a file (MPEG-1) that doesn't seem to byte aligned. I wrote a little function to do a "bit by bit" search but since the above statement is not true it fails, here is my code (I feed it 64 bits at a time):
int FindSequenceHeader(unsigned char *str)
{
char ch[4];
DWORD dwValue;
for (int x = 0; x < 4; x++)
{
for (int i = 0; i < 8; i++)
{
ch[0] = ( (str[x + 0] << (0 + i)) | (str[x + 1] >> (8 - i)) );
ch[1] = ( (str[x + 1] << (0 + i)) | (str[x + 2] >> (8 - i)) );
ch[2] = ( (str[x + 2] << (0 + i)) | (str[x + 3] >> (8 - i)) );
ch[3] = ( (str[x + 3] << (0 + i)) | (str[x + 4] >> (8 - i)) );
dwValue = ( ch[0] | (ch[1] << 8) | (ch[2] << 16) | (ch[3] << 24) );
switch (dwValue)
{
case 0x000001b3:
cout << "Video Sequence Header Found" << endl;
return 0;
break;
default:
break;
}
}
}
return 1;
}
which then leads me to ask why this standard routine i've seen in many sample codes works:
DWORD MakeDword(unsigned char *str)
{
return ( str[0] | (str[1] << 8) | (str[2] << 16) | (str[3] << 24) );
}
any thoughts?
|
|
|
|
|
georgiek50 wrote:
eg. 0x1F << 2 = 0xC0
but it equals 0x7C0
georgiek50 wrote:
Why is this?
Because it is the right answer.
0x1F = 0001 1111
shift it left a coupla times and put zeros in on the right
0111 1100 = 0x7C
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = A
1011 = B
1100 = C
1101 = D
1110 = E
1111 = F
cheers!!
Adam.
My world tour
What I do now..
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
georgiek50 wrote:
I was under the impression (according to my programming book) that a left shift on a byte caused the bits on the left to "fall off" and zeros inserted to the right:
eg. 0x1F << 2 = 0xC0
but it equals 0x7C0
That's not the right answer. 0x1F << 2 = 0x7C.But in any case to ensure that you receive only the last 8 bits you can AND a byte with 0x0FF. For example:
char[ 0 ] = 0x1F;
DWORD dwVar = char[ 0 ];
dwVar = (dwVar << 2) & 0x0FF
georgiek50 wrote:
dwValue = ( ch[0] | (ch[1] << 8) | (ch[2] << 16) | (ch[3] << 24) );
The compiler will get each character in ch and store it into a register because that's the only place where shift operations can be performed. For example if you would see the above code written in machine language it would look like this:
mov eax, ch[0];
mov edx, ch[1];
shl edx, 8;
or eax, edx;
mov edx, ch[2];
shl edx, 16;
or eax, edx;
and so on....
The final result in eax will be moved to a dword ptr memory location that corresponds to dwValue. All the registers are 4 bytes long (32 bits) and a DWORD data type is a 32 bit unsigned integer. That's why this works.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Sorry, what I meant to write was 0x1f << 6 (instead of 2)= 0x7c0 where I was expecting just 0xc0 according to this logic:
<br />
0x1F = 00011111<br />
0x1F << 6 = 11000000 or 0xC0<br />
I think my understanding of shifting is very off!
|
|
|
|
|
The compiler assumes it as a 16-bit number. So,
0x1F = 0000000000011111
0x1F << 6 = 0000011111000000 = 0x7C0.
So, for 8 - bit operation may be u can write as
unsigned long a = 0x1F;
a=LOBYTE(a<<6);
It gives the desired result....You can fit it into your program...
Harsha
----------------------------------
http://www.ece.arizona.edu/~hpg
----------------------------------
|
|
|
|
|
Thanks...and you clarified for me what hi and lo - byte means, I was wondering about that for some time!
|
|
|
|
|
Be aware that:
a) Bytes get int-expanded when shifting things around
b) char, int etc. are signed - which makes the shift "arithmetic", i.e. the highest order bit remains set.
So a) use unsigned char, and b) cast th shift result back to unsigned char.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Hello,
where can i get "tom.h". I have visual studio 6.0 enterprice eddition and sp5. but there is no such file.
Thanks in Advance to solve this problem.
Thank you
Asad Rasheed
|
|
|
|
|
Download the Platform SDK.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi , I wanted to know what is the function that detect a radio button is detected
example : in A Wizard the next button is disabled
what'is the function that enable the next button if a radio is checked.
Please Help,
Thanks
Bye
|
|
|
|
|
If you are using MFC then using classwizard, assign a member variable to the first radio button in the group.
Then, handle the BN_CLICKED message for each radio button in your group. Check the state of the member variable (having called UpdateData()). If it the right value then enable your Next button.
hope this helps
Adam.
My world tour
What I do now..
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Or, just give each radio button a unique id. (IDC_RADIO1, IDC_RADIO2) Then, you can map a OnClick handler for the ID and no member variable is required. In your handler, you can always ask the button whether it is checked or not as follows:
<br />
void MyClass::OnRadio2Clicked()<br />
{<br />
BOOL bChecked = SendDlgItemMessage(IDC_RADIO2,BM_GETCHECK);<br />
<br />
if (bChecked)<br />
else<br />
}
onwards and upwards...
|
|
|
|
|
I am developing an application in MFC, using the Microsoft Web Browser control, embedded in a CFormView. I have two specific questions related to using the browser control:
1) How do I retrieve the HTML text that is currently being displayed in the web browser? Specifically, when the OnDocumentComplete message fires, I would like to retrieve the HTML currently in the browser, and do some custom parsing on it.
2) None of the standard accelerator keys (ctrl-c, ctrl-v, etc.) work when the web browser control has focus. The only way I can perform these standard operations is to use the context menu (right-click), which is somewhat time consuming for many users.
Thanks in advance!
Brian
|
|
|
|
|
see this
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/commandids.asp
|
|
|
|
|
Thanks, I will check it out.
|
|
|
|
|
1) Try GetouterHTML().
2) In an app I'm slowly working on I grab the keystrokes in Javascript code embedded in the page and send them back to my C++ code.
For an excellent resource on this subject see:
http://www.beginthread.com/Topic/MSVC[^]
Hope that helps.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
I don't see 'GetouterHTML' as a member of the HTML browser class that was generated for me when I added the browser control to my project.
I will take a look at the URL you posted - thanks.
Brian
|
|
|
|
|
Sorry, that was me.
Please respond to *this* post, so I will get an email notification.
Sorry.
|
|
|
|
|
knappbl wrote:
I don't see 'GetouterHTML' as a member of the HTML browser class that was generated for me when I added the browser control to my project.
It is a member of IHTMLElementPtr. eg.
MSHTML::IHTMLDocument2Ptr pDoc( GetHtmlDocument() );
MSHTML::IHTMLElementPtr e;
if ( e != NULL )
{
e = pDoc->Getall()->item( _T("mybody") );
TCHAR szBuff[ 50000 ];
strcpy( szBuff, e->GetouterHTML() );
....
}
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Yeah... How do you get the Icon of a Window? any help would be appreciated
But unfortunatly... The Big Red Boat had Cerebal Palsy...
|
|
|
|
|
I'm sure that there there is an article in CP that get icon and images from files. But I don't have the link now,so search this site.
Mazy
No sig. available now.
|
|
|
|
|
|
Hi,
I use CImage class to read and display an image from file and I do this in OnDraw(CDC *pDC).
How can I cache this image because I don't wanna read it from file whenever OnDraw is called?
thank u in advance.
|
|
|
|
|
Hello,
I've created a program which is waiting for incoming network connections via I/O Completion Ports and I've created a pointer in the network class to a packet processing class which's object is created outside of the class on the heap memory.
All the things worked fine, but I got an error. No compiler or linker error - no error at all, but GetQueuedCompletionStatus() doesn't receive completed packets, when I add a specific number of bytes (in variables) in the Packet Processing Class. What's this??? Memory problems? Other problems? The Processing Class do nothing - an object of it is just created - that's all and the Packet Processing class has no relation to the Thread Function which is call the GetQueuedCompletionStatus() function.
I can only add a WSABUF variable plus 3 bools and 1 short. That's all.
What do you think is the error?
Thanks for your attention and your help,
bond006
|
|
|
|