display image using allegro cgui
Ma AnSheng

I want to display a image in the screen,so I do this:

1static void operation_menu(void *data nouse)
2{
3 MkMenuItem(0, "Open", "Ctrl-O", openwi, NULL);
4 MkMenuItem(0, "Quit", "Ctrl-Q", quit, NULL);
5}
6 
7int main(void)
8{
9 PALLETE pal;
10 BITMAP *bj;
11 char buff[200]="..\\examples\\bj.bmp";
12 InitCgui(1024,768, 16);
13 if((bj=load_bmp(buff,pal))==NULL)
14 Req("Information","Cannot Load Background Bitmap|~Aborat");
15 else
16 blit(bj,screen,0,0,0,0,bj->w,bj->h);
17 MkDialogue(800,600, "Information",W_NOMOVE|W_CENTRE);
18 MkSingleMenu(TOPLEFT, "Operation", operation_menu, NULL);
19 AddButton(TOPLEFT, "\33E~xit", quit, NULL);
20 DisplayWin();
21 ProcessEvents();
22 return 0;
23}
24END_OF_MAIN();

In the beginning,it can display correctly,but when I click the menu the image disappear.How can make it not disappear?

GullRaDriel

From which version of allegro did you got those functions ?

Tell us more about:

MkMenuItem(...);
InitCgui(...);
MkDialogue(...);
MkSingleMenu(...);
AddButton(...);
DisplayWin(...);
ProcessEvents(...);

Please also give us:

  • Your allegro version

  • The compiler you use

  • The OS you target

You can also attach your full source code, in the case someone have enough time to read them.

Thread #586681. Printed from Allegro.cc