please can any one help me

i develop a program that read binary files(e.g. wav file or mp3) then present the out in a dialog box
and first i make a variable outca.
in each of them i put the bytes readed from the file
char outca[10000000];
but it doesn not read all the bytes of a file(that is wanted)
i think if it is a pointer it will work but it does not by compiling it makes error
here is my source code:

#include
#include
#include
#include
#include
#include
#include"resource.h"


_finddata_t fd;

unsigned char b[9999999];
long i;
//char filename[50];
char filename[100];
HDC hdc,memdc;
///////
//variables
//char outca[400000];
char *outca;
extern char *outca;
outca=new char(fd.size);
void PrintFilecontasc()
{

strcpy(outca,"");
for(i=0;i0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}

long WINAPI WndProc(HWND hwnd ,UINT mid,WPARAM wp,LPARAM lp)
{
OPENFILENAME ofn;
HWND hdlg;
RECT rect1,rect2;
int width1,width2,height1,height2;
char k[30];

switch(mid)
{

case WM_COMMAND:
switch(wp)
{
case ID_FILE_OPEN1:
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=hInst;
//ofn.nMaxFile=50;
ofn.nMaxFile=100;

ofn.lpstrFile=filename;
GetOpenFileName(&ofn);
ReadFile(hwnd);

hdlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,DlgProc);
ShowWindow(hdlg,1);

GetWindowRect(hdlg,&rect1);
width1=rect1.right-rect1.left;
height1=rect1.bottom-rect1.top;
GetClientRect(hwnd,&rect2);
width2=rect2.right-rect2.left;
height2=rect2.bottom-rect2.top;
SetWindowPos(hdlg,0,width2-width1-25,0,width1,height1,0);
/////////
{
SplitFile();
SetDlgItemText(hdlg,IDC_EDIT1,fname);
SetDlgItemText(hdlg,IDC_EDIT2,ext);
_findfirst(filename,&fd);
sprintf(k,"%ld",fd.size);
SetDlgItemText(hdlg,IDC_EDIT3,k);
memcpy(k,ctime( &( fd.time_write )),24);
k[24]=0;

SetDlgItemText(hdlg,IDC_EDIT4,k);

}
//////////////
break;
case ID_PLAY_RUN:
::ShellExecute(hwnd, "Open",filename, NULL, NULL, SW_SHOW);

break;
case ID_VIEW_FILECONTENT:

ReadFile(hwnd);
if (fd.size>9000)
{
//file cont large file
{
{hdlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DIALOG3),hwnd,DlgProc2);
ShowWindow(hdlg,TRUE);
}

SplitFile();
SetDlgItemText(hdlg,IDC_EDIT1,fname);
SetDlgItemText(hdlg,IDC_EDIT2,ext);
PrintFileconthex();
SetDlgItemText(hdlg,IDC_EDIT3,outch);

}

}

else{
//file cont small file
{
{hdlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DIALOG2),hwnd,DlgProc1);
ShowWindow(hdlg,TRUE);
}

SplitFile();
SetDlgItemText(hdlg,IDC_EDIT1,fname);
SetDlgItemText(hdlg,IDC_EDIT2,ext);
PrintFileconthex();
SetDlgItemText(hdlg,IDC_EDIT3,outch);

}}
break;

case ID_FILE_EXIT:
DestroyWindow(hwnd);
break;

}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:return DefWindowProc(hwnd,mid,wp,lp);
}
return 0;
}


BOOL CALLBACK DlgProc(HWND hdlg,UINT mid,WPARAM wp,LPARAM lp)
{ switch(mid)
{

case WM_CLOSE:
EndDialog(hdlg,0);
break;

case WM_COMMAND:
switch(wp)
{

case IDCANCEL:
EndDialog(hdlg,0);
break;


} break;

}
return 0;

}

BOOL CALLBACK DlgProc1(HWND hdlg,UINT mid,WPARAM wp,LPARAM lp)
{//file content small file
switch(mid)
{

case WM_CLOSE:
EndDialog(hdlg,0);
break;

case WM_COMMAND:
switch(wp)
{
//dec
case IDC_BUTTON1:
PrintFilecontdec();
SetDlgItemText(hdlg,IDC_EDIT3,outcd);
break;
case IDCANCEL:
EndDialog(hdlg,0);
break;

} break;

}
return 0;

}

please can any one help me and find a solution
many thanks
in advance
regards
rania

Comments

  • : char *outca;
    : extern char *outca;
    : outca=new char(fd.size);

    Why do you first declare char *outca and then redeclare it as extern???

    Anyhow the error is that you have to use [fd.size] not (fd.size)

    char *outca = new char[fd.size];

    nICO

    [hr]
    [italic]How beautiful, if sorrow had not made Sorrow more beautiful than Beauty itself.[/italic]
    JOHN KEATS


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion