Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
C

chauteen

@chauteen
About
Posts
6
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Manipulate text file
    C chauteen

    hi V. I'm sorry keeping on bothering you. I agree with you, it is ok to load the whole data to memory. But I need to write data back and close the file at every editchange, because the file will be accessed by another class. Fortunately, I have only 8 data need to handle, the speed is compltely fine with me. My tesk is like this: I use MFC to make a dialog. I have serveral tabs with about 8 spins on each of them. and I add these tabs on a base dailog. I send the spin value out on a master query(I'm slave on the bus. I cann't send data out on my own. I need to wait the query command.) So I decide to store the tabs spin values in several files(every tab has it's own file), and open a serial port on the base port. When the user change the spin value, he only change the file, but doesn't send it out. When the master polling, I send the file data to master.(the polling speed is faster than the user's finger to click spin, of course) Will my idea work? One more ask V. wrote: "#value1|value2|...|valuen#" if I make my file like this: 10 15 20 when I fread them, CString will treat 10 to be one byte, or treat 1 as one byte and 0 as teh second byte? Many thanks for your help beforehan. slow-witted chauteen

    C / C++ / MFC question

  • Manipulate text file
    C chauteen

    Thanks for your reply first. For I am trying your way, to read the entire file and then write the whole data back.(the work I want to do is store 8 spin vlaue to a file, and update when the user click and change spin value.) but I use a brute force way, for I don't know how to read data in CString:confused: I declare an BYTE array, called buffer[8], and in the dialog's init, I read in the file fread( buffer, sizeof( BYTE ), 8, filespin ); and in the spin message, I add fseek(filespin, 0, SEEK_SET); fprintf( filespin, "%s", buffer ); I've also tried fwrite fwrite( buffer, sizeof( BYTE ), 8, filespin ); both failed the output file will contain some strange code, like slash , camma or something. I try to show the readin buffer text on a editbox, and it already contain a unexpected slash and the end.:confused: It seems the read in have something wrong already, not to mention write data back. Can you suggest me some smart or "correct" way to do? Thank you very much. chauteen

    C / C++ / MFC question

  • Manipulate text file
    C chauteen

    hi, Can you say something more about fseek please? how to use fseek to go to a certain line of a file. For examlpe, I need to overwrite the thrid line of the file. But fseek and fgetpos simply moving the file pointer in the same line, not be able to next line. Thankx. chauteen

    C / C++ / MFC question

  • Many tabs using one file
    C chauteen

    It's me again. I'm still fighting with tabs. I have 7 tabs with spins on them, and one Dialog. I use Propertypage, and use the instruction "AddPage" to make the 7 tabs on the dialog. Now I want to store the spin value in a flie when the user click and change the spin value. (or maybe in 7 different file, for one tab own one file belong to itself) Then, I have to communicate with a controller throu RS-232 under modbus portocol. Because I'm slave on modbus, I only can send data out when the controller send out query message. So I planning to store the spin value in files, then waiting untill the query message, then I send the data I stored in the file. I would like to ask how to deal with the file pointer. I use the code: in my base dialog' cpp: FILE *filedlg; filelog = fopen( "file_page1.txt", "r+" ) What code about pointer assignment I suppose to write in tab page1' cpp or h file to complete the rest? I mean page1 doesn't know the exitance of file pointer filedlg. I'm new about pointer and MFC, and would be many appriciate about your help. chauteen

    C / C++ / MFC c++ database json help tutorial

  • Modbus in MFC
    C chauteen

    I'm writing a dialog by MFC. I need to send data out through RS-232, using Modbus protocol. I know there are many classed written for serial communication, but not for Modbus. Does anyone have already fought with modbus and survied? Please give me sone advice. Thanks. chauteen

    C / C++ / MFC c++ question

  • Many tabs using one serial port
    C chauteen

    Hi, I'm writing a dialog by MFC. I have several tabs, and every tab has some control items on it. I creat classes for every tab. I want to send out status thru RS-232, such as when the user click one spin, and the spin value will be sent out thru RS-232. My problem is I've got the tab class and a serial class ready. But how to confige a serial port that can be used by "all" tabs. If I create the port in one tab's cpp, other tabs will not be able to use the port, of course. However, it doesn't work if I configure a port in the project's main cpp, either. Forthermore, if I call the functions in the CSerailPort class, like: CSerialPort::Openport("com4"); The compiler says another error: illegal call of non-static member function. Thanx your help. Chauteen

    C / C++ / MFC help c++ tutorial learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups