Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming 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
  #1 (permalink)  
Old December 29th, 2004, 12:48 PM
ck ck is offline
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pls Help Me Check This Code - Win32

hi,
 tis is the code that write/create, read the file in Win32.how can i put write code together with read code??? & how to get & display the bitmap pathname??? pls help me check what's wrong of this code, thanks a lot :(

code:

#include "stdafx.h"
#include "Finger_FASS.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

int main()
{

    char Name[10];
    char Bitmap[256];

    //Write File To tmp or Create tmp
    FILE *Load = fopen("FASS.inv", "w");

    cout << "Enter the following information\n";
    cout << "Name: "; gets(Name);

    //Open Directory
    _TCHAR szFileTitle[MAX_PATH] = {0};
    _TCHAR szTitle[MAX_PATH] = _TEXT("Open Dammit");

    OPENFILENAME openfile;
    memset(&openfile,0,sizeof(openfile));
    openfile.lStructSize = sizeof(openfile);
    openfile.lpstrTitle = szTitle;
    openfile.Flags = OFN_FILEMUSTEXIST;
    openfile.lpstrFile = szFileTitle;
    openfile.nMaxFile = MAX_PATH;
    openfile.lpstrFilter = ("Bitmap Files (*.bmp)\0*.bmp\0\0");

    cout << "Bitmap: ";

    if(GetOpenFileName(&openfile) == FALSE)
    {
        gets(Bitmap);
    }

    fprintf(Load, "%s\n", Name);
    fprintf(Load, "%s\n", Bitmap);

    fclose(Load);

    cout << endl;
    return 0;


    //Read File From tmp
    FILE *FASS = fopen("FASS.inv", "r+");

    fscanf(FASS, "%s\n", Name);
    fscanf(FASS, "%s\n", Bitmap);

    cout << "Information about the FASS";
    cout << "\nName: " << Name;
    cout << "\nBitmap: " << Bitmap;

    fclose(FASS);

    cout << endl;
    return 0;

}



__________________
ck.
Reply With Quote
  #2 (permalink)  
Old January 6th, 2005, 09:44 PM
Authorized User
 
Join Date: Dec 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to abelconde
Default

Hi,

I was working in your code. And I must tell you I didn't understand
what you wanted to do. However, here, are discribe the steps you
must follow.

1. Create a file called StdAfx.h. And write into it, this...

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#if !defined(AFX_STDAFX_H__080A3C04_6281_11D6_AEA2_008 0C8DFB15E__INCLUDED_)
#define AFX_STDAFX_H__080A3C04_6281_11D6_AEA2_0080C8DFB15E __INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls



// TODO: reference additional headers your program requires here

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444 553540000__INCLUDED_)

2. Create a file called main.cpp. And write into it, this...

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <tchar.h>
#include <wingdi.h>

#define MAX_SIZE 1024
#define NULL_LEN 1

using namespace std;

int main()
{
    char Bitmap[MAX_SIZE + NULL_LEN];

    //Write file To tmp or create tmp
    FILE *Load = fopen("FASS.inv", "wb");

    cout << "Enter the following information\n";
    cout << "Bitmap: ";

    //Open Directory
    _TCHAR szFileTitle[MAX_PATH] = {0};
    _TCHAR szTitle[MAX_PATH] = _TEXT("Open Dammit");

    OPENFILENAME openfile;
    memset(&openfile,0,sizeof(openfile));
    openfile.lStructSize = sizeof(openfile);
    openfile.lpstrTitle = szTitle;
    openfile.Flags = OFN_FILEMUSTEXIST;
    openfile.lpstrFile = szFileTitle;
    openfile.nMaxFile = MAX_PATH;
    openfile.lpstrFilter = ("Bitmap Files (*.bmp)\0*.bmp\0\0");

    if(GetOpenFileName(&openfile) != FALSE)
    {
        //Read the open file
        FILE *file = fopen(szFileTitle, "rb");

        //Read from the open file and write to FASS.inv all the bitmap
        while(!feof(file)){
            fgets(Bitmap, MAX_SIZE, file);
            fputs(Bitmap, Load);
        }

        fclose(file);
    }

    fclose(Load);

    cout << endl << endl;

    //Read tmp file
    FILE *FASS = fopen("FASS.inv", "r+");

    //Read from tmp file and assign data to Bitmap
    fscanf(FASS, "%s\n", Bitmap);

    //Print information
    cout << "Information about the FASS";
    cout << "\nName: " << szFileTitle;
    cout << "\nBitmap: " << Bitmap;

    fclose(FASS);

    cout << endl;
    return 0;
}

3. Put both files together in the same directory. And then run this
program.


Good luck!!!!!



Reply With Quote
  #3 (permalink)  
Old January 7th, 2005, 04:40 AM
ck ck is offline
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
 thanks a lot, although you not understand wat i wan, but still feel free to help me, i really appreciate it & really thank you so much..the code is really very useful for me, after i tried it...but it got this nonsense message pop up when i execute the file:

<img src="http://www.geocities.com/kv_sniper/bug.JPG">

 i not really understand wat the message telling...coz i a beginner of C++...
 thanks a lot & soli of inconvenience....:(

best regards,



Reply With Quote
  #4 (permalink)  
Old January 9th, 2005, 12:34 AM
ck ck is offline
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
 the codes above is very useful for me...but do u know how to display the bitmap? i means when the bitmap save in the temporary file, then it also display it on the dialog or the picture control on the dialog...so, do anyone help me, or teach me, or let me know the code??? thanks a lot....;) & soli of inconvenience...:(

Reply With Quote
  #5 (permalink)  
Old January 13th, 2005, 12:14 AM
ck ck is offline
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
 do some1 know how to define the image size?? means...when i write & read the image, the image in the temporary file will be the same with the original image size...means(my original image is 1.21MB, then when the program write into & read from the temporary file, it also must be the same size(1.21MB)...so, how to fix this problem???
 thanks for ur kindness for helping.....

best regards,
ck


Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
code to check values in two columns?? Mazzy Excel VBA 2 December 13th, 2007 07:39 AM
Plz Help Me Check What's Wrong Of This Code ! ck C++ Programming 1 January 13th, 2005 12:12 AM
Pls Help Me Check This Code - Win32 ck Visual C++ 0 December 29th, 2004 12:50 PM
check my code nadia Dreamweaver (all versions) 4 October 21st, 2004 12:46 PM





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