Wrox Programmer Forums
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2005, 02:59 PM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newbie help please

I've never used visual c++ before but am trying something I hope will be easy for someone to help me with. I've used some basic c stuff in the past on unix and dos.

I have vis c++ 6, i added a mfc app exe, i have a form with an edit box on it, and I called it IDC_currec.

There is an ok button on the form.

On the buttonok event, I've got something like this (real simple).

void CBatchLDlg::OnOK()
{
    FILE *fpin;
    char buff[5000];

    fpin = fopen("c:\\temp\\input-file.txt", "r");
    while (fgets(buff,5000,fpin)!=NULL){
        strcpy(IDC_currec.text,buff);
    }
    fclose(fpin);

    CDialog::OnOK();
}

How do I get the data from each row in this file (buff) to be displayed on the form in the edit box called IDC_currec???

I'd appreciate a heads up.

Sorry if this is all wrong, but I'm just guessing. I've had no training or prior experience with VC. I've used Vis Basic 6 a bit, and can do this SO easy but I really want to start using C++ for various reasons which I won't go into right now.

In VB it would be something like IDC_currect.text = whatever but this is not working. This example shown is the last thing I tried.

Thanks,

Kenneth

 
Old June 24th, 2005, 06:03 PM
Authorized User
 
Join Date: Jul 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to merediths
Default


 Bleh I haven't done any MFC development for awhile, but I think the name of the funciton you are looking for is setText() -- you see, what you are trying to do with a strcpy() is directly write to an objects internal member variable, which violates encapsulation -- you have to get and set values with accessor functions, for example control.getText() or control.setText().

Regards,
Meredith Shaebanyan







Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help the newbie!! shelly.aix Visual Basic 2008 Essentials 2 December 16th, 2008 07:35 AM
Newbie help... mkruger XSLT 7 October 24th, 2007 02:33 AM
Newbie here jmac731976 HTML Code Clinic 13 August 29th, 2007 03:54 PM
Newbie please help indyanguy XSLT 1 September 2nd, 2005 09:18 AM
Newbie Help! TheShadow Javascript 1 March 21st, 2005 03:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.