|
My program has to update the resource in the .exe file under Win98? What can I do?
stanley
|
|
|
|
|
You can load the Image File using win32 APIs.Then there is a section called .RSRC (Resource Section).Use Image header. Then you can manupulate the things..but then you have to take care of the file size and respective RVA's..
|
|
|
|
|
from MSDN:
The UpdateResource function adds, deletes, or replaces a resource in an executable file.
Update for win9x: UpdateResourceW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
That means you can use the UpdateResourceW function after adding those files.
|
|
|
|
|
But I am sorry that which files are neccesary. Can you tell me which files are must added to my program? Help me, please.
stanley
|
|
|
|
|
Thank you! The problem is gotten rid of.
stanley
|
|
|
|
|
I am a newbie so bear with me. I have a dialog that launches another dialog(modal). This second dialog collects and wraps user data into a data structure. I want to pass this data structure back to the original dialog that launched it. The default ctor for the second dialog takes a pointer to a cwnd which is the parent. How can I do this? Should I create another ctor in the 2nd dialog that takes in a pointer to the parent and have a callback, or does studio provide an easier way. Thank you!
|
|
|
|
|
There are lots of ways of doing this. One way is to create the data structure in the parent dialog, and pass in a pointer or reference to it in the constructor of the second dialog. Then the second dialog modifies the reference directly so when DoModal() returns, the data structure contains all the user data already.
Dave
|
|
|
|
|
This way the user can not cancel the dialog, as changes have already been performed.
Please seem my other post for a different possibility.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
IMHO it is easiest to have a SetData() and a GetData() function in your second dialog class, which takes/returns a data structure. If your second dialog returns IDOK you use the data returned from GetData() , if it returns IDCANCEL , you throw it away.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I am a professional, but unfortunately junior, developer, and I'm looking to do something that I thought I knew how to do.
Now, I cannot recall how to do it, and I'm feeling... well, terribly ignorant.
What is going on is I want to create an array of arrays - in specific, I'm making a pointer of pointers, actually.
I want each of the pointers in the "array" to point at an object of the same type. I wanted to set up a for-loop to assign these.
In other words, I have something like:
TCSpinEdit ** SpinnerArray;
SpinnerArray = new TCSpinEdit *[58];
for (int iCtr = 0; iCtr < 58; iCtr++)
the name of each of these objects starts out with CSpin followed by a number, from 1 to 58; so I need to point to CSpin1, then CSpin2, etc.
Therefore, I need to generate a string, or whathave you, to designate each CSpin variable to each of the pointes in the array.
And I realized I was unsure how to go about this.
I started originally by using the string class; assign it as:
string = "Cspin" + iCtr;
But I realized I wasn't sure how to use the string to refer to a variable NAME. Any suggestions?
Thanks!
James A Beggs
Microsoft MSN Mobile Component Test Team
|
|
|
|
|
I'm not sure if I understood you completely but in C++ there's no such association between a varaible name and a string, a variable name is merely a symbol by which you tell the compiler that you are about to request a block of memory, whereas a string is an array of characters. You cannot "convert" them into each other because they are totally different concepts.
|
|
|
|
|
Hum, I think I don't really understand you but why do you make so complicated ???
Why don't you just acces the array as normally like that:
TCSpinEdit* Temp;
for (int iCtr=0;iCtr<58;iCtr++)
Temp = SpinnerArray[iCtr];
|
|
|
|
|
You seem to be confused about what you really want - I try to give you an explanation, and maybe you can then decide if this was what you intended.:
James A Beggs wrote:
TCSpinEdit ** SpinnerArray;<br />
SpinnerArray = new TCSpinEdit *[58];<br />
for (int iCtr = 0; iCtr < 58; iCtr++)
So you have a pointer to an array of 58 TCSpinEdit* s.
In your for-loop you need to initialize each of the TCSpinEdit* 0 to 57 with a pointer to a TCSpinEdit :
for (int iCtr = 0; iCtr < 58; iCtr++)
{
SpinnerArray[iCtr]= new TCSpinEdit( parameter );
{
Your TCSpinners are now accessed as SpinnerArray[i], where i=0..57.
If you need - for whatever reason - a association between your TCSpinners and some other data, e.g. a string, you might use a std::map < string, int > to store pairs of strings and indices into your SpinnerArray.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I'm a novice to Visual C++ Programming, and, of course, I'm really competent at coding errors. I think this happens to everyone initially. I'm constantly reviewing the literature, and in spite of this, I make the most incredibly and redundantly insipid errors imaginable.
I can code infinite recursion without even the vaguest notion of what I am doing. I can do bloat. I can write functions that never get called. This is all so incredibly easy to. And, I'm actually good at it.
...And so I'm starting a thread in which you all can entertain us with your all-time most frustrating struggle to domesticate a seemingly insignificant type or format.
...Something that came REALLY close to making you a serial killer,...
|
|
|
|
|
I usually program in regular old c++,(though im learning visual) anyway this gets me:
if (x = 1)
statement;
when i meant
if (x == 1)
statement;
compiles great,runs like hell::;)
|
|
|
|
|
Two things you can do to fix that habit
1) Compile at warning level 4 in VC. In other compilers, turn on warnings (for example -Wall in gcc)
2) Put the constant on the left side: if (1 == x)
That way if you use = instead of == the code won't compile.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
The common mistake in this case (writing if (x = 1) instead of if (x == 1) ) is I believe a simple confusion caused by the fact that people often write assignments and the equality sign is a common operator used in mathematics, real life etc. whilst "==" does not exist. So nothing's wrong with making such a mistake and warning level 4 will put you right on the line, BUT:
Michael Dunn wrote:
Put the constant on the left side: if (1 == x)
This is something what I would call nonsense. Applying in a real-life situation:
You are making an equality comparison, and thinking to yourself as suggested:
- What am I doing?
- Checking for equality.
- So I should write an if..
- Yes exactly, do it. Stop! Put the constant on the left side!
- Why? Why should I do that?
- Because you can mistype the equality operator..
- Oh hell yeah I could've mistyped it, so I put the constant to the left..
- Yes and remember that everytime you make a comparison.
- Sure I'll remember.
The point is (just in case): Writing 1 = x; is invalid as an assignment so in order to remember to put the constant on the left side, one must keep in mind that (s)he is making a comparison. So, if you are aware of the fact that you're making a comparison, then there's no chance (besides a brain tumor or some similar disability) that you'll be writing "=" instead of "==" accidently.
I must say that I've seen this advice too many times and believe that people never think about it actually, just forward the idea.
Or worse: I have a tumor of a different kind
|
|
|
|
|
Not exactly a programming error but I would submit our database. Hundreds and hundreds of tables, dynamic SQL *everywhere*, if anything is documented it's months and months out of date.
As for becoming a serial killer, try this[^]...
not having a good day...
You should save yourself and your company years of grief by shooting yourself through the head immediately. Believe me, in the long run it'll turn out better for everyone. - Tyto (at arstechnica)
Awasu 1.0[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
That's EASY!
(Note improper placing of ';')
<br />
for (i = 0; i < MAX; i++); <br />
{<br />
}<br />
OR coming from a Fortran background...
<br />
for (i = 1; i < MAX; i++)<br />
{<br />
Array[i] = something * something_else;<br />
}<br />
where I have forgotten that arrays are indexed by 0 in C++
|
|
|
|
|
Guys ,u have forgotten about pointers!!!!
int i;
int *j=&i;
int k;
for(count=0;count
|
|
|
|
|
Try something like this:
short n;
scanf("%d", &n);
Gives amazing unpredictable results. If n is the first declared variable in the function, this code can overwrite function return address.
|
|
|
|
|
Ya know, I have this extensive list of amazingly dumb mistakes that I was going to post,...but, compared to me ,you guys look like Nobel Prize winners. (Yes, I have made that assignment operator mistake a number of times.)
My all-time most embarrassing errors:
I ALWAYS forget, #include "resource.h" at the beginning of the source file. ...and, I ALMOST ALWAYS make a number of typographical errors, so, I get the "Undeclared Identifier" error message ALL THE TIME (...it's like an old friend now).
Most frustrating: It took me forever to figure out that you must use TWO backslashes when designating the "file path string" with either CreateFile or the iostream library class functions (and I would have NEVER figured that out if I hadn't stumbled upon it in an introductory book on C++, completely by accident).
|
|
|
|
|
In msdn i see two possible ways to convert an MFC CString Object to a C-Style null terminated string:
1) cast the CString to an (LPCTSTR)
2) call CString::GetBuffer() on the object.
Is one method more correct or safe than the other? For example, if i wish to call "stdio.h" library functions like strcmp that take char*'s as parameters, which method should I use to convert my CStrings to Char*'s?
Thanks
Ben
|
|
|
|
|
The LPCTSTR operator returns a constant pointer to the underlying null-terminated string - i.e. you can't change it. It is invoked implicitly by the compiler when a function requires a constant string. GetBuffer() returns a non-const pointer to the underlying string, which you must release when you are finished by calling ReleaseBuffer().
So you can normally just use the LPCTSTR operator unless you need to change the string.
Dave
|
|
|
|
|