|
Hi,
I found out accidentally, that using the SetWindowPos to the MainFrm window inside the OnCreateClient it solves the problem. It seems that setting the attribute that does not change the Z-Order of the main window keeps it always in the top.
SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
What do you think ?
Regards,
sdancer75
|
|
|
|
|
Hello,
Quick prerequisite: I'm graphic designer and I have no idea about programing.
Long story short I want to modify some graphic files but they are encrypted. I already have the code in C for decrypting them but I have no idea how to make it into working program. Also I have no idea about C language syntax so I'm not sure if I need to modify this code so I can show the program files I need to decrypt. I would be very grateful if someone could help me with this.
#include <stdio.h>
int main (int argc, char **argv)
{
FILE *inp, *outp;
int i;
char sig[] = "CF10", *ptr;
if (argc != 3)
{
printf ("usage: decode [input] [output]\n");
return -1;
}
inp = fopen (argv[1], "rb");
if (inp == NULL)
{
printf ("bad input file '%s'\n", argv[1]);
return -2;
}
ptr = sig;
while (*ptr)
{
i = fgetc (inp);
if (*ptr != i)
{
printf ("input file sig is not 'CF10'\n");
return -2;
}
ptr++;
}
outp = fopen (argv[2], "wb");
if (outp == NULL)
{
printf ("bad output file '%s'\n", argv[1]);
return -2;
}
do
{
i = fgetc(inp);
if (i != EOF)
fputc (i ^ 0x8d, outp);
} while (i != EOF);
fclose (inp);
fclose (outp);
printf ("all done. bye bye\n");
return 0;
}
modified 22-Oct-14 11:46am.
|
|
|
|
|
What development environment will you be using? Visual Studio?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
To be honest I have no preferences and I can be flexible. I doubt I'll use C again in my life. I have acces to Visual Studio but isn't it only for Visual C++, C$ and VB?
|
|
|
|
|
Well you'll have to choose one before someone can help you make a program.
C code will compile in a C++ environment, so Visual C++ is OK.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Makes total sense. Let's make it Visual Studio Express 2013 for Desktop to be precise then.
|
|
|
|
|
Ok I figured out the easy part (how to compile C code in Visual Studio). But now there are two problems left:
a) When I try to compile the code from my first post i get this error: "
Error 1 error C4996:
EDIT: Ok I've dealt with this one by adding _CRT_SECURE_NO_WARNINGS to Preprocessor Definitions!
b) When I deal with the bug above how to modify code so I can "show" the program which files I want to decrypt?
|
|
|
|
|
It looks like the code is written to accept the names of the files to decrypt on the command line. So you might invoke the program by entering "program /file_to_decrypt.txt", or something like that.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Yup I did exactly that. Topic can be closed. Thx for your help!
|
|
|
|
|
Glad you got it working.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I have one last question about the software. How should I modify the code so instead of decrypting the files I can encypt them again using the same "CF10" signature. Thanks in advance.
|
|
|
|
|
That would not be a simple change. You'd have to rewrite the whole thing.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Apparently #define VERSION does not simply replace the VERSION with literal 1.0.0 but the 1.0.0 is analyzed by GCC compiler.
Did some search and found that certain "tokens" have special function in #define.
Did not quite get which tokens, period is one of them, but like to know if this is something new or specific to GCC ( used by Arduino IDE).
Of course it works "normal" if the token is enclosed in parentheses as a string.
Any comments will be appreciated.
Cheers Vaclav
PS What is the correct name for "the stuff" after #define and VERSION?
|
|
|
|
|
If it's used as a string, then why don't you #define it as a string? If you don't know how to correctly use #define, why do you use it at all? It's bad style anyway! Make it a const string instead:
const std::string VERSION = "1.0.0";
There. Works every time. And if the compiler complains, the code that uses it is wrong! That is the advantage of using const instead of #define: the compiler will notify you of usage problems, whereas in case of #define there's no guarantee the compiler will catch a glitch, and if it does, it will likely not point to the right position in your code.
Vaclav_Sal wrote: PS What is the correct name for "the stuff" after #define and VERSION?
The correct name is "clutter", or more to the point: "stuff that clogs your global namespace". #define symbols have a nasty habit of colliding with variable and function names elsewhere because they pollute the entire global namespace. Just don't use it!
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Stefan_Lang wrote: #define symbols ... pollute the entire global namespace
Ummm... what? They are gone as soon as the preprocessor completes.
|
|
|
|
|
That's true, of course. Still you may have a clash with a global symbol.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
That's OK, it'll just rock the casbah.
|
|
|
|
|
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
It once took me more than a day to resolve an issue that manifested as some inexplicable and incomprehensible error message somewhere in the depths of the MS-provided STL implementation. In the end it turned out that the #defined symbols min and max from the windows header files managed to wreak so much havoc in the implementation files of std::valarray, that the error messages not only were totally unrecognizable but also pointed to an entirely different point in the code!
That's what I mean by cluttering the global namespace: just about anywhere in your code, any macro from a totally unrelated part, has the potential to totally destroy your code to the point where you neither recognize the location nor cause of the problem! Fixing such an issue in a codebase of 3 million lines of code is not fun at all!
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
The problem is not with the defined value, but in how you are trying to use it. It will be difficult to use that value unless you make it a string, though you can stringize it. The following shows how it can be done (I used Borland's C/C++):
# include <stdio.h>
# define X(x) Y(x)
# define Y(y) #y
#define VERSION 1.0.0
void main() { printf ( "%s" , X ( VERSION ) ) ; }
http://msdn.microsoft.com/en-us/library/7e3a913x.aspx[^]
In general, if you use DEFINEs for constants (and you shouldn't), only use values that are valid literals.
Vaclav_Sal wrote: What is the correct name for "the stuff"
MSDN calls it "token-string".
Syntax
#define identifier token-stringopt
#define identifier( identifieropt, ... , identifieropt ) token-stringopt
http://msdn.microsoft.com/en-us/library/teas0593.aspx[^]
modified 16-Oct-14 15:20pm.
|
|
|
|
|
Please read the OP and if you do not know the answer do not bother to reply.
I did not ask for a lecture why not to use #define.
|
|
|
|
|
Please read the response.
|
|
|
|
|
I thought that was a pretty good response...
|
|
|
|
|
That's just rude.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Vaclav_Sal wrote: Apparently #define VERSION does not simply replace the VERSION with literal 1.0.0 but the 1.0.0 is analyzed by GCC compiler. When you use that statement the value after the word VERSION has two decimal points so it is not a valid token, and the compiler rejects it. A #define statement must contain valid C/C++ code, so the value after the identifier must be a valid literal or expression which resolves to a valid literal; see http://msdn.microsoft.com/en-us/library/teas0593.aspx[^].
|
|
|
|