I'm trying to write an HLA rich editor to familiarize myself with windows, dialogs and menus as a precursor to other windows projects.

Sadly, I've hardly begun and already I'm stuck. The program has progressed far enough to compile with no complaints. I've set up some basic menus to fill in as I advance through the code and managed to slap on a Rich Edit control.

I first tried to code in the open file dialog. I can manage to open a file dialog, and store a selection from it. However, I can't get the RichEdit to stream in the data.

Here is an attachment of the code if anyone is willing to help me tackle this one.
Posted on 2003-11-23 02:55:07 by Kain

I think I might have found one of the problems with your code. For the callback procedures you should add the @stdcall option because HLA uses the pascal calling convention by default and windows uses the stdcall convention. This is the reason why you notice that the parameters for WndProc are reversed. I tried adding the @stdcall option to your code myself but its still not streaming in the data so something else must also be wrong but i don't know what it is. :) I don't know much about rich edit controls but I've looked at the iczelion's rich edit example and compared it with yours and I don't know why yours is not working.
Posted on 2003-11-23 12:42:28 by Odyssey
Thanks. I'll change it and fiddle around some more.
Posted on 2003-11-23 12:47:34 by Kain
I tried it with @stdcall switch and the program freezes. So I recompiled without the -w swicth, added some stdout.puts to mark the passage of the code.

The program is getting stuck in an infinite call loop at the EditStreamRead procedure.
Posted on 2003-11-23 14:05:55 by Kain
Revisiting an old friend:

I know it's been a while, but I finally managed to solve this problem (after many hours, I might add), but sadly to say, it was through guesswork as I don't understand the particulars of HLA parameter passing to procedures, even after reading about them ( I guess I'm slow on this respect).

My problem was in the Editstream callback procedure:

procedure StreamInProc (pBytesRead:dword ; NumBytes:dword ; pBuffer:dword ; hFile:dword);

begin StreamInProc;

xor (1, eax);

end StreamInProc;

This would cause an infinite loop, the only way to exit being ctrl-alt-del

After re-reading about paramter passing, I experimented by randomly placing val and var on the above parameters until I stumbled upon the correct pattern:

procedure StreamInProc (var pBytesRead:dword ; NumBytes:dword ; var pBuffer:dword ; hFile:dword);

begin StreamInProc;

xor (1, eax);

end StreamInProc;

After entering this, I was expecting the program to crash again by joy of joy, I stared at the file I was attempting to load displayed in my richedit control! Ahhh I have exorcised the demons!

So, is there a cut and dry way to figure out when one needs to use them or should I be looking for a new hobby?

[ thanks to those who took some of their own time to help me with this. I hope the solution will be helpful to you as well]
Posted on 2003-12-15 23:17:31 by Kain
As the whole issue of pass by reference and pass by value is somewhat confusing to many new HLA programmers, I'm going to post an article on this subject within a day or so (here and on Webster). In the meantime, I strongly recommend the following sources of information on this subject:



and especially:


Randy Hyde
Posted on 2003-12-16 10:57:19 by rhyde