|
I don't have any links for this, sorry, but your google is as good as mine.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
If you really want to retrieve a full string from some code, then what you need is a compression algorithm, not a CRC code.
If you just want to be able to correct a bad bit or something like that, you still need something else than CRC. CRC has a 'hamming distance' of 10, meaning you can compare the value to the one you expect and decide if your input is correct, but you cannot determine what is wrong, nor how to correct it, and you can not unambiguously retrieve the original input. You can construct a hash code with a greater hamming distance that would enable you to fix up to a given number of bad bits, but the algorithms to do that are quite complex. Search for 'hamming distance' and 'coding theory' if that is what you're after.
P.S.: I just realized that the statement 'if you just want ...' above was in fact quite wrong, since to achieve a code with a hamming distance of 1 already implies you have a full compression algorithm and can retrieve the string from the code. Being able to correct a flawed encoded string requires a compression with extra information attached, meaning this is an extension to normal compression.
|
|
|
|
|
The better question might be, "How can I get rid of this dependency?".
I'm finishing testing on another developer's project who doesn't know himself how he got his application dependent on the FM20.dll and FM20ENU.DLL. Looking online I found that these are Microsoft forms 2.0 controls. Is there a way to check the resources or the project, for 2.0 controls? Since, these are not redistributable and the application is not dependent on anything that MS Office might have installed (as far as we know), I want to get rid of this dependency but simply removing the dlls from the application's installation directory is not going to solve this problem. I need to know why the application is dependent on them.
Is there certain 2.0 API type calls that I can search on within the project? Or something inside of the IDE itself that I can check?
modified on Tuesday, March 29, 2011 3:24 PM
|
|
|
|
|
In VC6, the two ways that a project links to a DLL is:
1. It includes some .h header file, and that has a statement like
#pragma comment(lib, "bozo.lib")
2. It links directly by specifying the .lib file explicitly in the Linker options.
|
|
|
|
|
Thanks, Hans. I've never used the #pragma comment lib directive. I've checked for both and there are no inclusion to those libs. The only thing it may be, and I will have to check first, is that he includes explicitly two libraries, that he created, in the Linker options. Perhaps, one or both of those library projects use the forms controls.
|
|
|
|
|
Okay, checking for a linked library in a library project when none will exist makes sense. I don't know what I was thinking. But it didn't have any #pragma comment(lib,...) directives in the two libraries either.
FYI, I finally found the answer by viewing the .rc resource file. It seems that a GUID exists, because the Forms Controls (is a COM object or OLE server?), for each of the controls that were used within the project. Found 4 GUIDs, one image, one text box, and two labels. Now have to replace them. Apparently they were used because the items all needed image backgrounds.
|
|
|
|
|
I have a Dialog that has many controls on it. It has multiple ComboBoxes that I have calling the same function when an item is selected in them. I am using CBN_SELCHANGE that calls my function. To get the ID of the control that was changed, I use:
CWnd *pwnd = GetFocus();
crtlid = pwnd->GetDlgCtrlID();
but the ID that is returned is always 1001 and is not the ID of any of the ComboBoxes - they start at 1454 in the resource.h file. None of the controls on the dialog has the ID 1001 so I am confused to what has the focus. Does anyone know what I am doing wrong. I am using VC++ 2005 for a Dialog based MFC application , and using MFC as a static library. Any help would be appreciated - Thanks in advance!
David
|
|
|
|
|
|
Thanks for the help - I will have a look and see if I can figure it out. I did find a way to make it work - In the properties I had the Type set as a Dropdown which I think lets you type in new entries in the EditBox - what has the focus must be that EditBox. If I change the Type to a DropList - fixed list, then when GetDlgCtrlID() runs, I get the ID that I am looking for. Thanks for the help again!
David
|
|
|
|
|
that's interesting... well, glad you have your code working
|
|
|
|
|
GetFocus returns a temporary CWnd, I don't know what the ID of that should be.
it might be that.
Watched code never compiles.
|
|
|
|
|
Thanks for the help. I did find a way to make it work - In the properties for the ComboBox, I had the Type set as a Dropdown which I think lets you type in new entries in the EditBox - what has the focus must be that EditBox. If I change the Type to a Drop List - fixed list, then when GetDlgCtrlID() runs, I get the ID that I am looking for. Thanks for the help again!
David
|
|
|
|
|
Even though the CWnd is temporary, the underlying HWND is not. So messages sent through the temporary object, still end up in the correct control, and thus, the ID should remain the same.
|
|
|
|
|
The information you need is passed back with the notification message as described here[^]. When investigating issues like this you should always go to the MSDN reference documentation first.
|
|
|
|
|
Hey guys. Lets say, i have such function, like:
void Stuff(int A, int *B);
So as you can see, B is OUT parameter. The question is, how would you call it from inline assembly code?
Something like this:
void Some(int A){
__asm
{
push 1
call dword ptr Some
}
int Some(int A, int B){
__asm
{
push 2
push 5
call dword ptr Some
}
but how to do it with this: void Stuff(int A, int *B) ? How to get B ?
Thanks
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Ok, solved it myself.
#include <windows.h>
#include <iostream>
using namespace std;
void Func(int A, int *B, int *C)
{
*B += ++A;
*C *= *B + 1;
}
int main()
{
int B = 3;
int C = 6;
__asm
{
lea ecx, C
push ecx
xor ecx, ecx
lea ecx, B
push ecx
push 3
call dword ptr Func
add esp, 12
}
cout << B << " : " << C << endl;
}
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
How to extract two bits simultaneously from a byte ?
|
|
|
|
|
Use bitwise AND operator.
unsigned char b = 0xFF;
unsigned char result = (b & 0x03);
(0x03 has the lowest two bits set.)
|
|
|
|
|
Don't think it has to be unsigned, but this works great and is commonly used.
|
|
|
|
|
unsigned can make a big difference if the top bit is one of those involved.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
not really, not if you're dealing with bit level operations... as long as you're not using the data to do arithmetic, but this type of logic is usually used for dealing with APIs and hardware type of operations.
|
|
|
|
|
As mentioned above, use '&' to test for a bit pattern. I've illustrated that in the inline function extract below.
If you don't have the actual values of the bits to test for though, you may need to combine the variables that contain the test bits. In that case use the bitwise or operator '|'. I've illustrated that in the inline function test2Flags below.
You can easily combine more than 2 flags to test for by combining several of them with '|'. See the last call to extract below.
typedef unsigned char byte;
const byte indicator1 = 0x01;
const byte indicator2 = 0x02;
const byte indicator3 = 0x04;
const byte indicator4 = 0x08;
const byte indicator5 = 0x10;
const byte indicator6 = 0x20;
const byte indicator7 = 0x40;
const byte indicator8 = 0x80;
inline byte extract(byte indicators, byte mask) {
return indicators & mask;
}
inline test2Flags(byte indicators, byte flag1, byte flag2) {
return extract(indicators, flag1 | flag2);
}
int main() {
byte myIndicator = 0x34;
byte testMyIndicators3and5 = test2Flags(myIndicator, indicator2, indicator5);
byte testSeveralFlags = extract(myIndicators, indicator2 | indicator3 | indicator4);
return 0;
}
Of course, you don't need to define any function for that, I just did this to enhance readability and focus on the relevant syntax.
|
|
|
|
|
Hi,
We are going to support our application for French localization (iso-8859-1 Windows-1252). The application developed using C++ and C# technologies. As per my understanding, if we support Unicode or MBCS (Multi-byte character set), we won’t get any data loss. Can we use normal string function for handle French characters or _MBCS requires for handle French characters?
Example:
Can we
if( *sz1 == 'A' ) for Character Comparison or
if( !_mbccmp( sz1, sz2) )
Thanks and Regards,
Selvam,
http://www15.brinkster.com/selvamselvam/
|
|
|
|
|
It looks like you plucked your question from here[^] where it explains the issue. It does not matter what character encoding you use if it's the same everywhere, just use the correct functions for your string manipulation, and ensure all constants are held in the correct encoding.
|
|
|
|
|
Hi Richard,
Thanks for your help. so, I can use ASCII functions(string manipulations, Windows API functions , etc) for my French application. Is it?
Thanks and Regards,
Selvam,
http://www15.brinkster.com/selvamselvam/
|
|
|
|