/* * Function: Process WM_INITDIALOG messages. Set the fonts * for all items on the dialog and populate the ticket list. * Also set the default values for user, instance and realm. * * Returns: TRUE if we didn't set the focus here, * FALSE if we did. */ static BOOL kwin_initdialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { LOGFONT lf; HDC hdc; char name[ANAME_SZ]; position_dialog(hwnd); ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); kwin_init_file_menu(hwnd); kwin_init_name(hwnd, (char *)lParam); hdc = GetDC(NULL); assert(hdc != NULL); memset(&lf, 0, sizeof(lf)); lf.lfHeight = -MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72); strcpy(lf.lfFaceName, "Arial"); hfontdialog = CreateFontIndirect(&lf); assert(hfontdialog != NULL); if (hfontdialog == NULL) { ReleaseDC(NULL, hdc); return TRUE; } lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); hfonticon = CreateFontIndirect(&lf); assert(hfonticon != NULL); if (hfonticon == NULL) { ReleaseDC(NULL, hdc); return TRUE; } ReleaseDC(NULL, hdc); set_dialog_font(hwnd, hfontdialog); GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); trim(name); if (strlen(name) > 0) SetFocus(GetDlgItem(hwnd, IDD_LOGIN_PASSWORD)); else SetFocus(GetDlgItem(hwnd, IDD_LOGIN_NAME)); ShowWindow(hwnd, dlgncmdshow); kwin_timer_id = SetTimer(hwnd, 1, KWIN_UPDATE_PERIOD, NULL); assert(kwin_timer_id != 0); return FALSE; }
int main(int argc, char *argv[]) { char buf[256]; int i; /* initialise everything */ if (allegro_init() != 0) return 1; install_keyboard(); install_mouse(); install_timer(); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); return 1; } } /* load the datafile */ replace_filename(buf, argv[0], "example.dat", sizeof(buf)); datafile = load_datafile(buf); if (!datafile) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Error loading %s!\n", buf); return 1; } set_palette(datafile[THE_PALETTE].dat); /* set up colors */ gui_fg_color = makecol(0, 0, 0); gui_mg_color = makecol(128, 128, 128); gui_bg_color = makecol(200, 240, 200); set_dialog_color(the_dialog, gui_fg_color, gui_bg_color); /* white color for d_clear_proc and the d_?text_procs */ the_dialog[0].bg = makecol(255, 255, 255); for (i = 4; the_dialog[i].proc; i++) { if (the_dialog[i].proc == d_text_proc || the_dialog[i].proc == d_ctext_proc || the_dialog[i].proc == d_rtext_proc) { the_dialog[i].bg = the_dialog[0].bg; } } /* fill in bitmap pointers */ the_dialog[BITMAP_OBJECT].dp = datafile[SILLY_BITMAP].dat; the_dialog[ICON_OBJECT].dp = datafile[SILLY_BITMAP].dat; /* shift the dialog 2 pixels away from the border */ position_dialog(the_dialog, 2, 2); /* do the dialog */ do_dialog(the_dialog, -1); unload_datafile(datafile); return 0; }