I've been working on my Win32 skills (not to say I'll be abandoning Acknex, ), and I've come at a problem. I don't know exactly how to set up a function that will load the content of a text file into an edit box (basically like NotePad).

I have this function that I copied precisely from the tutorial that I'm working from:

Code:

BOOL LoadTextToEdit(HWND hEdit,LPCSTR pszFileName)
{
HANDLE hFile;
BOOL bSuccess= FALSE;

hFile= CreateFile(pszFileName,GENERIC_READ,FILE_SHARE_READ,NULL,
OPEN_EXISTING,0,NULL);
if(hFile!= INVALID_HANDLE_VALUE)
{
DWORD dwFileSize;

dwFileSize= GetFileSize(hFile,NULL);
if(dwFileSize!= 0xFFFFFFFF)
{
LPSTR pszFileText;

pszFileText= GlobalAlloc(GPTR,dwFileSize + 1);
if(pszFileText!= NULL)
{
DWORD dwRead;

if(ReadFile(hFile,pszFileText,dwFileSize,&dwRead,NULL))
{
pszFileText[dwFileSize]= 0;
if(SetWindowText(hEdit,pszFileText))
bSuccess= TRUE;
}
GlobalFree(pszFileText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}



It has a great deal of error checking, and I think that's where the problem lies. Can anyone tell me how to set this up properly in Lite-C Legacy?

EDIT: If this belongs more in the Higher Languages forum, then feel free to move it.

Last edited by MrCode; 11/05/07 00:18.

Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}