|
I would start with something like
<br />
<br />
class CMyOldGlobals<br />
{<br />
public:<br />
static int AnExampleGlobal;<br />
};<br />
<br />
<br />
int CMyOldGlobals::AnExampleGlobal = DEFAULT_VALUE;<br />
remove the previous extern int AnExampleGlobal and definition of AnExampleGlobal.
#include shared.h wherever you need it and then a run through the compiler will list you all the places where AnExampleGlobal is used as being errors. You'll need to go through each one and change it to
<br />
CMyOldGlobals::AnExampleGlobal;<br />
This will remove all the old externs and global variables but it wont change the semantics of the code at all, the variables are still shared. If you then want to manage the sharing of this data between classes you'll need to do some data hiding and if multi threading is involved they'll all need sychronised access protection.
I hope this helps as a place to start anyway
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hello all,
I want to read excel file from my code. i tried to find out articles but every article used sql command.Can anybody please help me to read it without using sql code.
thanks in advance
|
|
|
|
|
There's really 3 ways I can think of unless you want to reverse engineer the Excel file format.
1.Embed an Excel sheet as an ActiveX control within your app (doesn't have to be visible) and then access the data in it using the Excel object model and COM. This way Excel still gets to read the file and you don't have to.
2.Export the excel file to a .csv file which is really easy to read, just data and commas, and read that.
3.Use ADO or some similar technology to hide all the SQL stuff from you so it's used but you don't have to worry about it.
I'd go for option 2, unless I wanted to write data back it which case I'd probably be rethinking my design.
The Excel ODBC,OLE/DB drivers are notoriously bad anyway. They can't handle spaces in column names and have 3 different types of 0, numeric 0, empty cell 0 and null string 0, which they seem to mix randomly.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
hi,
Can you please tell me the 2nd procedure... how to use it??? give me the idea to export excel file to .csv file....or give me a piece of code of exporting it....
thanks in advance
....
|
|
|
|
|
You can save any Excel spreadsheet as a Comma Separated Value file just by going to the File menu, Choose Save As and select the CSV file type from the drop down list at the bottom of the SaveAs Dialog. I would recommed using the built in macro recorder to record an Excel Macro while you're doing this and that will give you most of the code you need if you want to automate it.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
In addition to Matthew's three suggestions, there's also Excel Automation. Excel exposes a COM interface that can be used quite handily.
"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
|
|
|
|
|
Dear all
I would like to introduce myself first, Omar Ali, MSc student in the research stage, college of Engineering, Baghdad University, Iraq.I am making research on (Active Networking System- Security of Active Networks).I found out throughout my research that I need FTP client under windows to help me accomplishing my research.
I request your kind assistance to help providing me with answer to the following question about "TJFTP" software.
"After a successful compilation under MS VC++6 compiler, the linker is failed in linking the source code files. The linking result is shown below:
Output Window
Compiling resources...
Compiling...
tjftpdoc.cpp
csock.cpp
ftpconnect.cpp
mainfrm.cpp
f:\c projects\tjftp_src\mainfrm.cpp(122) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
f:\c projects\tjftp_src\mainfrm.cpp(123) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
stdafx.cpp
tjftp.cpp
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/TJFTPtest.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Results
TJFTPtest.exe - 4 error(s), 2 warning(s)
What is the problem please? I need correct building of the TJFTP code. I would like to make some modifications to the original TJFTP software (security, for example). I will, surely, refer to the original TJFTP author and site in references of my thesis. "
Knowing that I have been visited your site and find it related (in some cases) to my research.
Your kind assistance in providing me with answers to this question will help me allot to tackle and overcome the problems I am facing in my research.
I highly appreciate your kind assistance. With best regards.
MSc student
O. Ali
Iraq
|
|
|
|
|
Did the demo project and/or source that you downloaded include a project file or solution file?
If so, are you using those?
Make sure the project settings are set to build a multithreaded application.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Did you set /MT for your program?
|
|
|
|
|
Hello
I am writing below code for reading file from disk, But again agian
i am getted failed.
CString str;
CString strLine = "";
CString buffer = "";
CFileDialog Obj(TRUE);
if(Obj.DoModal() ==IDC_BUTTON3)
{
m_Upload = Obj.GetFileName();
}
str.Empty();
str = Obj.GetPathName();
SetDlgItemText(IDC_EDIT1,str);
CStdioFile fileObj;
fileObj.Open("str", CFile::modeRead | CFile::shareDenyWrite);
while(fileObj.ReadString(strLine))
{
fileObj.ReadString(strLine);
buffer += strLine + "\r\n";
}
fileObj.Close();
MessageBox(buffer);
can any one in this community soly this problem .
Regard's
Kaushik
|
|
|
|
|
fileObj.Open("str", CFile::modeRead | CFile::shareDenyWrite);
remove these double quotation mark from str n then try it
fileObj.Open(str, CFile::modeRead | CFile::shareDenyWrite);
|
|
|
|
|
Thanks you so much Sir.
Again thank you. ( it was realy silly mistake by me)
Can you told me how we copy this file to another folder.
Actually i am writing a program in which user can browse .doc and .txt file from Harddisk and save it in database.
Now : i am doing to save .doc or .txt file in a folder on local PC and its name save in database.
I can save its name in database . I am unable to save file in to folder
if you can plz help me
Regard's
Kaushik
|
|
|
|
|
if you want to make a copy of this file in another folder
you have to create a new file using open function and passing the name in 1st parameter then passing second parameter as CFile::modeCreate....
then you read content of already created file an write in this newly created file ......
and your database point is not clear to me...
|
|
|
|
|
suppose new file name is temp. and i want to copy it to UserFile (UserFile is the name of folder located in c:\UserFolder ) then if we write code
for copy file in to folder how we assign the path of folder to file
fileObj.Open(temp,CFile::modeCreate);
its not clear how new file read data from old one and how we assing path its for saving temp to folder.
Regard's
Kaushik
|
|
|
|
|
you can't copy file in a folder but you can create a new file in the folder and then write contents to that file.
For creating new file in the folder u have code
CStdioFile file_ptr;
file_ptr.open("c:\\UserFolder\\UserFile\\temp.txt",CFile::modeCreate|mode::ReadWrite,NULL);
this will create a file in the specified folder with name temp.txt
now if you want to write the content into it open the previous file that contains content.Read the content a write it simultaneously....
|
|
|
|
|
Sir Ji I am very near for solving this problem ( Actually i am making such type of thing first time )
if i wrote this code
CString fname;
fname = fileObj.GetFileName();
MessageBox(fname);
it will be show file name
when i write
fileObj.Open("c:\\UserFolder\\temp.txt",CFile::modeCreate,NULL);
i can create file successfully
But in that case
fileObj.Open("c:\\UserFolder\\fname.txt",CFile::modeCreate,NULL);
file name become fname (Not actual file name) Why??
How can we read contant of old file and copy to new one simultaniously..
can you give me some hint regarding this .
Regard's
Kaushik
|
|
|
|
|
Y_Kaushik wrote: But in that case
fileObj.Open("c:\\UserFolder\\fname.txt",CFile::modeCreate,NULL);
file name become fname (Not actual file name) Why??
Because that's exactly what you told it to do.
Y_Kaushik wrote: How can we read contant of old file and copy to new one simultaniously..
Use the Read() and Write() methods. Start reading the documentation so that you are not asking the most basic of questions.
"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
|
|
|
|
|
Hi,
I have a MFC app with a main form (CMainFrame) and a dialog. How can I call a member function of CMainFrame from another dialog?
|
|
|
|
|
One way is to pass the CMainFrame into your dialog. Another is to use the m_pMainWnd member from your application object like this:
CMainFrame* mainFrame = dynamic_cast<cmainframe *="">(AfxGetApp()->m_pMainWnd);
mainFrame->doThisMemberMethod();
|
|
|
|
|
Hey, I tried that. But while compiling I am getting error:
error C2059: syntax error : ')'
I can't figure out why. Can u please help me?
|
|
|
|
|
Oh!
I looked at MSDN and found the correct way to use it.
The code should be as follows:
<code>
CMainFrame* mainFrame = dynamic_cast<CMainFrame*>(AfxGetApp()->m_pMainWnd);
mainFrame->doThisMemberMethod();
</code>
Thanks.
-- modified at 6:26 Sunday 17th June, 2007
|
|
|
|
|
Ooops. I copied the code from one of my own projects and had to rename things from my class name to CMainFrame. I accidentally erased <cmainframe *="">. Very sorry about that. Glad you still figured it out.
I ran into my own pet peeve of someone giving a code example which doesn't work.
|
|
|
|
|
Hmmm, strange. Apparently I did not erase it. It seems the forum is completely deleting my code. I just typed it again in my previous message and it does not show up in the post.
Somehow it worked when you typed it in your post. I wonder why.
|
|
|
|
|
StevenS_Dev wrote: It seems the forum is completely deleting my code.
No, it's there, albeit not shown. You are just failing to use the angle brackets above the smileys.
"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
|
|
|
|
|
Hi everyone. This is my first post ever :P
I am currently programming a MSVC(no MFC), WIN98/WINXP, TaskManager-like application that enumerates all running processes through PE32, and displays total and hidden HWNDs per PID and running status. Options for killing a PID, show/hide/close hwnds are also available. So far so good.
This program detects via SendMessageTimeout any HWND that is not responding, but what about the ones without any HWNDs? How can I detect if a PID is not responding if it is windowless?
CTRL-ALT-DEL shows (not responding) for the hanged windowless process, and maybe I could use that as a workaround, but I do not know how to access this information either.
Three days so far in the web without success. HELP!!!
|
|
|
|