|
Tom,
do you know which c++ functions are used for checking serial number of a CD?
thx
includeh10
|
|
|
|
|
Hi:
is is possible to add extern hyperlinks into the help file afxcore.rtf?
|
|
|
|
|
Hi All,
I am new to MFC and so I thought I would set myself a small project as an exercise which is:- To read in an ASCII file from the hard disk (like the Notepad program). Then to add a button called "process" on the top row next to help. When pressed this button should process the displayed data in some way, then display the altered data on the screen. I should be able to then save that data to file.
The first part is accomplished with the helpful tutorial here
http://www.geocities.com/mcoiii2000/MFCtutorial.html to produce a simple text editor. and I have added the button to the top line
but now to manipulate....here is the task I set myself
Read in QWERTY contained in a file "ascii.txt"
All done with the created text editor. The button "process" is pushed (ok to here).
Now I want to display YTREWQ and save the file. i.e I now have a file ascii.txt containing ytrewq.
Simple? -not to me
The question, how can data from that filename be stored into an array/variable in order to be manipulated and then re displayed and saved??
Thanks for your help!
If I get it working I'll put it in the examples section!
|
|
|
|
|
Hi,
If your file contains only text, you can use CStdioFile for file processing. Open the File with file path and read the content, store CString varibale.
Finally, reverse that sting and save it.
Regards,
Selvam
|
|
|
|
|
Thanks , I really don't understand I am so new to this.
If I have made myself clear, I have constructed a simple text editor and loaded a file called ascii.txt I have added a button which when pushed takes me to the code below. Obviously I have to add the code. I actually want to manipulate the data on the screen. Where is it stored? what is the variable called?
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::Onreverse()
{
// TODO: Add your command handler code here
// I have used file>load >ascii.txt. The file contents are being displayed on the screen. Now I want to manipulate the data
// load the data displayed on the screen (qwerty)how with MFC , where is it?
// reverse it (ytrewq)-code for me to write!
// update the screen - how with MFC?
}
I can then save it to file. done with file>save
I hope that makes some sense
Thank you all for your time and help
|
|
|
|
|
While the task is easy enough to do, I certainly would not have chosen it for my first MFC project.
I presume you have created an SDI application (using AppWizard). If so, I would derive the view from CEditView . In the handler funtion for the button, call GetEditCtrl() to get a reference to the edit control used by the view. You can then call CEdit::GetWindowText() to get the text currently displayed in the edit control. Use the function _strrev() to reverse the text. Call CEdit::SetWindowText() to write the new text. Call GetDocument()->SetModifiedFlag(TRUE) to let the document know that the text has been changed. Upon exiting, the framework should prompt you to save the changed file.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you I'll give it a go and let you know how I get on.
You are right If I knew it was going to be this difficult I wouldn't have chosen this either but I've started so I'll finish as they say
|
|
|
|
|
Nearly there!!
I have entered the code you suggest and it now looks like this
/////////////////////////////////////////////////////////////////////////////
// CReverseView message handlers
void CReverseView::OnReverse()
{
// TODO: Add your command handler code here
GetEditCtrl() ;
CEdit::GetWindowText() ;
//_strrev();
//CEdit::SetWindowText();
//GetDocument()->SetModifiedFlag(TRUE) ;
}
and I get this error message
error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters.
and subsequently for all the other items when not commented out. I presume something needs to go into the bracket?
do I declare a variable here or what happens? I want to get it correct.
Now you can see how new I am to this but I have learnt more today than in weeks of trying on my own. NB the SDI project was called reverse hence the reference
Regards
Thank you again for your time and help
|
|
|
|
|
hugPW wrote:
GetEditCtrl() ;
This should be:
CEdit &edit = GetEditCtrl(); hugPW wrote:
CEdit::GetWindowText() ;
This should be:
CString strText;
edit.GetWindowText(strText); There are other changes to make, but see how you can fare with these first.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Now we are really getting somewhere!
code looks like this
void CReverseView::OnReverse()
{
// TODO: Add your command handler code here
CEdit &edit = GetEditCtrl();
CString strText;
edit.GetWindowText(strText);
_strrev(strText);
edit.SetWindowText(strText);
GetDocument()->SetModifiedFlag(TRUE) ;
}
doesn't like _strrev, get this error. After that it should work!
error C2664: '_strrev' : cannot convert parameter 1 from 'class CString' to 'char *'
I was going to write my own bit of code but if the function exists I might as well use it.
Thank you I really appreciate this help.
|
|
|
|
|
hugPW wrote:
error C2664: '_strrev' : cannot convert parameter 1 from 'class CString' to 'char *'
The answer is in the error message. You need to figure out how to "convert" a CString object to a char * that _strrev() expects. Become very familiar with the CString class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you once again for all your help!
Kind Regards
Peter
|
|
|
|
|
Hi,
I have a Property Sheet Class with three pages.
My question is, how can I disable/enable the OK button based on the user input on
any of the pages?
I have a Property Sheet Class with three pages.
BOOL CPropSht::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
CWnd *wnd=(CWnd*)GetDlgItem(IDOK);
wnd->EnableWindow(FALSE);
return bResult;
}
I have seen that OK button is disable.
I have added three pages page1,Page2 and Page3 in a property Sheet.
Now, suppose user changes something on any of the pages then in this situation OK
button should be enable.
I mean, OK button should behave like apply button.
Please provide me some idea.
Thanks!
rajesh
|
|
|
|
|
|
Hi,
I am trying to use cdhtmldialog to display a html page in the resource folder, it works fine untill I want to have more than one html file.
Do anyone know how to change to the other html file while having the original one displayed? Thanks a lot!!!
|
|
|
|
|
hi all,
I am using SQLConfigDataSource(HWND hwndParent,UINT fRequest, LPCSTR lpszDriver, LPCSTR lpszAttributes) Method to configure the ODBC datasource..
The Problem is I have used the above Method Like this:-
SQLConfigDataSource(NULL,ODBC_ADD_DSN, "SQL Server\0","DSN=myfinger\0" "Server=SERVER\0" "Database=emp\0");
This working perfectly and create the DSN..
Now I want to give the DSN ,server ,Database Name as variables..
But when I create create Like this This is not working..
CString var4,v1,v2,v3;
v1="myfinger";
v2="SERVER";
v3="emp";
var4.Format(" \"DSN=%s\0\" \"Server=%s\0\" \"Database=%s\0\" ",v1,v2,v3);
SQLConfigDataSource(NULL,ODBC_ADD_DSN, "SQL Server\0",var4);
But No error When compilling the Program..But Not creating the DSN..
So please any know the correct way to show this please send me a reply...
Thanks in advance..
|
|
|
|
|
There is no need to put the extra \0 characters in the string. CString::Format() does not like them. Looking at var4 after calling Format() would have confirmed this.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Also, when you have a variable number of arguments, which follow a formatting type string, the compiler does not necessaily know what to types to cast the arguments into, so you should probably always cast the CString manually in such a situation. I always do and boy have the wierdness factors decreased.
So, it would like something like this, following mine and David's suggestions:
var4.Format(" \"DSN=%s\" \"Server=%s\" \"Database=%s\" ",(LPCTSTR)v1, (LPCTSTR)v2, (LPCTSTR)v3);
|
|
|
|
|
hi ,
Sorry that is also not working..
Compilling the Project perfectly..But Not creating the DSN..
If I used the Method like this:
SQLConfigDataSource(NULL,ODBC_ADD_DSN, "SQL Server\0","DSN=myfinger\0" "Server=SERVER\0" "Database=emp\0");
This working perfectly and create the DSN..
This is working ...
But I want to pass the values for DSN,Server and Database/b>
please help...
|
|
|
|
|
SQLConfigDataSource -> lpszAttributes
List of attributes in the form "keyname=value". These strings are separated by null terminators with two consecutive null terminators at the end of the list.
Try this instead:
CString var4, v1, v2, v3;<br />
<br />
v1 = "myfinger";<br />
v2 = "SERVER";<br />
v3 = "emp";<br />
<br />
var4.Format("DSN=%s\0Server=%s\0Database=%s\0", (LPCTSTR)v1, (LPCTSTR)v2, (LPCTSTR)v3);<br />
<br />
SQLConfigDataSource(NULL, ODBC_ADD_DSN, "SQL Server", (LPCTSTR)var4);
I think this will work for you.
|
|
|
|
|
hi,
Thanks for ur reply..But it is also not working..You can also try to create DSN using above ur code:
void testDlg::OnButton2()
{
CString var4, v1, v2, v3;
v1 = "myfinger";
v2 = "SERVER";
v3 = "emp";
// this generates paramaters separated by a single NUL character
// and a sting terminated with two NUL characters
var4.Format("DSN=%s\0Server=%s\0Database=%s\0", (LPCTSTR)v1, (LPCTSTR)v2, (LPCTSTR)v3);
if(!SQLConfigDataSource(NULL, ODBC_ADD_DSN, "SQL Server\0", (LPCTSTR)var4))
AfxMessageBox("error");
}
But I got Error for this..
Thanks in advance..
|
|
|
|
|
I have created a separate thread to continuously monitor the serial port (i.e. to wait for something to arrive and then read it out)
Is it possible to write to the serial port at the same time (in the main thread), or does the read thread block. I have tried...it didn´t work, but the problem might be somewhere else...
If I cannot send while monitoring the port, what would be the proper solution? Do I have to temporarily Suspend, Sleep or Abort the thread while performing the write operation?
doneirik
|
|
|
|
|
IIRC you should use overlapped IO for the serial read write.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
it is not neccessary to write in a thread - thread is for waiting (reading) events.
before u write, u need to check if writing (sending) buffer is empty - otherwise writing fails.
i have worked for years on your current job.
includeh10
|
|
|
|
|
How can I change the background color of dialog form in a MFC application.
can anyone help me regarding this project ?
Philip
|
|
|
|