|
Can anyone tell me how to put an MFC Dialog box project into another existing project in visual studio C++ 6.o.
Thanks
Vladimir
|
|
|
|
|
Menu "project" option "add to project" and then including whatever you need wherever you need it
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hello MDV,
That didn't worked. Can you give me an example how to fit a dialog box class into an exisiting project.
Greetings,
Vladimir
|
|
|
|
|
|
It didn't worked. Can you show me an example how you do that?
greetings,
Vladimir
|
|
|
|
|
Ok, First of all take a look on the link Hans Dietrich gave you.
Anyways... what I told you should work, I have added classes to my project and I had no problems. The only thing you have to take care is to create a resource to fit your DialogBox. I mean, you create an empty DialogBox, close it, goes to the file *.rc in the *.cpp path and edit it.
A trick to do this is to look for the name of a resource into all the files of the project, I mean... just added a DialogBox had the IDD_DIALOG1 name, just use this in the search, the results will come where below in "Search in files1" (1st option is the compiler errors, 2nd debug, 3rd "search in files1", 4th search...) Open the ApplicationName.rc file with a doble click there. Then you will see a file with ALL your resources of the active project in code, not in grafics.
Look for your IDD_DIALOG1 (or the name you wanna give to it), erase the contents and replace it with the code of the dialog you wanna import. That will let you to have the new dialog with all the references/names of the old one.
After this, reboot your VC++ and you should have the Dialog in your resources as it is. Doubleclick to create an associated class, remove the new files and add the *.cpp and *.h of the dialog.
The only problem with it is that a DialogBox-based application can have some code that collisionate with the intialisation of a DOC-View app. But is nothing that you can't deal.
Anyways, I have taken a look to Hans Dietrich article and it will work very good, and its "cleaner". What I told you is a "bruto"'s way.
Good luck and have fun
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hi
Here is the Problem:
To access a Datafile which contains 26 Million addresses and find a given address. The Datafile is an ascii text file and is fixed
What I have come up with:
1. Sort the 26 Million addresses into Postcode order. (I have application for this)
2. Using FSEEK look at the MIDDLE of the file and compare using STRNCMP the POSTCODE for searching, against the POSTCODE within the Datafile.
3. Using the result move the file pointer backwards from the middle (half it) or forwards and keep checking until a match is found.
This will loop for roughly 24-25 times and not 26 Million.
Is there a better way?
|
|
|
|
|
|
Thank you, I will have a look at these.
|
|
|
|
|
Probably the easiest way to speed searching is to divide the big file into N smaller files, maybe organized by a partial postcode. Then, after you have selected the correct (smaller) file, the search will be that much faster. This involves a minimum or presort setup.
|
|
|
|
|
Thank you, that sounds like a good idea.
|
|
|
|
|
Hi
I have recently upgraded from Windows 2000 to Windows XP Professional and have noticed that when I run my applications the progress bar stops and the application looks as if it has crashed, but after a while finishes.
I have Mcafee Virus protection running in the background, is this causing the problem?
The code is a simple "UpdateData(FALSE)" instruction after setting the ProgressBar.SetPos() which is looping until an EOF instruction.
Any Ideas?
Thank you in advance
Brian.
|
|
|
|
|
1. Disable McAfee and observe the result.
2. Put a ProgressBar.RedrawWindow(); after the UpdateData(FALSE); and observe the result.
|
|
|
|
|
Unfortunately this has not solved the problem.
Thanks for trying.
|
|
|
|
|
After your UpdateData(FALSE) add a
ProgressBar.UpdateWindow()
I believe that will solve your problem.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Why do you need to call UpdateData? Are other controls changing or just the progress control?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
I am using the following program to delete all files in a specified directory. But when running, no files could be deleted, and the related error information is,
failed with error 5 -- access denied. Anything wrong with the program?
<br />
remove_non_empty_directory ("c:\\temp\\non_empty_dir\\*");<br />
<br />
<br />
int remove_non_empty_directory (const char* path)<br />
{<br />
<br />
WIN32_FIND_DATA FindFileData;<br />
HANDLE hFind;<br />
int rtn;<br />
<br />
hFind = FindFirstFile(path, &FindFileData);<br />
if (hFind == INVALID_HANDLE_VALUE) <br />
{<br />
FindClose(hFind);<br />
return -1;<br />
} <br />
else <br />
{<br />
rtn = DeleteFile(&(FindFileData.cFileName));<br />
<br />
if (0 == rtn)<br />
{<br />
ErrorExit (NULL);<br />
}<br />
<br />
while (FindNextFile(hFind, &FindFileData) != 0) <br />
{<br />
rtn = DeleteFile(&(FindFileData.cFileName));<br />
}<br />
<br />
FindClose(hFind);<br />
}<br />
<br />
return 0;<br />
<br />
}<br />
thanks in advance,
George
|
|
|
|
|
Do you have permissions to delete from that folder, have you tried deleting a file manually through explorer ?
|
|
|
|
|
Sure Jonathan, I have the privilege. I am admin and I can manually delete such files. I think there should be something wrong with my program, but through debugging for almost an hour, I still can not find the reason. Any ideas?
regards,
George
|
|
|
|
|
I think the problem is that the first file you will 'find' is the current folder '.', you will get an access denied if you try to delete this, so you need to exclude both '.' and '..' from your wildcard search, something like this (obviously could be optimised, this is just to show an example):
Also, you could make it recursive if you wanted to delete sub folders too.
int remove_non_empty_directory(const char* path)
{
WIN32_FIND_DATA FindFileData;
int rtn;
HANDLE hFind = FindFirstFile(path, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
FindClose(hFind);
return -1;
}
else
{
bool bDelete = true;
if((_tcsicmp(FindFileData.cFileName, "..") == 0) || (_tcsicmp(FindFileData.cFileName, ".") == 0))
bDelete = false;
if(bDelete)
{
rtn = DeleteFile((LPCSTR)FindFileData.cFileName);
}
while (FindNextFile(hFind, &FindFileData) != 0)
{
bDelete = true;
if((_tcsicmp(FindFileData.cFileName, "..") == 0) || (_tcsicmp(FindFileData.cFileName, ".") == 0))
bDelete = false;
if(bDelete)
rtn = DeleteFile((LPCSTR)FindFileData.cFileName);
FindClose(hFind);
}
return 0;
}
And change this code:
DeleteFile(&(FindFileData.cFileName));
to this:
DeleteFile((LPCSTR)FindFileData.cFileName);
regards,
-- modified at 7:09 Monday 30th July, 2007
|
|
|
|
|
Thanks Jonathan,
I have tried and slightly modified your program to make it compile.
Now the error condition is, error number 2 -- system can not find specified file. I am confused since the file actually exists.
I need to using absolute path other than relative path to delete the file?
<br />
int remove_non_empty_directory(const char* path)<br />
{<br />
WIN32_FIND_DATA FindFileData;<br />
int rtn;<br />
HANDLE hFind = FindFirstFile(path, &FindFileData);<br />
int bDelete = 0;<br />
<br />
if (hFind == INVALID_HANDLE_VALUE)<br />
{ <br />
FindClose(hFind);<br />
return -1;<br />
}<br />
else<br />
{<br />
if((_tcscmp((LPCSTR)FindFileData.cFileName, "..") == 0) || (_tcscmp((LPCSTR)FindFileData.cFileName, ".") == 0))<br />
{<br />
bDelete = 0;<br />
}<br />
if(bDelete)
{<br />
rtn = DeleteFile((LPCSTR)FindFileData.cFileName);
}<br />
while (FindNextFile(hFind, &FindFileData) != 0)<br />
{<br />
bDelete = 1;<br />
if((_tcscmp((LPCSTR)FindFileData.cFileName, "..") == 0) || (_tcscmp((LPCSTR)FindFileData.cFileName, ".") == 0))<br />
{<br />
bDelete = 0;<br />
}<br />
if(bDelete)<br />
{<br />
rtn = DeleteFile((LPCSTR)FindFileData.cFileName);<br />
if (0 == rtn)<br />
{<br />
ErrorExit (NULL);<br />
}<br />
}<br />
}<br />
FindClose(hFind);<br />
}<br />
<br />
return 0;<br />
}<br />
regards,
George
|
|
|
|
|
which line is producing error 2, and what is the value of FindFileData.cFileName at that point ?
|
|
|
|
|
Relative file name.
regards,
George
|
|
|
|
|
George_George wrote: I have tried and slightly modified your program to make it compile.
George_George wrote: I need to using absolute path other than relative path to delete the file?
Yes, in this case you should.
regards,
|
|
|
|
|
Thanks Jonathan,
I have tried that if I am using absolute path, it works!
regards,
George
|
|
|
|