|
|
i have a structure, call
<br />
struct FileType<br />
{<br />
char type[_MAX_EXT];<br />
char size[20];<br />
<br />
};<br />
<br />
and the text file that looks like
.txt 4140
.tif 4100
.doc 21000
.pdf 3459
.
.
.
so i want to read from the text file and put it into array.
so used vector.
<br />
#include <vector><br />
typedef vector<TypeSize> typeNsize;<br />
<br />
TypeSize typeNsize;<br />
<br />
ifstream filelist("TableOfType.txt",ios::in);
while(!filelist.eof())<br />
{<br />
filelist>>typeNsize.filetype>>typeNsize.size;<br />
<br />
}<br />
filelist.close();<br />
my application is dialog base.
and i have following errors
<br />
<br />
SMPprojectDlg.cpp<br />
E:\SMP\SMPprojectDlg.cpp(2161) : error C2143: syntax error : missing ';' before '<'<br />
E:\SMP\SMPprojectDlg.cpp(2161) : error C2143: syntax error : missing ';' before '<'<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2065: 'TypeSize' : undeclared identifier<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2146: syntax error : missing ';' before identifier 'typeNsize'<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2065: 'typeNsize' : undeclared identifier<br />
E:\SMP\SMPprojectDlg.cpp(2168) : error C2228: left of '.filetype' must have class/struct/union type<br />
E:\SMP\SMPprojectDlg.cpp(2168) : error C2228: left of '.size' must have class/struct/union type<br />
Error executing cl.exe.<br />
<br />
SMPproject.exe - 7 error(s), 0 warning(s)<br />
i was thinking to use CStringArray like read the sentence like
<br />
char info[50];<br />
filelist.getline(info,50,'\n');<br />
CString infoline = (const char*)info;<br />
CStringArray array;<br />
array.add(infoline)<br />
if i do so , i have to separate the string into two parts, type and size, again. i dont' want to do that..
do you have any idea better than what i have right now?
|
|
|
|
|
Try this
================================================
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
/*
Other code here
*/
struct FileType
{
char type[_MAX_EXT];
char size[20];
};
/*
other code here
*/
vector<FileType> v_filetypes;
ifstream filelist("TableOfType.txt", ios::in); //ios:in is optional
while(!filelist.eof())
{
filelist >> v_filetypes.type >> v_filetypes.size;
}
filelist.close();
================================================
That should work fine... I think.. but my brain isn't working the best
|
|
|
|
|
Does anyone know how to remove a sunken style border from a CView? When I use ModifyStyle and ModifyStyleEx on it removing the border flags on it, it doesn't seem to make any difference? Does anybody know a way around this problem?
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Joel, have you tried changing the style in: CJoelsView::PreCreateWindow(CREATESTRUCT& cs)?
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
After you change the style of a window, you need to call SetWindowPos in order to force a repaint of the frame. make this call:
::SetWindowPos(hWnd, NULL,0,0,0,0, SWP_NOMOVE SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE);
BTW, this is in the documentation for SetWindowLong.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I've just written this line of code:
CFrameWnd *fw= (CFrameWnd*)AfxGetMainWnd();
It lies in the OnCreate handler of a docking window, but for some reason the pointer returned by AfxGetMainWnd is not the expected CFrameWnd, but a pointer to a CToolTipCtrl . This I don't really understand. Does anybody know why the problem occures, or how to fix it? Thanks for your time.
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Joel Holdsworth wrote:
It lies in the OnCreate handler of a docking window, but for some reason the pointer returned by AfxGetMainWnd is not the expected CFrameWnd, but a pointer to a CToolTipCtrl .
How do you know it is pointing to a CToolTipCtrl? As an aside it isn't a good idea to use the old C style casts. In this case use a dynamic_cast.
Is the OnCreate running in a seperate thread to the main app code?
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Joel Holdsworth wrote:
AfxGetMainWnd
Basically all it does is to return the m_pMainWnd member! You sure you are not meddling with m_pMainWnd soewhere else?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
... please check out my post in the requests form? Thanks in advance...
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
You know.. .You might get flamed to a crisp for that.. but I won't be the one doing it. I don't think I can be of any help though. Sorry
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
Hello,
I've just read an article here saying how to enumerate the data in windows' protected storage.
http://www.codeproject.com/w2k/pseenuma.asp
I can't understand , without having a COM calss being registered, declared and Created at runtime, how are we able to access its methods and properties?
I would be glad if anyone can give me an example for doing this.
|
|
|
|
|
hi.. all
i have a function that travel the file tree( like window explore ), get the tree item, calculate the file size, and estimate how many page will print. and print to the .txt file.
the function is doing ok. it is fast when estimating all files( let's say 1000 files). but for 12000 files, so.. slow. for 35000 files, even worst. it took 10 minues to finish all travel, get file size, do caculation, and write to the file. i found out for that 35000 files, the txt file has 238 pages, which is the reason it took 10 minues, i guess.
here how i print to file.
1. open file -> ofstream file; file.open("c:\estimated.txt");
2. do estimate-> get file size and calculate
3. print to file -> file<
|
|
|
|
|
Are you opening the file each time you write to it? If so, you might consider keeping the file open for the duration of the whole scanning process. This should speed your app up by orders of magnitude.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
If your opening the file each time then that woudl slow it down. Just open at the begining of your app and close at the bottom.
ofstream outFile("estimated.txt");
and then close it
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
yes.. i do open the file very top and close it after tree travesal, and calculation for all has finished.
but thanks i have another file which is getting the size of the file open and close for each file. i will put that into array and read it from array. hope that will speed my estimate page function.
thanks guys
|
|
|
|
|
Win wrote:
i will put that into array and read it from array. hope that will speed my estimate page function.
Try using a vector... itmight work quicker than an array. Especially if your filling it with lots of info... and it's dynamic too [and genreic]
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
oh.. i was trying to use it.. can you check my post which way is better.. no. let me post it back here again.
i have a structure, call
<br />
struct FileType<br />
{<br />
char type[_MAX_EXT];<br />
char size[20];<br />
<br />
};<br />
<br />
and the text file that looks like
.txt 4140
.tif 4100
.doc 21000
.pdf 3459
.
.
.
so i want to read from the text file and put it into array.
so used vector.
<br />
#include <vector><br />
typedef vector<TypeSize> typeNsize;<br />
<br />
TypeSize typeNsize;<br />
<br />
ifstream filelist("TableOfType.txt",ios::in);
while(!filelist.eof())<br />
{<br />
filelist>>typeNsize.filetype>>typeNsize.size;<br />
<br />
}<br />
filelist.close();<br />
my application is dialog base.
and i have following errors
<br />
<br />
SMPprojectDlg.cpp<br />
E:\SMP\SMPprojectDlg.cpp(2161) : error C2143: syntax error : missing ';' before '<'<br />
E:\SMP\SMPprojectDlg.cpp(2161) : error C2143: syntax error : missing ';' before '<'<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2065: 'TypeSize' : undeclared identifier<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2146: syntax error : missing ';' before identifier 'typeNsize'<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2065: 'typeNsize' : undeclared identifier<br />
E:\SMP\SMPprojectDlg.cpp(2168) : error C2228: left of '.filetype' must have class/struct/union type<br />
E:\SMP\SMPprojectDlg.cpp(2168) : error C2228: left of '.size' must have class/struct/union type<br />
Error executing cl.exe.<br />
<br />
SMPproject.exe - 7 error(s), 0 warning(s)<br />
i was thinking to use CStringArray like read the sentence like
<br />
char info[50];<br />
filelist.getline(info,50,'\n');<br />
CString infoline = (const char*)info;<br />
CStringArray array;<br />
array.add(infoline)<br />
if i do so , i have to separate the string into two parts, type and size, again. i dont' want to do that..
do you have any idea better than what i have right now?
|
|
|
|
|
Try this
================================================
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
/*
Other code here
*/
struct FileType
{
char type[_MAX_EXT];
char size[20];
};
/*
other code here
*/
vector<FileType> v_filetypes;
ifstream filelist("TableOfType.txt", ios::in); //ios:in is optional
while(!filelist.eof())
{
filelist >> v_filetypes.type >> v_filetypes.size;
}
filelist.close();
================================================
That should work fine... I think.. but my brain isn't working the best
|
|
|
|
|
wow!!!
i use cstringarray to store files types and sizes
as follow:
<br />
char info[50];<br />
CStringArray array;<br />
ofstrea filelsit.open("type.txt");<br />
while(!filelist.eof())<br />
{<br />
filelist.getline(info,50,'\n');<br />
CString infoline = (const char*)info;<br />
array.add(infoline)<br />
}<br />
guess what it only tooks 16 sec to read and estimate page to print for all 350000 files.
compare to old function, way way faster. old function took 10 mins and now only 16 sec.
i say WOW
let me try to use vector.. i think vector might be faster because i dont' have to separator type and size again.
|
|
|
|
|
Win wrote:
way way faster. old function took 10 mins and now only 16 sec
I'd say thats a good improvement!!!
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
|
Since a process can have multiple heaps, load DLL's at rather high addresses (eg kernel32.dll is loaded somewhere at 0x77xxxxxx IIRC) I think it's a rather unusable piece of information.
If you on the other hand was interested in what address (and with what length) a PE was mapped at you can use VirtualQuery(). To see what heaps a process has (and how large they are ...) you can use GetProcessHeaps() + HeapWalk().
|
|
|
|
|
Hi.
I would like to limit the number of characters a user make enter at any given time to a finite integer. For example, let say I have an edit box in a dialog box for entering zip code. I would like to limit the number of characters to *exactly five*.
I have tried using DDV verification feature in a dialog box. However, I found that the user can overflow the edit box. For example:
limit: 500
User: 500000
If the user overflow the edit box, for DDV will consider the data entered as being valid. I believe the problem has something to do with overflowing a datatype.
Nonetheless, what is the best way to limit the number of characters/digits entered in an edit box?
Thanks,
Kuphryn
|
|
|
|
|
Have a look at Alvaro Mendez' article Validating Edit Controls. He provides several CEdit -derived controls for limitting user input --I guess they can serve your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|