|
WhiteSky wrote: ...but what do you need exactly?
He needs to "print the contents of a directory."
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I've installed VS2005, but some of my projects can't be compiled to
debug version, the program will fail on "can't find msvcr80.dll"
message, when launched. However, the release version is ok. And
also some projects can run debug version correctly.
I know 'can't find msvcr80.dll' problem exists on system without .NET framework installed, but that's not my case.
Does anyone know the probably cause???
|
|
|
|
|
I am using this code for inserting the data in msaccess database............
<br />
m_TQuote.Open();
m_bInserting = FALSE;
DoModal();<br />
<br />
GetDlgItemText(IDC_EDIT1,m_TQuote.m_DateTimeStamp,);<br />
GetDlgItemText(IDC_EDIT1,m_TQuote.m_MarketNo);<br />
GetDlgItemText(IDC_EDIT1,m_TQuote.m_Bid);<br />
GetDlgItemText(IDC_EDIT1,m_TQuote.m_MarketName);<br />
GetDlgItemText(IDC_EDIT1,m_TQuote.m_Ask);<br />
GetDlgItemText(IDC_EDIT1,m_TQuote.m_MarketState);<br />
<br />
HRESULT hr = 0;<br />
if (m_bInserting)<br />
{<br />
hr = m_Set.Insert();
}<br />
else<br />
{<br />
hr = m_Set.SetData();
}<br />
m_bInserting = FALSE;<br />
<br />
<br />
But i am getting this error can anybody help me to solve this problem:
Error are :
<
1): error C2664: 'int __thiscall CWnd::GetDlgItemTextA(int,class CString &) const' : cannot convert parameter 2 from 'double' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
2): error C2664: 'int __thiscall CWnd::GetDlgItemTextA(int,class CString &) const' : cannot convert parameter 2 from 'union tagCY' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
3): error C2664: 'int __thiscall CWnd::GetDlgItemTextA(int,class CString &) const' : cannot convert parameter 2 from 'union tagCY' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
4): error C2664: 'int __thiscall CWnd::GetDlgItemTextA(int,class CString &) const' : cannot convert parameter 2 from 'char [51]' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
5): error C2664: 'int __thiscall CWnd::GetDlgItemTextA(int,class CString &) const' : cannot convert parameter 2 from 'union tagCY' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
6): error C2664: 'int __thiscall CWnd::GetDlgItemTextA(int,class CString &) const' : cannot
convert parameter 2 from 'short' to 'class CString &'
>
|
|
|
|
|
parameter 2 of GetDlgItemText must be CString, but these you use are not.
GetDlgItemText(IDC_EDIT1,m_TQuote.m_DateTimeStamp);
~~~~~~~~~~~~~~~~~~~~~~~~~
GetDlgItemText(IDC_EDIT1,m_TQuote.m_MarketNo);
~~~~~~~~~~~~~~~~~~~~
GetDlgItemText(IDC_EDIT1,m_TQuote.m_Bid);
~~~~~~~~~~~~~~
GetDlgItemText(IDC_EDIT1,m_TQuote.m_MarketName);
~~~~~~~~~~~~~~~~~~~~~
GetDlgItemText(IDC_EDIT1,m_TQuote.m_Ask);
~~~~~~~~~~~~~~
GetDlgItemText(IDC_EDIT1,m_TQuote.m_MarketState);
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
This are table field variable....(like :m_TQuote.m_DateTimeStamp etc)
so should i make change in ms access table for this
|
|
|
|
|
change the table or convert the data type to CString first.
|
|
|
|
|
2 parameter of CWnd::GetDlgItemText is CString
|
|
|
|
|
I'm relatively new to the doc/view architecture. I have a splitter and two views (vertical splitter). One of the views is straight-forward stuff that MFC does already. The other view is where I want to:
1) Show a toolbar with buttons at the top.
2) Show a tab control just below that.
3) Show another view below that.
The tab control should switch between 2 to 4 views and should not have any funky borders. That is, the view currently showing below the tab control should look seamless with the tab control.
I've been everywhere on Google and CP. The closest thing I've found is somewhere between CTabView[^], CSDITrueColor[^], and CMDITabs[^]. However, none of these solutions includes a toolbar. I could roll my own control, but I've never done that and that still doesn't tell me how to manage a view inside a control (unless you count the SubView[^] article that doesn't make much sense to me).
I should mention that I don't need icons on my tabs, but I do need a toolbar (which none of the above links have). And I'm looking to do this without buying some expensive package or using WTL.
|
|
|
|
|
dontknowitall wrote: ...none of these solutions includes a toolbar...
The trick to making it easy with MFC is to use a frame window as a "view" and use the actual
CView-derived window as a client window of that frame. Toolbars work nicely with frame windows
(CFrameWnd-derived windows).
So, for your situation, the windows you'll need (from bottom upward in z-order) are
(1) A CFrameWnd-derived window containing a toolbar
(2) A CTabCtrl-derived window used as the "view" (client window) of the frame window (1)
(3) CView-derived window(s) for each tab created as children of the frame window (1) but
always resized in response to WM_SIZE to fit the "client area" of the tab control
(CTabCtrl::AdjustRect() gives you the tab control's "client" rect).
Used this way, there's no need to worry about the toolbar. It stays anchored to the frame (unless
you make it dockable) and the client window (tab control) is automagically kept sized within the
remaining client area of the frame window. You just need to keep track of each tab's window, as
is necessary with tab controls anyway.
dontknowitall wrote: The tab control should switch between 2 to 4 views and should not have any funky borders
Not sure what you mean by "switch between 2 to 4 views " but you can control borders using the
style flags used when creating the different windows.
Hope this helps a bit,
Mark
|
|
|
|
|
Thanks a ton. Your solution sounds a lot better (and simpler) than the solutions I was coming up with. Ignore the last bit you were confused over - it isn't important.
|
|
|
|
|
Have a name followed by 10 int's and it repeats for 15 names. Have a program that will input just the int into a 2d array if no string is involved. Need to somehow input the names from the file (every 11 lines) into a seperate array. Any suggestions?
|
|
|
|
|
Ok, so what part is troubling you? Be specific now. No teasing!
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
File i have the code for is like:
34
34
45
32
....
File i need to be able to get grades from is:
Name
35
54
34
44
34
54
34
54
34
54
Name
34
34
...
Need help on how to somehow get the name strings into an array somehow. As i have it now it is just inputFile >> data[students][tests] which is a declared 2d array with 15 students and 10 tests.
|
|
|
|
|
This is a starting place (it isn't complete, but it should get you started):
#include <string>
#include <vector>
#include <algorithm>
#include <interator>
#include <iostream>
#include <fstream>
class Student
{
public:
Student() : _Name("") {}
~Student() {}
void setName(const std::string& name) { _Name = name; }
std::string& getName() const { return _Name; }
void setGrades(const std::vector<int>& grades) { _Grades.assign(grades.begin(), grades.end()); }
std::vector<int>& getGrades() const { return _Grades; }
private:
std::string _Name;
std::vector<int> _Grades;
};
std::ostream& operator<<(std::ostream& os, const Student& s)
{
os << s.getName() << " ";
const std::vector<int> grades = s.getGrades();
std::copy(grades.begin(), grades.end(), std::ostream_iterator<int>(os, " "));
os << std::endl;
return os;
}
std::istream& operator>>(std::istream& is, Student& s)
{
string name = "";
is >> name;
std::vector<int> grades;
std::copy(std::istream_iterator<int>(is), std::istream_iterator<int>(), std::back_inserter(grades));
s.setName(name);
s.setGrades(grades);
return is;
}
int main()
{
std::ifstream fin;
std::vector<Student> students;
fin.open("MyData.txt");
std::copy(std::istream_iterator<Student>(fin), std::istream_iterator<Student>(), std::back_inserter(students));
fin.close();
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
So in the operator>> method, the Student object that gets passed in is modified (i.e., its setName() and setGrades() methods are called), but the students vector in main() never gets any Student objects added to it. Isn't this what the call to copy() is supposed to be doing?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It should be getting 1 student only (due to the previously mentioned bug in that example). Fixing the bug will allow it to copy all the students in the file to the vector. The easiest way to do this without having to modify the data file format is to modify the input stream extractor to get the id and then calling getline to store the rest of the line as a string. Then create a stringstream object and extract the grades (everything in the streamstream) into the grades vector using a copy operation. Basically, you add 2 lines of code and change the iterators for the grades-copy call.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I'm still learning this C++ stream stuff, so I don't think we are on the same page here, Zac. For an input file having a format of:
bob 1 2 3 4 5
mary 2 3 4 5 6 7
nathan 9 8 7 6
The first line of the file is read correctly by the operator>> method. The name is stored in the name variable, and the grades are stored in the grades vector. Those then get copied successfully to the Student object. The problem is that the students vector in main() does not get any Student objects added to it.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Here is a working example with the data format you gave:
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
class Student
{
public:
Student() : _Name("") {}
~Student() {}
void setName(const string& name) { _Name = name; }
string getName() const { return _Name; }
void setGrades(const vector<int>& grades) { _Grades.assign(grades.begin(), grades.end()); }
vector<int> getGrades() const { return _Grades; }
private:
string _Name;
vector<int> _Grades;
};
std::ostream& operator<<(std::ostream& os, const Student& s)
{
os << s.getName() << " ";
const vector<int> grades = s.getGrades();
copy(grades.begin(), grades.end(), ostream_iterator<int>(os, " "));
os << std::endl;
return os;
}
std::istream& operator>>(std::istream& is, Student& s)
{
string name = "";
is >> name;
string sGrades = "";
getline(is, sGrades);
vector<int> grades;
stringstream ss(sGrades);
copy(istream_iterator<int>(ss), istream_iterator<int>(), back_inserter(grades));
s.setName(name);
s.setGrades(grades);
return is;
}
int main()
{
ifstream fin;
vector<Student> students;
fin.open("data.txt");
copy(istream_iterator<Student>(fin), istream_iterator<Student>(), back_inserter(students));
fin.close();
std::copy(students.begin(), students.end(), ostream_iterator<Student>(cout, "\n\n"));
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thanks, Zac. So by having copy() read from a stringstream rather than a istream , how did that make a difference? The grades vector had the correct number of items added to it either way.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Putting the grades in a stringstream prevents the istream from trying to read the rest of the file. When the istream gets to the end of the file (that is, when the >> returns an eof()) it doesn't add anything to the vector (which is what you were seeing).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
That helps. Thanks.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I came accross this little issue with the a CPrintDialog dialog.
Using the debug build of my code when I display the print setup dialig with the DoModal() method, I get a dialog with the attached printers displayed in a ListView. But in my release build of my code I get a dialog showing the attached printers in a combo-box! Also, in the debug version of the code selecting one of the printers to be the default printer does actually set the selected printer as the default printer but doing the same using the release build the default selection isn't retained by the OS! Both the release and debug builds are using the exact same code and there are no debug defines!
I would appreciate anyones advice on why this is happening, and any way to overcome the problem with the release build not being able to set the default printer, whereas the correct functionality is obtained in the debug build.
|
|
|
|
|
Once again this blasted IDE has brought this neophyte to his knees. My question is: how do you set the system path in Visual Studio 2003. I have been toiling away for the better part of 3 hours to try and get it to see the DLL that's on my hard drive, but it can't see it. Truthfully, I feel like crying.
Alas, any help you can give me would be greatly appreciated - as always.
Peace,
BP
|
|
|
|
|
Here's the search order for DLLs, from the platform SDK
The directory from which the application loaded.
The current directory.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
Windows Me/98/95: This directory does not exist.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The directories that are listed in the PATH environment variable.
|
|
|
|
|
How do I tell it which directory to look in? How do I add another directory to the PATH environment variable? I can't find where to set it.
Thanks,
BP
|
|
|
|