Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,388 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
(Win32) UGH! Opening Files #165862
11/04/07 21:14
11/04/07 21:14
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
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");
}
Re: (Win32) UGH! Opening Files [Re: MrCode] #165863
11/06/07 02:01
11/06/07 02:01
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Nobody?


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: (Win32) UGH! Opening Files [Re: MrCode] #165864
11/07/07 02:29
11/07/07 02:29
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I'm wondering if there's something wrong with the forums or my browser, because I haven't gotten any responses in any of the most recent threads I've posted. Granted, I solved some of those problems on my own, but I'm really stumped with this one. I've never worked with the Windows API before until just a few days ago, and I really would like to know how to actually use this function.

I'll give you the real scoop: it's opening the Open window, but if I double-click on a file (or type it into the filename bar), it doesn't open. I'm thinking that the reason is that this function isn't working properly. I guess I haven't been clear enough..

Maybe I should take this to Higher Languages or even MSDN?


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

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1