|
If you click on cancel, won't the app close? Care to explain your problem?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
v.j wrote: ...my application are not working there is sum error...
Would that be error A or error B?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
v.j wrote: my application are not working there is sum error
That is very poor description of your error. Without knowing what it is, no one can really help.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
|
dear all
i already added in main function #include <iomanip> and using std::setw. why after i use cout statement setw(3)..no response..what happened?thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
If cout is used, include iostream.h
Come online at:-
jubinc@skype
|
|
|
|
|
already added it,any other problem? thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
Please post the code and state what you expect the code should do.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
the code is following:
double a[3][4];
for (int j = 0; j <<10; j++)
{
double a[3][4] = {{(double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX,( double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX}};
cout<< setw(3)<< "Particle" << setw(3) << j << endl << endl;
for (int i = 0; i<< 3; i++)
{
for (int j = 0; j<< 4; j++)
cout <<setw(3)<< setprecision(6) << fixed << showpoint << a[i][j]<< " ";
cout << endl;
}
cout<< endl;
}
how to save each array a and the setw is not available....
Li Zhiyuan
5/10/2006
|
|
|
|
|
Anybody have an opinion on include guards:
#ifndef _thisheader_h_included
#define _thisheader_h_included
versus using pragma once?
#pragma once
I suppose the pragma directive is less portable across platforms, but is that the only issue?
|
|
|
|
|
Efficiency?
MSDN [^] states
#pragma once
Specifies that the file will be included (opened) only once by the compiler in a build. This can reduce build times as the compiler will not open and read the file after the first #include of the module.
hence I guess that #pragma once may speed up compilation with respect header guards. But it is only a guess.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: hence I guess that #pragma once may speed up compilation with respect header guards. But it is only a guess.
Yeah, I wasn't sure either, that's why I asked.
|
|
|
|
|
the #include guards are portable - but they require the header file to be parsed again by the preprocessor, since I could do something like that:
#ifndef FOO_H_
#define FOO_H_
#ifdef SECOND_TIME
#endif
#endif
#include "foo.h"
#undef FOO_H_
#define SECOND_TIME
#include "foo.h"
So the pragma is a stronger statement than include guards, and allows to compiler to ignore the file completely (ideally avoiding extra disk access)
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
Of course, we can have something like:
#define true false
#define private public
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
my point is that the compiler has to respect these things - so the include guards can't easily prevent the preprocessor from running again.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
I understood and I must agree with that point. But it just came to my mind, how nastier coding can be.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
As you know, both are doing the same thing. I doubt if pragma once would even speed up the compilation time in comparison with ifndef. That should depend on how they've implemented it though. Unless there is a strong reason to use pragma once, I'd use ifndef, because it is more portable.
There is no great difference, otherwise.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
modified on Saturday, January 19, 2008 5:55:50 AM
|
|
|
|
|
So it's basically just a portability issue then. That's what I was thinking.
Thanks!
|
|
|
|
|
once is the hint toward speed up hypothesis (but is only a guess, I agree).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hi Chris. First of all I am thankful to you for a wonderful grid control with entire source code that u have provided here on CP. Also want to thank for the revisions, additions, add-ons, database connectivity and other utilities related to the MFC Grid posted by various users on CP. I am one person making use of it in one of my applications where there is a requirement to display elements in 2-d/3-d data in a matrix form.
For 2-d arrays it is simple matrix-type table with rows and columns. For 3-d arrays, however, I have to make the cells combo-boxes and display the third dimension elements in the combo box. And I have done it. However, there is a need for my application to get hold of the combo-box inside the cells that is created at runtime. I want to set the contents of my application based on the element selected by the user in the combobox. In short, I want to perform all the operations related to a combo-box, that is created in every cell of the grid. And I want to set the cell text to the selection made by the user in the combo-box, which happens automatically ofcourse. However, after selection, I have to get the index selected inside the combo box and store it in a 2-d int array on the execution of the command button. And conversely I have to set the cell text from a 2-d int array holding the combobox from this array. I am using Visual Studio 2005 and my OS is Windows XP.
Here is the part of the code:
void CTest_GridView::OnInitialUpdate()
{
CTest_GridDoc * pDoc = (CTest_GridDoc*)GetDocument();
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
int count = 0;
for(int a = 0; a < 10; a++)
{
for(int b = 0; b < 10; b++)
{
for(int c = 0; c < 10; c++)
{
count++;
pDoc->m_nDataArray[a][b][c] = count;
}
}
}
this->m_Grid.SetRowCount(m_nRows);
this->m_Grid.SetColumnCount(m_nCols);
this->m_Grid.SetFixedRowCount(m_nFixedRows);
this->m_Grid.SetFixedColumnCount(m_nFixedCols);
CString sz;
for (int x = 1; x < m_Grid.GetColumnCount(); x++)
{
sz.Format(_T("%d"), x);
this->m_Grid.SetItemText(x, 0, sz);
this->m_Grid.SetItemText(0, x, sz);
}
for (int i = 1; i < m_Grid.GetColumnCount(); i++)
{
for (int j = 1; j < m_Grid.GetRowCount(); j++)
{
m_Grid.SetCellType(i, j, RUNTIME_CLASS(CGridCellCombo));
m_Grid.SetItemText(i, j, _T("My Number"));
CString str;
CStringArray options;
for(int k = 0; k < 10; k++)
{
str.Format(_T("%d"), pDoc->m_nDataArray[i-1][j-1][k]);
options.Add(str);
str.Empty();
}
CGridCellCombo *pCell = (CGridCellCombo*) m_Grid.GetCell(i,j);
pCell->SetOptions(options);
pCell->SetStyle(CBS_DROPDOWN);
}
}
}
....
....
....
void CTest_GridView::OnBnClickedButtonFix()
{
CTest_GridDoc * pDoc = (CTest_GridDoc*)GetDocument();
CString sz;
int num = -1;
for (int i = 1; i < m_Grid.GetColumnCount(); i++)
{
for (int j = 1; j < m_Grid.GetRowCount(); j++)
{
CGridCellCombo * pCell = (CGridCellCombo*)m_Grid.GetCell(i, j);
CWnd * pWnd = pCell->GetEditWnd();
CComboBox * pCmb = (CComboBox*)pWnd;
if(pCmb->GetCurSel() != CB_ERR)
num = pCmb->GetCurSel();
else
num = 0;
pDoc->m_nIndexArray[i-1][j-1] = num;
pCmb->GetLBText(num, sz);
pDoc->m_nComboText[i-1][j-1] = sz;
sz.Empty();
}
}
}
I am using Visual Studio 2005 and the OS is Windows XP SP2. I have used a formview in a SDI application to display the grid and the button.
Thank you,
Bhushan.
|
|
|
|
|
It seems you used of Chirs's article if you have any question about that article you can ask on that article forum.
|
|
|
|
|
Hey...I tried to do so....but when I went to Desktop Development | Miscellaneous | MFC Grid Control 2.26 link, I was navigated to a page where it said page not found and suggested an alternate location which was having a different link. Even after clicking the link the page would not change! So I do not know where to search. Besides, this site previously had a different layout with a distinct area for Visual C++ programming. Now I do not seem to find those familiar links. However, I had managed to find the link today itself before I posted this message. However, the same location is giving me an error now. This has added to all the clutter and nebulousness. I dunt know what to do. By the way, I thought it would be best to go to Chris Maunder's personal profile page and post my question so that he can help me out with it. Anyway, once I find the article it would be miracle and then I would post my Q there...
Thanks,
Bhushan.
|
|
|
|
|
Well, no articles were opening for about a while. There was a problem with the site and it is resolved now.
You can view the grid control article by clicking here[^].
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi. thank you for the clarification. My other question was, why would CP change the previous design of the website of having a systematic navigation for each of the programming environments?
Thank you,
Bhushan.
|
|
|
|
|
You can still systematically navigate through the website. If you have a genuine problem, you should report it at the site issues forum.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|