|
What exactly is the question here? Are you trying to write to a file, or read from it?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i am able to save the contents of edit box to the text file now.. this is how i did it...
CString S1;
CString A;
CStdioFile flEdit;
CFileDialog FileDlg(FALSE, ".txt","Prioritynotes",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);
if( FileDlg.DoModal() == IDOK )
{
if( flEdit.Open(FileDlg.GetPathName(), CFile::modeCreate | CFile::modeWrite) == FALSE )
return;
S1 += "Critical****";
S1 += nextline;
S1 += "--------------------------";
S1 += nextline;
flEdit.Write(S1, S1.GetLength());
A.Empty();
m_edit1.GetWindowText(A);
flEdit.Write(A, A.GetLength());
S1 = '\0';
now i want to retrieve the data under each name to the respective edit boxes once i click open in file menu....
|
|
|
|
|
sonualex wrote: now i want to retrieve the data under each name...
Meaning that you want to read from the file. You do know that CStdioFile has ReadString() (and WriteString() ), don't you?
sonualex wrote: ...to the respective edit boxes...
Using SetWindowText() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
yes i know we can use ReadString and WriteString.. but how to combine dat wit CEdit and make it display in edit box i dont know..
plz bear with me ...
|
|
|
|
|
If you are unfamilar with the ReadString() and WriteString() methods, why not consult the documentation?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
thanks again David.. with ur guidance i succeded in completing the project...
my exe is workin fine... iam able to save the contents of editox to text file and import the data from the same text file....
thanking u once again...
my code for OnSave includes
S1 += "Critical****";
S1 += nextline;
S1 += "--------------------------";
S1 += nextline;
flEdit.Write(S1, S1.GetLength());
A.Empty();
m_edit1.GetWindowText(A);
flEdit.Write(A, A.GetLength());
S1 = '\0';
flEdit.Write(S1, S1.GetLength());
flEditClose()
and my code for OnOPen includes
CString mystring;
CString buffer1;
pFile = fopen ("Prioritynotes.txt" , "r");
if (pFile == NULL) perror ("Error opening file");
else
{
while (!feof(pFile))
{
c = fgetc (pFile);
mystring+= c;
if (c=='\n')
{
mystring.TrimRight();
//CODE FOR EXTACTING THE CONTENTS UNDER EACH TITLE
char d[3];
CString test = mystring;
CString crt = "Critical****" ;
CString line = "--------------------------";
CString imp= "Important***";
CString les = "Less Important**";
CString nor = "Normal*";
if(test==crt)
{
mystring ="";
z=1;
}
if(z==1)
{
if(test==imp)
{
mystring =" ";
z=2;
buffer2+=mystring;
m_edit2.SetWindowText(buffer2);
mystring ="";
}
if(mystring !="--------------------------")
{
d[0] = 0x0D;
d[1]= 0x0A;
d[2]= 00;
mystring+= d;
buffer1+=mystring;
m_edit1.SetWindowText(buffer1);
mystring = "" ;
}
}
//SIMILARLY FOR OTHER TITLES....
|
|
|
|
|
It's not very efficient, but if it works for you...
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
ya it works for me perfectly.. thanku 
|
|
|
|
|
Hi Friends
I have function, show below coded in "Test.h"
void Msg()
{
....
}
I copied "Test.h" to include folder of VC++
Can i use Msg function in a project without adding "Test.h" in project solution ?
Just like below
In stdafx.h file
#include <test.h>
thanks in advance
-kk.tvm-
|
|
|
|
|
You have to include Test.h.
You can either include it directly in the file in which you're going to call Msg or you can include it in stdafx.h and then include stdafx.h in the file in which you're going to call Msg.
|
|
|
|
|
|
HI all,
in dialog box i m using GotoDlgCtrl to set focus on button,but this not working in formview.
even i use setfocus from button variable but its also not working.
please tell me what can i use for set focus on button control in formview.
please help me foe this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?
I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg?
Thanks in advance.
|
|
|
|
|
How and where in the code are you creating CCalibracionDlg?
You must be having the object of CCalibracionDlg in your appplication. Why cant you share it with DlgMap1 class?
|
|
|
|
|
well i dont think sendMessage is a good option if they are belonging to the same application and thread.
one method will be use FindWindowEx, that give you the handle if you specify the name of the dialog.
Величие не Бога может быть недооценена.
modified on Thursday, October 22, 2009 12:53 AM
|
|
|
|
|
CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?
I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or
Better to have an 'object' or pointer of CCalibracionDlg in DlgMap1.U can get handle through object.GetSafeHWND(). Or Simply u can call object.SendMessage(..) or object.PostMessage()
--Cool_Dev--
|
|
|
|
|
The objet from i'd like send the message is CDlgMap1 to the objet CCalibracionDlg, so you say that i have to put this code in the apropiate function in CDlgMap1 : CCalibracionDlg.PostMessage(...)?
|
|
|
|
|
yeaa.. exactly. As you want to send message to a window from another window in same application, u can simply use a Callback or a direct function call. But if the situation needs, such as you need to call the function many times, its better to use PostMessage or sendMessage.
--Cool_Dev--
|
|
|
|
|
Well , thanks to all, finaly i get the solution with:
GetParent()->PostMessage(WM_MyMessage,NULL,NULL);
|
|
|
|
|
timbk wrote: ...when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?
Are they both visible? Are they modal or modelsss?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Ies they are both visible, the one from class CCalibracionDlg is modal and the one from CDlgMap1 is no modal, why?
|
|
|
|
|
timbk wrote: ...the one from class CCalibracionDlg is modal and the one from CDlgMap1 is no modal, why?
Because modal dialog boxes "block" other windows from processing messages. Your topmost dialog would need to be modeless if you want it to be able to communicate with the dialog below it.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
oh, I didn't know it , so it's imposible send and recive messages between a model and modeless? ok supose that i change the main dialog to modeless , how can i do te send or post a message between the two modeless? with PostMessage?
|
|
|
|
|
timbk wrote: so it's imposible send and recive messages between a model and modeless?
No, it IS possible.
timbk wrote: ok supose that i change the main dialog to modeless...
The main dialog should stay modal. Any subsequent dialogs that you want to communicate with it should be modeless.
timbk wrote: ...with PostMessage?
That's a different topic altogether, and at this point does not matter to you.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks. But , wich is the correct syntax? i wrote the following code in CDlgMapa1
<code>CCalibracionDlg.PostMessage( ? , WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam);</code>
Two questions:
1-What have i put in'?' ? , the handler to CCalibracionDlg (is the object that recives the message) ? in this case , how can obtain it? if you could put some code like an example , would be nice.
2- at that line of code the compiler says : error C2143: syntax error : missing ';' before '.' , sounds like the compiler doesn't recognizes that line. thanks again.
|
|
|
|