|
What error message do you get?
My first thoughts would be to move the declaration to outside of the ClassWizard generated code
class CMyDialog : public CDialog
{
public:
CMyDialog(CWnd* pParent = NULL);
enum { IDD = IDD_MY_DIALOG };
double ValuesArray[200];
};
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
I moved it outside, but I still get an error (once the code is done running). It works up until that point. Thanks to me changing the size of the array. I swear I had it set up correct, but I guess not.
This is the error message I get when I do it inside the ClassWizard zone
MYSOURCE caused an invalid page fault in<br />
module MSVCRT.DLL at 0167:78009dd3.<br />
Registers:<br />
EAX=00000000 CS=0167 EIP=78009dd3 EFLGS=00210246<br />
EBX=0063f600 SS=016f ESP=00540000 EBP=00540034<br />
ECX=005400dc DS=016f ESI=817f7600 FS=20d7<br />
EDX=bff76855 ES=016f EDI=00540104 GS=0000<br />
Bytes at CS:EIP:<br />
55 8b ec 56 8b 75 18 57 bf 20 05 93 19 39 3e 74 <br />
Stack dump:<br />
7800a7bc 00540104 0063f600 00540120 005400dc 5f4b5948 00000000 00000000 00000000 00540104 817f7600 0063f600 5f4b5948 00540058 bff76849 00540104
This is what I get if I am outside the Class Wizard stuff:
MYSOURCE caused an invalid page fault in<br />
module MSVCRT.DLL at 0167:78009dd3.<br />
Registers:<br />
EAX=00000000 CS=0167 EIP=78009dd3 EFLGS=00210246<br />
EBX=0063f600 SS=016f ESP=00540000 EBP=00540034<br />
ECX=005400dc DS=016f ESI=817f7c40 FS=3227<br />
EDX=bff76855 ES=016f EDI=00540104 GS=0000<br />
Bytes at CS:EIP:<br />
55 8b ec 56 8b 75 18 57 bf 20 05 93 19 39 3e 74 <br />
Stack dump:<br />
7800a7bc 00540104 0063f600 00540120 005400dc 5f4b5948 00000000 00000000 00000000 00540104 817f7c40 0063f600 5f4b5948 00540058 bff76849 00540104
Keeping in ming that if I define the array inside of the subroutine-locally (or function? I don't know the right word.) I get no error at all???
I wish I could type better ...
|
|
|
|
|
spaced_out wrote:
for (int i=0; i < 199; i++) // loop 200 times for 200 lines of data
FYI, this only loops 199 (0-198) times. That's not the issue at hand, though.
When you are read from the ValuesArray[] array, adding the values to the list control, what line of code causes the error? Is it an access violation, or a fired assertion?
|
|
|
|
|
Thanks for the 0-198 clarification.
The error is posted in my reply above. I have NO IDEA what it means?
I wish I could type better ...
|
|
|
|
|
hehe, i'm sure it is a stack overflow... because of page fault...
you define the CDialog class local in the InitInstance function of the program, right??
then it makes no difference, if you place the whole class in stack or just the 200 doubles.
define the CDialog class GLOBAL, then it should work!
Don't try it, just do it!
|
|
|
|
|
200 doubles is not a lot of memory.
John
|
|
|
|
|
Do you have another way for me to define these numbers that would take up less space?
Instead of double?
If so let me know.
I wish I could type better ...
|
|
|
|
|
My point is that 200 doubles only takes 800 bytes of memory. Your stack is over a megabyte. So the memory allocation is insignifigant... I have programs that allocate over a gigabyte of data with no probelem. They do not put it on the stack though....
John
|
|
|
|
|
next time better take a calculator!
200*sizeof(double)=200*8=1600bytes!
Don't try it, just do it!
|
|
|
|
|
You are correct a double is 8 bytes... Anyways 1600 bytes on the stack is still not signifigant..
John
|
|
|
|
|
Alexander M,
I didn't understand what the Hell you were talking about (well maybe just a little), but it got me thinking and tried some new stuff. I just defined the array in the .cpp soure code outside of all subroutines(functions? I still don't know what to call it.) And POW, BINGO, YEEHA, WHOOPIE GOLDBERG, HOORAY! It works. Global array, and no errors!
I don't know if that is what you were trying to tell me, but we will just say it was. SO, I gave you a 5 out of 5 for helpfulness, but I would have given you a 10 if they let me.
You da bomb.
Thanks!
I wish I could type better ...
|
|
|
|
|
I am not sure that it is fixed. I think you just delayed the crash by moving the variable to a different memory location.
John
|
|
|
|
|
|
thx
Don't try it, just do it!
|
|
|
|
|
I think the only reason why that solved your problem is that if you step past the end of a global variable you are probably not going to interfere with the runtime stack. Your problem probably still exists but in a sneaky way. Try the following declare your values array as
double ValuesArray[190];
Guess what it probably will not crash your dialog this time either. Why does it not crash the dialog? It is overwriting other variables in your global data that could come back and cause your program to work in an unexpected way.
I just tested my theory and it worked. I created a dialog application and in my OnOk() function I did the following which caused a crash because I am stepping past the end of ValuesArray.
void CStackOverflowDlg::OnOK()
{
double ValuesArray[200];
for(int i=0;i < 300;i++) {
ValuesArray[i] = 100.0;
}
}
Guess what moving ValuesArray to the global namespace and there was no crash at all.
double ValuesArray[200];
void CStackOverflowDlg::OnOK()
{
for(int i=0;i < 300;i++) {
ValuesArray[i] = 100.0;
}
}
But have I fixed the problem? Absolutely NOT! I still am using more items ValuesArray than I declared...
John
|
|
|
|
|
Hi,
How to assign a new IP address through MFC for windows 98. after assigning
I should not restart the system and could be able to continue with
communication. I tried with AddIPAddress().
but this supports only winNT. Is there any equivalent api in windows 98.
thanks in advance,
pramod.
Pramod Kumar A
SASKEN-INDIA
|
|
|
|
|
Interesting. One possible solution is to change the IP via registry.
Kuphryn
|
|
|
|
|
Is there such a thing? In short, I need to hook a game that was written with DirectX...
Thanks
Ralph Krausse
|
|
|
|
|
D3DSpy from the DirectX 9 SDK.
- Mike
|
|
|
|
|
I ahve no experience in anything at all and i was wondeing if anyone could give me tips on how to start becoming a game developer?
Program newb
|
|
|
|
|
Don't shoot too high on your first attempt at a real game - don't attempt to write a Halo or a GTA:VC on your own as your first project - you will fail and get depressed Aim for something simple like Tetris.
Try out different tools to see what you are comfortable with - try Flash for some 2D games, for example.
Learn a simple and clean language such as VB.NET or C# or Python to gain programming experience with relatively little pain (which you will want to do) without getting immediately bogged down an insanely complicated but powerful language like C++ (which a lot of games are currently written in).
Learn LISP as skills development. Because you learn how to program well just as much from "odd and obscure" languages as much as "normal and popular" ones.
Try stuff out - experiment with different approaches to solving a problem.
Develop good algorithm skills - know what the operating complexity/advantages/disadvantages of an algorithm are. Your game is going to be slow if you use a bubble sort to sort the Z-Order of some polygons because you didn't bother to learn quick sort or radix sort because it looked too complicated. Knuth's Art of Computer Programming series has a lot on these algorithms - which leads to the next point:
You'll need books. Lots of books. Books covering DirectX, C++, object oriented design, software testing, dealing with people on software teams (you did plan on working with others, right?), and probably books on VB.NET/C#/Python to help writing your toolsets with (level designers, scripting, etc - you want something quick, dirty and productive for these)
Don't be impatient. It takes years to become a talented and skilled developer.
Ask sensible, concise and thought-out questions in the appropriate forums (here and elsewhere). (Note, your question isn't one of them It's too broad in scope.)
BTW, I'm not a games developer, just a highly skilled "normal" developer.
--
Ian Darling
|
|
|
|
|
I found writing a PACMAN game is a good starter...
John
|
|
|
|
|
Do you have any programming experience at all?
If you have none, then the first thing to do is learn a language. Start simple and learn the basics of your chosen language before even contemplating writing a game.
If you do have some coding experience then http://gamedev.net[^] is a good resource for learning about game development.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
Is it possible to set a few check buttons to be defaultly true so that when a user opens an applcation those buttons are by default true??
if it is how can we do that??
|
|
|
|
|
Try calling
CButton::SetCheck() in OnInitDialog() of your dialog class.
|
|
|
|