|
Hi all!
I have 2 dimensional array but whenever i make a loop to travers it and output the result, it display some weird number such as -858933448 ans so on
Here is my function call:
pDoc->A.getLadder(ladder);
for(row = 0; row <4; row++)
{
CString team = pDoc->A.getTeam(ladder[row][TEAM]);
int played = ladder[row][PLAYED];
int won = ladder[row][WON];
int draw= ladder[row][DRAW];
int lost = ladder[row][LOST];
int f0r = ladder[row][FOR];
int against = ladder[row][AGN];
int points= ladder[row][POINTS];
CString tempString;
tempString.Format("%s = %d = %d = %d = %d == %d == %d == %d",
team, played, won, draw, lost, f0r, against, points);
lineArray.push_back(tempString);
tempString = " ";
}
thanks!
|
|
|
|
|
Show the code for A.getLadder
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
here is the code for getLadder
void Group::getLadder(int ladder[4][8])
{
Sort();
for(int i = 0; i < 4; i++)
for (int j = 0; j < 8; j++)
ladder[i][j] = aILadder[i][j];
}
and here is the sort function that is placed within the class but is declared as private.
void Group::Sort()
{
const int TEAM = 0;
const int PLAYED = 1;
const int WON = 2;
const int DRAW = 3;
const int LOST = 4;
const int FOR = 5;
const int AGN = 6;
const int POINTS = 7;
int row, col;
for( row = 0; row < 4; row++)
{
for (col = 0; col < 4 ; col++)
{
if( row != col)
{
aILadder[row][TEAM] = row;
if(result[row][col] > result[col][row] && result[row][col] != -1)
{
aILadder[row][PLAYED] +=1;
aILadder[row][WON] += 1;
aILadder[row][FOR] += result[row][col];
aILadder[row][AGN] += result[col][row];
aILadder[row][POINTS] += 3;
}
else
if(result[row][col] == result[col][row] && result[row][col] != -1)
{
aILadder[row][PLAYED]+=1;
aILadder[row][DRAW]+=1;
aILadder[row][FOR] += result[row][col];
aILadder[row][AGN] += result[col][row];
aILadder[row][POINTS]+=1;
}
else
if(result[row][col] < result[col][row] && result[row][col] != -1)
{
aILadder[row][PLAYED]+=1;
aILadder[row][LOST]+=1;
aILadder[row][FOR] += result[row][col];
aILadder[row][AGN] += result[col][row];
}
}
}
}
int tempArr[1][8];
int j, target;
for(row = 1; row < 4; row++)
{
j = row;
target = aILadder[row][POINTS];
while(j > 0 && target > aILadder[j-1][POINTS])
{
for(int i = 0; i < 8; i++)
{
tempArr[0][i] = aILadder[j-1][i];
aILadder[j-1][i] = aILadder[j][i];
aILadder[j][i] = tempArr[0][i];
}
j--;
}
}
}
Thanks
|
|
|
|
|
Obviously there is a problem with the stmt
pDoc->A.getLadder(ladder);
I think that the pointer being returned is not correct.
What is the decl of getLadder ?? Is it accepting a
pointer to a pointer (**p??).
Also if a pointer is being returned I think that you
should use the pointer notion for retrieving the
elements
So if you want to have [i][j]
*(p + i*nSize + j)
where nSize is the size of the array's first index.
PS: Its been long since I have worked with this kind of
pointers to arrays (So just off the top of my head i remembered that
arrays are contigious locations and formulated the above code).
Please correct me if it is wrong
|
|
|
|
|
Hi,
I want to show all the directory (directory structure)
in the Tree View
How can i do that
Sameer
|
|
|
|
|
CTreeCtrl::Expand
Use the root node as the HTREEITEM and TVE_EXPAND as the 2nd arg
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Hi,
I'am sory, but i guess u misunderstood my problem.
Actually i want to display a tree view in which all
the directories of the Drive are listed
Sameer
|
|
|
|
|
Sameer Maggon wrote:
Actually i want to display a tree view in which all
the directories of the Drive are listed
Sorry
What you need is SHBrowseForFolder
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
look at the foll,. article at Codeguru
http://www.codeguru.com/treeview/CDirTreeCtrl.shtml
|
|
|
|
|
Hi,
I saw that Control, but that control is too heavy.
I just want to Display the Directories and not the
Files etc.
Actually i just want to give a user, selection of a
Directory.
Please help
Sameer
|
|
|
|
|
You can limit the tree to one level.
Best regards,
Alexandru Savescu
|
|
|
|
|
Sameer Maggon wrote:
Actually i just want to give a user, selection of a
Directory.
Already told you. Use SHBrowseForFolder
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Use the foll. code
CString GetUserDirectory()
{
CString strPath ;
char szDisplayName[_MAX_PATH] ;
char *szPath = NULL ;
char *szTitle = _T(" Please Locate Directory : ") ;
BROWSEINFO bi = {0} ;
bi.pszDisplayName = &szDisplayName[0] ;
bi.lpszTitle = szTitle ;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS ;
bi.hwndOwner = NULL ;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi) ;
if( pidl == NULL )
return strPath ;
if( !SHGetPathFromIDList(pidl,szPath) )
{
AfxMessageBox(" The Path is Invalid ! ") ;
return strPath ;
}
IMalloc *pMalloc = NULL ;
HRESULT hr = SHGetMalloc(&pMalloc) ;
if( !SUCCEEDED(hr) )
return strPath ;
pMalloc->Free( (void*)pidl ) ;
pMalloc->Release() ;
strPath = szPath ;
return strPath ;
}
<pre>
|
|
|
|
|
Thanx for the code, but i had already written the application using MSDN.. Thanx a lot again for the help.
Regards
Sameer
|
|
|
|
|
Do I have to CoInitialize() and Uninitialize()
???
|
|
|
|
|
Thanx a lot Nish.
This solves my problem
|
|
|
|
|
See this article.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
All
I have a Server running which listens on a particular port and
according to the XML sent to it, it sends a JPG file (a binary stream).
Now this XML would be sent by my ASP page. I know i can do
this using ActiveX component.
Please suggest me (no code, just algo types) how to go about
it
Thanx
Sameer
|
|
|
|
|
Hi, How do I determine when the user has finished entering text in an edit box. In other words, how do I know he has pressed the enter key and has completed typing in the text.
Rui
|
|
|
|
|
Write a handler for EN_KILLFOCUS
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Sorry, I should have expressed myself better.
I know about Killfocus, but this requires that the user clicks elsewhere so that the focus on the edit box may be lost. Is there no other way?
Is there a way to call an event when the Enter key is pressed?
I tried using OnKeyDown, but am not sure how it works as I got no action from this event.
Rui
|
|
|
|
|
Hi,
You cannot trap enter from an edit box in the parent, you need to
derive a new class from CEdit and process the WM_CHAR mesgs
|
|
|
|
|
|
Haven't tried it now, but I think you can use PreTranslateMessage to get the WM_CHAR for the edit box, so you don't need to subclass it.
Another thing is, usually you have a default button in your dialog, so pressing enter will activate the default button, and the edit box gets an EN_KILLFOCUS message.
Martin
|
|
|
|
|
You wont get WM_KEYDOWN/WM_KEYUP messages in a dialog based application. I have written an article on how to go about trapping keys in dialog apps.
http://www.codeproject.com/useritems/pretransdialog01.asp
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|