For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I've got a relatively large project (400K lines) that was developed in Embedded Visual C++. For all intensive purposes, you can consider EVC++ pretty close to VS6. We're migrating to a new OS that requires the use of at least VS2008. Needless to say, the much older compiler allowed us to commit a multitude of sins that the new compiler tosses it's cookies on.
I'm pretty sure I could pragma myself to death, but that's "cheating". I'd like to lift the code to a more modern state. Does anyone know of any tools or approaches that can be applied to a set of code that would do most of the heavy lifting? For example, the older compiler allowed methods with no return type. Most of these will be void returns, but at something like 8K errors, it's going to be a lot of $hit shoveling.
Appreciate any ideas.
Charlie Gilley Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
See here. Examples on the Net and here at CP are almost limitless.
If you are looking specifically for "installed" programs (rather than just any and all exe files), you could use WMI with the Win32_Product class. It's a tad more code, however, with all of the COM involved.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
Everything works if I put the handler of TCN_SELCHANGE in the view class.
Instead If i put the handler in the CTabCtrl derived class of my tab control the handler is never called when I push tabs and the tab control doesn't work
I am not sure exactly what feedback you are expecting, as it really depends on what sort of GUI you wish to present to the user. Setting parameters could be anything from simple text input, drop down list or combo, slider, up/down control etc., all of which can be accomplished by using the various Windows Controls[^]. I would suggest looking at some of the sample articles here on CodeProject[^] to get some ideas about how other people have approached similar issues. You could also add some more detail to your question which would help us make more suggestions.
Sorry about my poor explanation!,
The working on a project which is windows console application. But as per my understanding, GUI can be only done in 'Windows Forms Applications'.
Will it be possible to change console applications to windows forms application, where I can find all tools for creating GUI??
Windows Forms applications use C++/CLI or C#. But you can create a Win32/MFC Windows application using the standard Windows controls. Since you already (I assume) have most of the code in your console app, converting it to Windows should not be too difficult (depending on your skill level), although the initial learning does take some time.
You can create a basic Windows application from the template supplied with Visual Studio, so it is worth starting with that to see how it is put together.
(this is partly a rant, because it seems to be something really easy to do, but the framework makes it really hard to achieve).
I need to be able to change the background color of a CMFCButton when certain conditions happen in our application.
According to the documentation, I could use the method CMFCButton::SetFaceColor (Sets the background color for the button text); but this will get overridden (sp?) by the visual manager drawing method (CMFCBaseVisualManager::DrawPushButton) and will have not effect.
Our application is under control of a CMFCVisualManager theme; so all controls are drawn to respect the current theme ( we want to have themes in our application).
There is a static method in CMFCButton to disable themes for ALL CMFCButtons; so that is a little bit overkill.
I could set the CMFCButton flag m_bDontUseWinXPTheme to TRUE (which will disable the theme for that particular button (I would need to inherit from CMFCButton) But that will change the look of the button (and if I want to keep some of the look, I would have to draw all of it manually).
Any insights, tips or hints on what would be the best way to change the background color of a CMFCButton without having to re-invent the wheel?
Alas, think your only solution is to derive your own button from the MFC one and change the OnDraw() method (think that's what the draw method is called, going off memory). I had to do this for a set of buttons that reflected status on their color. It's not terribly hard to do once you've done it once.
which, as I explained will lead to problems: you will either get strange results, or a program crash. If you are going to store data in the buffer returned from malloc then you must allocate enough space for the data you are going to copy into it. Anything less will cause your program to overwite other variables.
OK, let us say that you have a path ("C:\Users\Noname\Documents\Test") in argv, and you now want to inspect a subdirectory called "images":
int argvSize = strlen(argv); // the number of characters in the base path
// calculate the space needed for the subdirectory as follows:
// the length of the base path (argv)
// plus the length of the new subdirectory
// plus one for the backslash separator in front of the new directory
// plus 1 for the trailing null character
//int mallocSize = argvSize + strlen(subdir) + 1 + 1;
char* newPath = (char*)malloc(mallocSize);
strcpy(newPath, argv); // copy the root path
strcat(newPath, "\\"); // add a single trailing backslash - note two \\ required here,
// as the first one is treated as the escape character
strcat(newPath, subdir); // append the new directory name at the end.
// The trailing null is appended automatically by strcat
// newPath should now contain:
Yes because you are using the count from location to do the copy, which is the length of the string, and so will not include the null character. Use the code sample I gave you which makes use of standard library functions that will ensure your copied data is correctly structured.
a random user wrote:
is there any way we could communicate like through skype ?
Sorry, I do this in my own time and at my own speed. I will not be available much longer today.
I did what you told me but the results are still the same
That's because you did not do what I told you. You are still copying your path strings based on strlen rather than strlen+1. And you seem to be creating too many variables, most of which are just duplicates of existing items. This may well be what is causing you confusion.
That is because you keep doing the same thing wrong. You need to stop and think, and reread all my posts that explain how to do it properly. Especially look closely at the sample code I posted yesterday
i did do waht you told me i expended the string by 1
but that 1 byte is messing up my code
even trying using strcat just makes it worse I stopped and read all of ur recent psots but i have nothign that comes in mind that could help me
im sorry for giving you a hard time here but it is hard for me as it is
would you please fix the code to show me what you mean?
I did calculate the bytes and the characters as i needed it needs to be 24 bytes
when at the last code i posted you can see that until i reach to the point that is /1 its 23 bytes
the + 1 is the one i added so it will be the end of the string
Looks to me like you're most of the way there. You probably want to read in your reference file into a buffer. You can use _stat() to get the file size for malloc().
Next, it depends on where the signatures are in the file. If they're at a known location you could use fseek(), fread() and memcmp() to determine if the signature is in the file or not. If the signatures are at a random location, I'd pull the entire file into a malloced buffer (_stat() again), and then search through the buffer. The simple way would be use memcmp() at locations 0 ... (current_file_size - reference_file_size), but there's more efficent ways of going about that. If you know that there's no null chars in the either file (unlikely), maybe strstr() is an option.
some notes on what you have so far:
sizes, and sizes will not change over the while loop, so they could be computed before entering the loop. strlen("\\") is 1, not 2
you not calling free(string) within the while loop, so you're leaking memory. If you use my suggestion about slurping the file into memory, don't forget to free() that buffer too.
First you need to write down the steps you require to do the searching. Something like:
Read 'key' file and extract its signature
For each file in directory
Open next file
Read some data (maybe a small amount, maybe all, or maybe just some specific block)
If the key-file signature is in the data of this file
Do file match processing
Do file no match processing (if necessary)
Until (no more files)
Once you have all the steps clearly defined it should not be too difficult to turn that into code.
A folder in a folder is just a new path to search. When you get a directory in your dirent search, you just append a backslash '\\' followed by the directory name to the string you got from argv (or the current path), and start a new search. Say you start your program by:
and your found entry is a directory named Music, you would create a new path C:\Users\Random\Lists\Music and continue with that. Don't forget to ignore directories named . and .. as they lead back up the tree.
Sorry, but that code does not make any sense. I have no idea what the first block of code is supposed to be doing. And in the code following the flushall call, you have made a call to strlen on a pointer returned from malloc. But the memory that it points to has not been initialised with a string, so the value you get will be either zero, or some random invalid number. You must use strlen on the source string (argv) in order to measure it. So your code should be something like:
int length = strlen(argv) + 1; // extra space for trailing null character
char* entrenceToTheFolderBefore = (char*)malloc(sizeof(char) * length);
for (int i = 0; i < length; i++)
entrenceToTheFolderBefore[i] = argv[i];
You could use strcpy here, but perhaps your teacher has told you not to.
I dont know if i fixed it or not because Just now i saw your comment
but this is how far i got in order to get to the second frole from the first file
but for some odd reason it stopps when i do malloc