Reputation: 1
I call the CFileDialog
constructor in the following method:
CFileDialog FileDlg(TRUE, ".txt", NULL, 0, strFilter);
according to the parameters in the CFileDialog
constructor, the first parameter should be BOOL
, but my compiler thinks it's int
instead of BOOL
. Can you tell me why?
Besides, in the code, when I use fopen(str,"r")
, the error is no conversion function from CSring to const char*
. Appreciate your discussion.
The code is:
void OnFileOpen()
{
CClientDC dc(this);
CString str;
CRect rc;
FILE *ifp;
char strFilter[] = { "TXT Files (*.txt)|*.txt|All Files(*.*)|*.*||" };
CFileDialog FileDlg(TRUE, ".txt", NULL, 0, strFilter);
if (FileDlg.DoModal() == IDOK)
{
str = FileDlg.GetFileName();
ifp = fopen(str,"r");
dc.TextOutW(350, 50, "File Opened: " + str);
for (int i = 1; i < n; i++)
{
fscanf(ifp, "%d %d", &pt[i].x, &pt[i].y);
rc = CRect(pt[i].x - 30, pt[i].y - 30, pt[i].x + 30, pt[i].y + 30);
dc.Ellipse(rc);
rc = CRect(pt[i].x - 1, pt[i].y - 1, pt[i].x + 1, pt[i].y + 1);
dc.Rectangle(rc);
}
fclose(ifp);
}
}
Upvotes: 0
Views: 101