1 #include <Application.h> 2 #include <Screen.h> 3 4 #include <stdio.h> 5 #include <string.h> 6 7 int main() 8 { 9 BApplication app("application/x-vnd.BScreenTest"); 10 BScreen screen; 11 12 if (!screen.IsValid()) { 13 printf("Invalid BScreen object\n"); 14 exit(-1); 15 } 16 17 display_mode oldMode; 18 status_t status = screen.GetMode(&oldMode); 19 if (status < B_OK) 20 printf("%s\n", strerror(status)); 21 else 22 printf("width: %d, height: %d, space: %lu\n", 23 oldMode.virtual_width, 24 oldMode.virtual_height, 25 oldMode.space); 26 27 printf("Screen frame: "); 28 screen.Frame().PrintToStream(); 29 30 printf("\nTrying to set mode to 800x600: "); 31 display_mode newMode = oldMode; 32 newMode.virtual_width = 800; 33 newMode.virtual_height = 600; 34 35 status = screen.SetMode(&newMode); 36 if (status < B_OK) 37 printf("FAILED (%s)\n", strerror(status)); 38 else { 39 printf("OK\n"); 40 status_t status = screen.GetMode(&newMode); 41 if (status < B_OK) 42 printf("%s\n", strerror(status)); 43 else { 44 printf("width: %d, height: %d, space: %lu\n", 45 newMode.virtual_width, 46 newMode.virtual_height, 47 newMode.space); 48 printf("Screen frame: "); 49 screen.Frame().PrintToStream(); 50 printf("\n"); 51 } 52 } 53 54 snooze(4000000); 55 56 printf("resetting video mode: "); 57 status = screen.SetMode(&oldMode); 58 if (status < B_OK) 59 printf("FAILED (%s)\n", strerror(status)); 60 else 61 printf("OK\n"); 62 } 63