|
Can you tell me how you managed to download and install the SDK ?
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
The following is a summary of the problem we are having with our application:
The application is a SDI MFC application with a single view. There are quite a few dialogs brought up by the main view.
When we try to bring up a dialog, the application returns a Debug Assertion Failure. The code used to bring up the dialog is:
CPayorBenefitDlg dlgPayorBenft;
int nDlgRetState;
//subsequent lines of code
If the above block of code is executed in the Debug mode, we can observe that immediately on execution of the 1st line (where we instantiate the dialog object) the this pointer (the pointer to the view object) changes. This event causes the program to assert further down the line since in the subsequent lines of code we access the view's data.
However, if we change the above code as:
int nDlgRetState;
CPayorBenefitDlg dlgPayorBenft;
//subsequent lines of code
Then the dialog comes up fine but the program raises a General Protection Fault on closing the dialog. In this case, the this pointer does not change when the dialog is instantiated.
Finally, if we change the above code as:
int nDlgRetState;
char chArray[100];
CPayorBenefitDlg dlgPayorBenft;
//subsequent lines of code
Then the program works perfectly fine!!
What could be the reason for such an inconsistent behaviour? And any suggestions as to how we can fix the problem??
Thanks,
Arvind
|
|
|
|
|
You are describing the textbook case of a stack corruption. If you are certain the problem is related to the dialog, check to make sure the dialog doesn't have any embedded arrays that might be writing beyond (or before) their bounds.
This problem happens most often with embedded arrays rather than arrays created with new.
|
|
|
|
|
All I can think of (that's what happened to me) is that
a) you're doing something 'weird' in the dialog constructor (most likely)
b) the header file for you class you use is somehow different from the original class
(missing variables and such).
I had the exact same problem, when I fixed the header file it worked fine again...
|
|
|
|
|
I am designing a dialog that resembles a keyboard that will allow the user to enter passwords, keys, etc... Is it possible to create a single message handler for all of the buttons (letters, numbers, spacebar, -, and .), and if so how do you differetiate between which button was actually pressed. Or, do I have to have a single message handler for each individual keyboard button?
Roger Printy
Software Engineer
TeraNex
Orlando, FL
|
|
|
|
|
Supply your own WndProc (window procedure) and look for
the messages in that.
Stephen Kellett
|
|
|
|
|
Any help on doing that, this is new to me. Also, how would you suggest to create an array of button objects that in a constructor is initialized to have each element in the array be a pointer to a button. I am doing this, am I correct because it seems to not be working completely:
CButton *m_pLetterBtn[19];
m_pLetterBtn[1] = (CButton *)GetDlgItem(IDC_KEY_1);
m_pLetterBtn[1] = (CButton *)GetDlgItem(IDC_KEY_2);
m_pLetterBtn[1] = (CButton *)GetDlgItem(IDC_KEY_3);
.
.
.
Roger Printy
Software Engineer
TeraNex
Orlando, FL
|
|
|
|
|
Well, actually, you can use the ON_COMMAND_RANGE message handler. You must make sure all the buttons resource ID's are sequential though.
Having said that, your design is probably not the best. It would be much easier if you simply drew the keyboard layout on the dialog in it's OnPaint handler, then create regions for each button and then handle the OnMouseUp event and check to see which region the button press occured in.
|
|
|
|
|
You can create a message map entry as below
ON_CONTROL_RANGE(BN_CLICKED, IDC_BUTTON1, IDC_BUTTON10, OnButtonClicked)
instead of the ON_BN_CLICKED message map entry. Here IDC_BUTTONis is the first button in a set of button having consequtive IDS. and IDC_BUTTON10 is last among them.
The corresponding hadler will look like
void CMyDialog::OnButtonClicked( UINT nID )
{
int nButton = nID - IDC_BUTTON1;
ASSERT( nButton >= 0 && nButton < 10 );
// ...
}
If you dont have the button ids as consequtive integers You can try one more method.
Let me explain that.
Map All the button to one Command Handler. You can do this using the class wizard itself. For all the buttons give the function name the same. Say (OnButtonClicked)
Later inside OnButtonClicked you can code as below;
void CMyDialog::OnButtonClicked()
{
const MSG *x = GetCurrentMessage();
CString ToDisp;
int nID=(int)x->wParam;//WParam gives the command id of the button.
ToDisp.Format("The Id of the button is %d...",nID);
MessageBox(ToDisp);
}
HTH
Sundaravalli Shriram
Tektronix Engineering Development India Ltd,
Bangalore - 560001,
India.
|
|
|
|
|
Hi all,
I am using a listctrl w/ small icon style, but unfortunately some of my strings are too long, so they overwrite the items right to them. Therefore, I changed the style to list view. Everything ok, but I do not want a scoll bar. So, when I use the style LVS_NOSCROLL, only the first item is drawn, all others disappeared. Does anyone know where did they gone?
Thanks in advance,
Thomas
|
|
|
|
|
Hi
I'm trying to copy a <vector> array onto the clipboard and I keep getting crashes when I do. Any1 know why this happens? I'm assuming that vectors dont work if u just copy them coz they have pointers to data they use somewhere, but it still shouldnt stuff up??
any help appreciated
thanx
-Peter
|
|
|
|
|
Likely what happening is that you are copying the vector and then the original vector is going out of scope, destroying the data in the poitners.
Then when you try to access that data later, you're accessing deleted memory, and thus the crash.
You need to copy the data from the vector, not just the vector itself.
|
|
|
|
|
I always think that there might be a simpler solution to my current problem.
OK guys, here's how it goes: A RTS game (e.g. Starcraft, Red Alert, etc) will have many of those small units walking around on the map. OK, so now I want to make a game that each human player, will represent ONE unit on the map. That means, you log on to the server, you play as ONE SINGLE unit. If you die, the battle still go on. You gotta join the on-going battle again later.
Allright? So that's simple right? But when I consider the traffic over the server side, there's this BIG problem: Imagine there are 1000 players log on to play in a game, if there's a need to synchronize, one player will send out a message package to the server, and the server will in turn forward the messages to all the other players.
In the worst case, 1000 players will each send out a package, and the server will receive 1000 message packages from all the players, and if it wants to forward them, that will be 1,000,000 message packages on the server side. Try to consider a package of few bytes, will easily result in few megabytes of data flow on the server's line!! (Note that this is only for a single message package!!)
Oh Gosh!! That's gonna kill the server!! So my friend, do you have any idea as how to address this serious problem? Thanks a lot for helping me, this little poor guy. haha!!
|
|
|
|
|
I'm not sure about the answer, since i'm not specialized in that, but i'd like the server to have all positions in memory, clients send their new position if needed (to decrease client upload), and then server sends an update packet (of all changed positions, that is 1000 max here) to all client each frame / tick / second - depends what framerate u need.
I mean, do not update all clients when a client moves, just keep the server up to date and make the server tells everything that is needed on a regular time base.
Good luck
|
|
|
|
|
Well, I think your math is correct...
I play EverQuest, and I've noticed that they seem to have a maximum of about 2000 players per server, and use many other techniques to keep the relayed message count down.
One technique in particular is to divide the "world" into a number of zones that you move between. When you move from one zone to another, you get sync'd up with the players in that zone. The system still has the ability to send world wide messages, but they are very few in number in comparison to the standard.
By using zones, there's ususally groups of 70 to 80 people or less that are hooked together, and so the standard character positioning messages are far, far fewer in number.
HTH,
David
|
|
|
|
|
> but i'd like the server to have all positions in memory,
> clients send their new position if needed
Yes, and you need to make sure that the server takes care of colission detection and other stuff like that, so that the Server has the ultimate say on what happened, and when.
> One technique in particular is to divide the "world"
> into a number of zones that you move between.
Yes, but in an RTS game, (a similar idea) you might want to consider only sending updates to players that actually have something around them. For example, if your avatar is standing in the middle of the woods, with no other players in sight, there is no need for you to receive the locations/actions of every other player in the game (that also increases the cheat potential). You only need to know what is going on around you, and certain other items like transmissions from other teammates, "Base under attack", etc.
-=- James.
|
|
|
|
|
I want connect to some server at some port through a proxy wich uses NTLM authentification.
After connection I want to send some buffer to the server and initiate a communication (not just to get some file).
The main problem is NTLM scheme. I can bypass it using WinInet API, but I can't figure it out how to send a buffer (command) to server.
Another way is using WinSocks, but there is the NTLM scheme again.
So, can anybody help me?
Thanks,
may
|
|
|
|
|
i need a formula that will give me the x y coordinates of the edge of a circle
|
|
|
|
|
Isn't it something like
r^2 == x^2 + y^2
for the case when the origin is at 0, 0
r is radius
Stephen Kellett
|
|
|
|
|
thanks heaps for the help
|
|
|
|
|
Hy,
i need for a personnal application to retrieve the title and the url of a ie favorites. I have got the full path of each .htm favorite and i want to know what is the easiest way to retrieve the info i need. Thanx for your help
Patrice
|
|
|
|
|
If anyone can help me with this assignment I would greatly appreciate it. At this point I do not know where to start. The assignment can be seen at the following url:
http://www.cise.ufl.edu/class/cgs6305fa00/prog/5/
I have started the Mp3.h header file but I know I am doing things incorrectly. I will post additional code as I complete it this evening. This assignment is due Thursday 11/16/00.
Any help at all would be greatly appreciated.
/*
Mp3
Stores information about an mp3 file: artist name, song title, and
bit rate (an integer greater than 0 that represents kbits / sec).
The constructor accepts all values as parameters
(strings arguments should be passed by reference).
Two public methods must be defined in the class:
1. equals( const Mp3 & ): returns true if the passed argument's
instance variables are equal to the current instance and false
otherwise.
2. display(): displays the Mp3 data in the following form
(using example data):
Artist: Nirvana
Title: Smells Like Teen Spirit
Bit Rate: 128 kbits/sec
This method doesn't return a value.
*/
#ifndef __mp3_h__
#define __mp3_h__
#include <string>
class Mp3
{
public:
//constructor
Mp3(string &Artist, string &Title, string &Bit){
string art = &Artist;
string tit = &Title;
string bit = &Bit;
}
// this is a mess
bool equals(const Mp3&){
if (Mp3& == this.Mp3)
return true
}
void display(){
cout << "Artist: " << this.art << endl;
cout << "Title: " << this.tit << endl;
cout << "Bit Rate: " << this.bit << endl;
}
}
|
|
|
|
|
For starters, am I wrong in thinking your variables, being declared in the constructor, will be deleted in the constructor also ? They need to be globals.
Linked lists are not so hard, the best thing is to sit down with a piece of paper and draw out the structure so when you're knee deep in the code you have a mental picture of what is meant to be going on. I did a quick sort of a linked list once, now THAT was confusing....
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Okay, I made those variable static...
I've made a bunch of changes. I think my header file is coming along. I still do not know where to begin with this linked list thing.
/* mp3list.h
Your classes must all be declared in a header named mp3list.h.
Their definitions must reside in the file mp3list.cpp
(capitalize those correctly). */
/*
Mp3 Class
Stores information about an mp3 file: artist name, song title, and
bit rate (an integer greater than 0 that represents kbits / sec).
The constructor accepts all values as parameters
(strings arguments should be passed by reference).
Two public methods must be defined in the class:
1. equals( const Mp3 & ): returns true if the passed argument's
instance variables are equal to the current instance and false
otherwise.
2. display(): displays the Mp3 data in the following form
(using example data):
Artist: Nirvana
Title: Smells Like Teen Spirit
Bit Rate: 128 kbits/sec
This method doesn't return a value.
*/
//prevent multiple inclusion of header
#ifndef __mp3list_h__
#define __mp3list_h__
#include <string>
class Mp3
{
public:
//constructor
Mp3(string &Artist, string &Title, int &Bit){
static string art = Artist;
static string tit = Title;
static int bit = Bit;
}
bool equals(const Mp3& ComparedMp3) const {
return if ((art == ComparedMp3.art) && (tit == ComparedMp3.tit) && (bit == ComparedMp3.bit));
}
void display(){
cout << "Artist: " << art << endl;
cout << "Title: " << tit << endl;
cout << "Bit Rate: " << bit << endl;
}
}
/* Mp3ListNode Class
An object to represent a single node of the linked list.
*/
typedef Mp3ListNode *Mp3ListNode_ptr;
class Mp3ListNode
{
public:
/* constructor
Two instance variables are needed: a pointer to an Mp3 object
(the data held by the node) and a pointer to an Mp3ListNode that
points to the next node in the chain. The constructor must take
the three Mp3 data values (artist, title, rate) as arguments and is
responsible for creating an instance of Mp3 using the given data and
to save it in its instance pointer variable. It should also
initialize the pointer to the next list node to NULL
*/
Mp3(string &Artist, string &Title, int &Bit){
static string art = Artist;
static string tit = Title;
static int bit = Bit;
static Mp3ListNode_ptr curr;
static Mp3ListNode_ptr next = null;
}
/*
Three public methods must be defined in the class:
1. getMp3(): returns a copy of the pointer to the Mp3 object.
2. getNext(): returns a copy of the next Mp3ListNode pointer.
3. setNext(Mp3ListNode *): sets the values of the next Mp3ListNode
pointer to the passed pointer argument.
*/
getMp3() const {
return curr;
}
getNext() const {
return next;
}
//do I need a return type here? what return type is a pointer?
setNext(Mp3ListNode* SentNextMp3ListNode) {
next = SentMp3ListNode;
}
}
----------------------------------
/* mp3list.cpp
Mp3List
An object that represents a linked list. It provides methods for
common list operations such as adding, deleting, searching, and
inserting.
/*
The object should have three instance variables:
An Mp3ListNode pointer that points to the head (first) node of the
list, another Mp3ListNode pointer that points to the tail (last)
node of the list, and a count of the number of nodes currently in
the list. The constructor for the class takes no arguments and
initializes both pointers to NULL and the counter to 0 (the list
is created empty).
*/
typedef Mp3ListNode *Mp3ListNode_ptr;
class mp3list
{
public:
mp3list() {
Mp3ListNode head = null;
Mp3ListNode tail = null;
Mp3ListNode count = 0;
}
/*
Several public methods must be defined by the class:
1. getNumNodes(): returns the current number of nodes in
the list.
*/
int getNumNodes()
{
return count;
}
/*
2. add(const string &, const string &, int): Adds an
entry to the end of the list. Arguments passed
correspond to artist name, song title, and bitrate.
*/
void add(const string& addart, const string& addtit, int addbit)
{
Mp3ListNode_ptr new_node = new Mp3ListNode;
strcpy(new_node->mp3.art, addart);
strcpy(new_node->mp3.tit, addtit);
new_node->mp3.bit = addbit;
if (count == 0)
{
new_node->tail = ;
new_node->head =
/* i am completely lost here
3. find(const string &, const string &, int): returns a pointer
to the Mp3 that matches the given arguments (artist, title, and bitrate). If no matching element is found, it returns NULL.
4. del(): deletes all the nodes in the list. No value is returned.
5. del(const string &, const string &, int): deletes the entry
that matches the given arguments (artist, title, bitrate) and
returns true. If no match is found then no deletion takes place
and the method returns false.
6. insert(const string &, const string &, int, int): inserts at the
given index position and returns true if successful. If the index
is out of bounds, then no insertion takes place and the method
returns false.
7. display(): traverses all the nodes and calls each Mp3's display()
method to produce output in the format:
List data - total node count: 6
---------- INDEX 0 -----------
Artist: Nirvana
Title: Smells Like Teen Spirit
Bit Rate: 128 kbits / sec
---------- INDEX 1 -----------
Artist: Fila Brazilia
Title: Tunstall & Californian Haddock
Bit Rate: 128 kbits / sec
*/
|
|
|
|
|
Hi,
I am developing an MFC SDI application on Microsoft Visual C++ 6.0. The development is being done on Windows 95 whereas the deployment will be on Windows 2000.
I would like to know whether anyone out there has done something of this kind - development on Windows 95 and deployment on Windows 2000. I am anticipating some problems as regards API calls.
I would appreciate it if anyone who has had a similar experience get back to us with details!
Thanks,
Arvind
|
|
|
|
|