CompuServe Messages

#Locating Dialogs

    04-Jan-95 21:33:28
Sb: #145051-#Locating Dialogs
Fm: Alfonso Hermida 72114,2060
To: Jonas Ruikis [ADESK] 73172,1351
Jonas: I developed this code to handle the dialog location. I have to thank Stefan Didak who gave me a hint on how to code it. // assumptions: // 1) Dialog was created with upper left corner at origin // 2) center of Dialog will be positioned to the right @ // X = MAXX + (MAXX-MAXY)/2 = MAXY/2 // Y = (MAXY – dialog[0].height)/2 // // If someone has the time and patience, please make this function more general // like locate_dialog_at(x,y) where x,y are the upper left corner coordinates of the // dialog. int MAXX, MAXY; // maximum coordinates in X and Y, GLOBAL VARIABLES!!! void Do_User_Interface(void) { ScrnInfo screen; init_dialog( maindlg, main_edit, NULL); ready_dialog ( maindlg, main_edit, NULL, main_feel, main_rad, NULL, NULL ); gfx_scrn_info(&screen); MAXX = screen.sc_width; MAXY = screen.sc_height; center_dialog( maindlg ); locate_dialog( maindlg ); gfx_clearscreen(); gfx_cblock(0,0,MAXX,MAXY,6); // fill whole screen draw_dialog( maindlg ); do_dialog ( maindlg, -1 ); gfx_redraw(); } // The code that does the trick! // by Alfonso Hermida void locate_dialog(Dialog *root) { int max, start=0, i; max = dlg_item_count(root,start); root[0].sx += MAXY/2; root[0].sy = (MAXY – root[0].height)/2; for(i=start;i<max;i++) { root[i].sx = root[i].x + root[0].sx; root[i].sy = root[i].y + root[0].sy; } } /* Alfonso */