|
mostafa_pasha wrote: is that anyway that call CMyDialog's function from CMyFile
class?
Sure, but why would you want to? By allowing CMyFile access to the internals of CMyDialog , you have thus tied the two together (i.e., encapsulation). It's especially troublesome if you are wanting CMyFile to manipulate a UI component (e.g., progress bar) that CMyDialog owns. You should be posting a message to CMyDialog instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
did you try it?
CMainClass *m_Main=(CMainClass*)GetParent();
m_Main->your variables
|
|
|
|
|
Hi,
it does not work.
GetParent get one argument as HWND.
i change it ,
<br />
CMainClass *m_Main=(CMainClass*)GetParent(theApp.GetMainWnd()->m_hWnd);<br />
but in dialog base application , compiler say " error C2065: 'theApp' : undeclared identifier"
now how can i get pointer to CVerApp class?
CVerApp * = ???;
which function exist to point to my CVerApp?
Best Regards.
M.J.M.
|
|
|
|
|
How to use this file if you use of GetParent(m_hWnd) what happens?
|
|
|
|
|
I have progress bar, i want to change position from
my CMyFile class ! CMyFile class is generic class!
i just want to change position of bar from my CMyFile
so first , i get pointer to my dialog class form CMyFile!
then call function SetPos() of my prograss bar class .
How can i do that?
best regards.
MJM
|
|
|
|
|
if this pointer is valid you dont have problem and you must create this pointer once and again use of it for call your class,I hope it helpful for you but if you have problem you can ask
|
|
|
|
|
Hello all,
I need to find out one of those things for which msdn or other website are almost a useless reference.
I need to check if a file exists in a given folder.
I am sure there is a function that just returns true if the file exists but there is no way I can find it on the web.
Can anyone help?
Ciao
Giulio
|
|
|
|
|
How about the OpenFile() Windows API using the OF_EXIST flag?
Mark
|
|
|
|
|
Giulio2000 wrote: I need to find out one of those things for which msdn or other website are almost a useless reference.
Well, this question certainly is NOT one of those. MSDN, CP, and Google will all give you quick results for this question.
Giulio2000 wrote: I need to check if a file exists in a given folder.
Are you using MFC, Win32 API directly, or standard C++? Depending on which library you want to use, there are several options available to give you this answer. Here is the MSDN link[^] for the MFC way.
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 am using MFC.
Thanks for the replies. Trying to open the file with a NO_CREATE option is the obvious solution but it is actually more that I need doing.
There must be a function like IfFileExists(<path to="" file="">) somewhere in MFC but there is no word combination that will give me sensible results on the web.
Ciao
Giulio
|
|
|
|
|
MSDN: Accessing File Status[^]
CFile theFile;
char* szFileName = "c:\\test\\myfile.dat";
BOOL bOpenOK;
CFileStatus status;
if( CFile::GetStatus( szFileName, status ) )
{
bOpenOK = theFile.Open( szFileName,
CFile::modeWrite );
}
else
{
bOpenOK = theFile.Open( szFileName,
CFile::modeCreate | CFile::modeWrite );
}
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
What's wrong with _access(..., 0) , which is just a thin wrapper around GetFileAttributes() ?
You could also use _stat() , which is a wrapper around FindFirstFile() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: What's wrong with _access(..., 0)?
or _stat ?
Unicode?
|
|
|
|
|
Sceptic Mole wrote: or _stat?
Nothing that I know of. Why?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You can try:
BOOL PathFileExists( LPCTSTR pszPath );
-----------
Mila
|
|
|
|
|
I usually use GetFileAttributes() and check return value (and possibly GetLastError())
--
Filmed on Location
|
|
|
|
|
You can use of FindFirstFile and check return value of this file if file is exist it return a valid handle else null
|
|
|
|
|
Try opening it. If it fails, it doesnt exist.
Truth is the subjection of reality to an individuals perception
|
|
|
|
|
Thanks to you all.
In the end I will the easiest. I will try to open it to read and then check if it is open:
ifstream InSettingsFile(pDoc->ExecutablePath + "Settings.cfg",ios::nocreate);
if (!InSettingsFile.is_open())
{
AfxMessageBox("File does not exists");
}
The PathFileExists function looked promising but then you need some include which I don't seem to have or something. You know, I am beginner with this stuff and don't really have the time to look for "optimal" solutions.
Ciao
Giulio
|
|
|
|
|
You are right.
You know, I am beginner with this stuff and don't really have the time to look for "optimal" solutions.
Some of us here are very experienced developers, and WE don't always have the time to provide you with optimal solutions either ...
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
I dynamically created a button "View" on sub-class of CPropertySheet.
when I press F1 key then click the button, system (?) displays a message "No help topic is associaated with this item".
how to hide or disable the message because I want to use F1 key + clicking the button for something else - not related to help issues?
|
|
|
|
|
you will have to override
OnHelp() handler of the button
|
|
|
|
|
Hi,
I have created a new child window with folowing method in VC++
AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_FILE_NEW);
and directed my output display on this window.
But when I press a key there is no response or LButtonDown Doesn't respond to this window.Only RButtonDown Works on this window.What Should I do to get the focus?
Thanks
Prithaa
|
|
|
|
|
Hi,
I want to read excel files as we read comma delimited files . I want to read them in C++.Can anyone help me?
Prithaa
Thanks
|
|
|
|
|
Ok, so what exactly is the problem?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|