23 December 2023, 01:25 | #1 |
A1200 040 SAM440EP 667
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
|
Icons doesn´t work
Hi, every project I compile with StormC and then add to its executable an Icon, when I run it from it´s Icon, gives me a message of "attemping to launch..." in WB but nothing happens.
If I run it through Shell or directly through StormC it works but through its icon it does nothing. In the icon information I choose "Start from: Workbench" The icon type is: tool Why this happens?? How could I make its icon works? Here an example of the code: Code:
#include <proto/exec.h> #include <proto/dos.h> #include <proto/graphics.h> #include <proto/intuition.h> #include <proto/gadtools.h> #define GID_UP 1001 #define GID_DOWN 1002 int main(int argc, char **argv) { struct Screen *scr; struct Window *win; struct IntuiMessage *mess; BOOL cont; long scroll = 0; struct Gadget *glist = NULL; struct Gadget *gad; struct NewGadget ng; long winw,winh; long y = 0; scr = LockPubScreen (NULL); gad = CreateContext (&glist); ng.ng_LeftEdge = 0; ng.ng_TopEdge = 20 * scr->RastPort.TxHeight; ng.ng_Width = 20 * scr->RastPort.TxWidth; ng.ng_Height = scr->RastPort.TxHeight + 6; ng.ng_GadgetText = "Up"; ng.ng_TextAttr = scr->Font; ng.ng_GadgetID = GID_UP; ng.ng_Flags = 0; ng.ng_VisualInfo = GetVisualInfo (scr,TAG_END); gad = CreateGadget (BUTTON_KIND,gad,&ng,GA_Immediate,TRUE,TAG_END); ng.ng_LeftEdge += ng.ng_Width; ng.ng_GadgetText = "Down"; ng.ng_GadgetID = GID_DOWN; gad = CreateGadget (BUTTON_KIND,gad,&ng,GA_Immediate,TRUE,TAG_END); winw = ng.ng_LeftEdge + ng.ng_Width + scr->WBorLeft + scr->WBorRight; winh = ng.ng_TopEdge + ng.ng_Height + scr->WBorTop + scr->WBorBottom + scr->RastPort.TxHeight + 1; win = OpenWindowTags (NULL, WA_Left,(scr->Width - winw) / 2, WA_Top,(scr->Height - winh) / 2, WA_Width,winw, WA_Height,winh, WA_Flags,WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_ACTIVATE | WFLG_GIMMEZEROZERO | WFLG_NOCAREREFRESH, WA_IDCMP,IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_GADGETUP | IDCMP_GADGETDOWN, WA_Gadgets,glist, TAG_END); if (!win) { printf ("cannot open window\n"); return (RETURN_FAIL); } else { GT_RefreshWindow (win,NULL); SetFont (win->RPort,scr->RastPort.Font); SetABPenDrMd (win->RPort,1,0,JAM2); cont = TRUE; do { if (scroll) { if (scroll > 0) { if (gad->Flags & GFLG_SELECTED) { ScrollRaster (win->RPort,0,-1,0,0,win->GZZWidth - 1,win->GZZHeight - ng.ng_Height - 1); y ++; if (y >= win->RPort->TxHeight) { y = 0; Move (win->RPort,0,win->RPort->TxBaseline); Text (win->RPort,"Text Text Text Text Text Text Text Text Text",44); } } } else { if (gad->Flags & GFLG_SELECTED) { ScrollRaster (win->RPort,0,1,0,0,win->GZZWidth - 1,win->GZZHeight - ng.ng_Height - 1); y --; if (y < 0) { y = win->RPort->TxHeight - 1; Move (win->RPort,0,win->GZZHeight - ng.ng_Height - win->RPort->TxHeight + win->RPort->TxBaseline); Text (win->RPort,"Text Text Text Text Text Text Text Text Text",44); } } } WaitTOF(); if (SetSignal (0,0) & SIGBREAKF_CTRL_C) cont = FALSE; } else { if (Wait ((1L << win->UserPort->mp_SigBit) | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) cont = FALSE; } while (mess = GT_GetIMsg (win->UserPort)) { switch (mess->Class) { case IDCMP_GADGETDOWN: gad = (struct Gadget *)mess->IAddress; switch (gad->GadgetID) { case GID_UP: scroll = -1; break; case GID_DOWN: scroll = 1; break; } break; case IDCMP_GADGETUP: scroll = 0; break; case IDCMP_VANILLAKEY: if (mess->Code == 0x1b) /* Esc */ cont = FALSE; break; case IDCMP_CLOSEWINDOW: cont = FALSE; break; } GT_ReplyIMsg (mess); } } while (cont); CloseWindow (win); } FreeGadgets (glist); FreeVisualInfo (ng.ng_VisualInfo); UnlockPubScreen (NULL,scr); return (RETURN_OK); } |
23 December 2023, 06:08 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,028
|
Storm does not call main() if the program is run from Workbench, it calls wbmain().
Add this to the end of your program to make it compatible with other compilers: Code:
void wbmain (struct WBStartup *wbmsg) { main (0,(char **)wbmsg); } |
23 December 2023, 13:18 | #3 |
A1200 040 SAM440EP 667
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
|
Thanks thomas, I will try it when I'm at home
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WriteLUTPixelArray() doesn't work | softwarefailure | support.WinUAE | 2 | 21 February 2020 15:48 |
Why doesn't this work? | volvo_0ne | Coders. AMOS | 2 | 03 April 2017 15:18 |
Entity doesn't work | Another World | support.Games | 10 | 14 May 2007 11:49 |
A500 doesn't work | Jan | support.Hardware | 6 | 07 May 2003 15:48 |
WinFellow doesn't work | Ian | support.WinFellow | 5 | 03 May 2003 22:04 |
|
|