Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: jonssonj on October 24, 2003, 12:34:45 PM
-
Hello!
Is there anyone that have an simple example code of opening and closing a window in amiga os, that are made in Storm C 4?
Very thankful for any example.
Regards from jonssonj
-
Well, StormC is like any other C, so every example should work. I don't have my Storm C installation here at work, so I cannot verify now if there are some specialties to attend.
Here is an example that works great with Dice C and VBCC. From my experience there should be no difficulty with Storm C.
#include
#include
#include
int main (int argc,char **argv)
{
BOOL cont;
struct Window *win;
struct RastPort *rp;
struct MsgPort *port;
struct IntuiMessage *mess;
if (win = OpenWindowTags (NULL,
WA_Left,20,WA_Top,10,
WA_Width,200,WA_Height,50,
WA_Title,"My Window",
WA_Flags,WFLG_CLOSEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_ACTIVATE|WFLG_GIMMEZEROZERO,
WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY,
TAG_END))
{
port = win->UserPort;
rp = win->RPort;
SetDrMd (rp,JAM2);
SetAPen (rp,1);
SetBPen (rp,2);
Move (rp,10,20);
Text (rp,"Close me !",10);
cont = TRUE;
while (cont)
{
WaitPort (port);
while (mess = (struct IntuiMessage *) GetMsg (port))
{
switch (mess->Class)
{
case IDCMP_CLOSEWINDOW:
cont = FALSE;
break;
case IDCMP_VANILLAKEY:
if (mess->Code == 0x1b) /* Esc */
cont = FALSE;
break;
}
ReplyMsg ((struct Message *)mess);
}
}
CloseWindow (win);
}
return (0);
}
Bye,
Thomas
-
#include
#include
#include
...and to make it work on all amiga compilers, use:
#include
#include
#include
-
I was just about to say the same thing...
-
I will try it out when I get home from work. I had an old example that was made for WB1.3, they used the exit() function and Storm C could not find a prototype for exit().
The strange thing was that Storm C could not find a prototype for CloseLibrary either. But I will try your example as soon as I get home... :-D
-
Piru wrote:
...and to make it work on all amiga compilers, use:
#include
#include
#include
Erm, no. Dice C has heavy problems with register calls (proto/xxx includes pragma/xxx). Sometimes it uses A6 as a scratch register after it has loaded the library base into it and other faults. Also it easily runs out of registers.
Bye,
Thomas
-
Erm, no. Dice C has heavy problems with register calls (proto/xxx includes pragma/xxx). Sometimes it uses A6 as a scratch register after it has loaded the library base into it and other faults. Also it easily runs out of registers.
If that is indeed the case, Dice C deserves to die already. There are better working alternatives now.