|
Have you looked at CWnd::GetNextDlgTabItem API?
Yours Truly, The One and Only!
|
|
|
|
|
Is this used for taskbar button? or do you mean to transfer the TaskBar window handle to this function and get it's items? If it is so, how to find the corresponding application window handle?
|
|
|
|
|
all the controls as well as the controlbar are basically windows. so if you have a handle to the taskbar you should be able to use this api to enumerate the child controls.
Yours Truly, The One and Only!
|
|
|
|
|
Here's the scenario. I have a tree control and a list control on a dialog. I added a ON_NOTIFY_REFLECT(NM_DBLCLK, xxx) handler for the list control to handle the double click event. Then I realized I need to inform the parent dialog the double click notification message as well, so that the parent dialog can synchronize some information to the tree control on the left side. But the thing is I can't use ON_NOTIFY(NM_DBLCLK, xxx) in the message map of the owner dialog because the notification is handled locally in the list control. Is there a way to let both the control and its owner receive the same notification or I have to redirect the notification to the parent window after the event is handled locally (SendMessage or something?)
Thanks guys.
Toe the line
Thread the needle
Think outside of the box
|
|
|
|
|
One way to redirect the notification message is:
In the list control: message map ON_NOTIFY_REFLECT(NM_DBLCLK, OnDoubleClicked)
In the function
void CListCtrl::OnDoubleClicked(...)
{
...// code for handling the double click in list control
Get the dialog window's handler->SendNotifyMessage(MESSAGE_CODE, wParam, lParam);
}
Add a ON_MESSAGE(MESSAGE_CODE, OnRecvLVDoubleClicked) in the dialog's message map
and finally add the OnRecvLVDoubleClicked function.
Pretty ugly. Isn't there a way to let the control and its owner both receive the same notification?
Toe the line
Thread the needle
Think outside of the box
|
|
|
|
|
_Pinux_ wrote: Pretty ugly. Isn't there a way to let the control and its owner both receive the same notification?
No
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I see. Thanks.
Toe the line
Thread the needle
Think outside of the box
|
|
|
|
|
Hello Guru Jiiiiiiiiii's
I am making a application in VC++(MFC-Modal Dialog based).And i don't know
file handling ........The question i am writing here i have already post here
but I am sending my code also. my question is below . Plz help me
Actually I am making a file field ( Mense when user click browse button
all HD display and he/she can attach his .txt document ) That .txt doc
will be save at a file which is created in C:Drive in a folder ( it can any other place also )
I have done its Most of work like i can read file create new file also
but i am unable to write that data in to newly created file.
I don't know where i am making wrong . I know its vewry basic . But i am also know i am also very begginner in file handling
My whole code That i have write for this is below
CString str;
int ids;
CFileDialog Obj(TRUE);
if(Obj.DoModal() ==IDC_BUTTON3)
{
m_Upload = Obj.GetFileName();
}
str.Empty();
str = Obj.GetPathName();
SetDlgItemText(IDC_EDIT1,str); //write file path with name at edit box
CString strLine = "";
CString buffer = "";
CStdioFile fileObj,filewrite;
CString fname;
fileObj.Open(str, CFile::modeRead | CFile::shareDenyWrite);
fname = fileObj.GetFileName();
while(fileObj.ReadString(strLine))
{
fileObj.ReadString(strLine);
buffer += strLine + "\r\n";
}
fileObj.Close();
// MessageBox(buffer);
SetDlgItemText(IDC_EDIT3,buffer);////write all data at another edit box
fileObj.Open("c:\\UserFolder\\" + fname + ".txt",CFile::modeCreate,NULL);
CString dataStr;
GetDlgItemText(IDC_EDIT3,dataStr);
CStdioFile myFile;
CFileException e;
CString strFileName =str;
if(! myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite
| CStdioFile::modeNoTruncate, &e ) )
{
CString failCause = "Unable to open file. Reason : ";
switch (e.m_cause) {
case CFileException::none:
failCause += "No error occurred.";
break;
case CFileException::generic:
failCause += "An unspecified error occurred.";
break;
case CFileException::fileNotFound:
failCause += "The file could not be located.";
break;
case CFileException::badPath:
failCause += "All or part of the path is invalid.";
break;
case CFileException::tooManyOpenFiles:
failCause += "The permitted number of open files was exceeded.";
break;
case CFileException::accessDenied:
failCause += "The file could not be accessed.";
break;
case CFileException::invalidFile:
failCause += "There was an attempt to use an invalid file handle.";
break;
case CFileException::removeCurrentDir:
failCause += "The current working directory cannot be removed.";
break;
case CFileException::directoryFull:
failCause += "There are no more directory entries.";
break;
case CFileException::badSeek:
failCause += "There was an error trying to set the file pointer.";
break;
case CFileException::hardIO:
failCause += "There was a hardware error.";
break;
case CFileException::sharingViolation:
failCause += "SHARE.EXE was not loaded, or a shared region was locked.";
break;
case CFileException::lockViolation:
failCause += "There was an attempt to lock a region that was already locked.";
break;
case CFileException::diskFull:
failCause += "The disk is full.";
break;
case CFileException::endOfFile:
failCause += "The end of file was reached.";
break;
default:
failCause += "Unknown cause.";
break;
}
AfxMessageBox(failCause);
}
else
{
myFile.SeekToEnd();
CString strLine = dataStr;
strLine += "\r\n";
myFile.WriteString(strLine);
// myFile.WriteString(dataStr);
myFile.Close();
}
I write that all code with the help of net also its work almost fine But
The main task i.e write all data at file in userfolder is not perform
Please told me where i am wrong
Regard's
Kaushik
|
|
|
|
|
Can you explain about this line "if(Obj.DoModal() ==IDC_BUTTON3)".
|
|
|
|
|
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
It mense When particular button which id is (IDC_BUTTON3) clicked
Then event fire and Browse the window for selecting your file
Regard's
Kaushik
|
|
|
|
|
Have you got any error message? If the answer is Yes then, please, post it.
BTW, the debugger is your best frined.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I don't have any error message
But data is not write at file
Regard's
Kaushik
|
|
|
|
|
myFile and fileObj are use mixed, I think you neednt myFile. Really
Greetings from Germany
|
|
|
|
|
Your code has some problem
(1)
if(Obj.DoModal() ==IDC_BUTTON3)
to
if(Obj.DoModal() ==IDOK)
(2)
while(fileObj.ReadString(strLine))
{
fileObj.ReadString(strLine);
buffer += strLine + "\r\n";
}
to
while(fileObj.ReadString(strLine))
{
buffer += strLine + "\r\n";
}
fileObj.ReadString(strLine);
(3)
Do you have this folder on your system
fileObj.Open("d:\\UserFolder\\" + fname + ".txt",CFile::modeCreate,NULL);
(4)
if(! myFile.Open( strFileName
, CStdioFile::modeCreate | CStdioFile::modeWrite
| CStdioFile::modeNoTruncate, &e ) )
and also you have an if/else block
|
|
|
|
|
Do you have this folder on your systemfileObj.Open("d:\\UserFolder\\" + fname + ".txt",CFile::modeCreate,NULL);
Yes This folder in my system
I have replace all change but problem remain
Regard's
Kaushik
|
|
|
|
|
Can any move to solve this problem.
After all change I am gotted any solution ...
Please advise me for solving this;)
Regard's
Kaushik
|
|
|
|
|
You dont have any code for write on the if block you have a write to file on the else block.
|
|
|
|
|
I think first time i have seen when WhiteSky has given the code directly instead of link.
Well, I have nothing to do with it. It's good that you are replying and helping the programmers in any way you can. Good.
|
|
|
|
|
Anurag Gandhi wrote: I think first time i have seen when WhiteSky has given the code directly instead of link.
Don't you like links, do you?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Oh no its not first time it seems to question for example on this question a link arent helpful for asker because he wrote his code but needs to help but for some question if we see an article is better for asker.;)
|
|
|
|
|
Below is the code to save the file that i am using to save the text file.
I hope you will understand each line of it. It is very easy.
CStdioFile file;
if(!file.Open(lpszPathName,CFile::modeCreate | CFile::modeWrite, 0))
{
AfxMessageBox(CString("File cannot be Saved. Please Check if the file is read only."));
return FALSE;
}
long nLen = reinterpret_cast<ceditview*>(m_viewList.GetHead())->GetWindowTextLengthW();
TCHAR* pSaveText = new TCHAR[nLen+1];
reinterpret_cast<ceditview*>(m_viewList.GetHead())->GetWindowText(pSaveText,nLen + 1);
file.WriteString(pSaveText);
file.Close();
|
|
|
|
|
Can u told me in your code
AfxMessageBox(CString("File cannot be Saved. Please Check if the file is read only."));
return FALSE;
When function return type void how we return FALSE ?
Second
What is m_viewList ?? I think its mamber variable of List
What is pSaveText ?? I think Its data which I have to read from file
Regard's
Kaushik
|
|
|
|
|
I am simplifying my answer according to your need.
CStdioFile file;
if(!file.Open(lpszPathName,CFile::modeCreate | CFile::modeWrite, 0))
{
AfxMessageBox(CString("File cannot be Saved. Please Check if the file is read only."));
return;
}
CString strTextToSave = _T("This text will be saved to the file.");
file.WriteString(strTextToSave);
file.Close();
Hope it is clear.
For Your Information:
The code i have given you was from one of my project where I called FileSave function in CProjectDocument Class and was retriving the text from EditView Window.
|
|
|
|