Beispiel #1
0
/**
 * Create Emulator Window
 */
void CreateEmulatorWindow() {
    HINSTANCE hInstance = GetModuleHandle(NULL);
    static char szAppName[] = "MIDP stack";
    WNDCLASSEX  wndclass ;
    HWND hwnd;
    HDC hdc;
    HMENU hMenu = NULL;
    static WORD graybits[] = {0xaaaa, 0x5555, 0xaaaa, 0x5555,
                              0xaaaa, 0x5555, 0xaaaa, 0x5555
                             };

    unsigned int width ;//REMREM = EMULATOR_WIDTH;
    unsigned int height; //REMREM = EMULATOR_HEIGHT;
    static char caption[32];

    hPhoneBitmap = loadBitmap("phone.bmp",&width,&height);
    printf("[CreateEmulatorWindow] Window size %dx%d\n",width, height);
    sprintf(caption, "+%d Sun Anycall", _phonenum);

    (void) javacall_lcd_init();

    wndclass.cbSize        = sizeof (wndclass) ;
    wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
    wndclass.lpfnWndProc   = WndProc ;
    wndclass.cbClsExtra    = 0 ;
    wndclass.cbWndExtra    = 0 ;
    wndclass.hInstance     = hInstance ;
    wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
    wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
    wndclass.hbrBackground = (HBRUSH) BACKGROUND_BRUSH;
    wndclass.lpszMenuName  = NULL ;
    wndclass.lpszClassName = szAppName ;
    wndclass.hIconSm       = LoadIcon (NULL, IDI_APPLICATION) ;

    RegisterClassEx (&wndclass) ;
#ifdef SKINS_MENU_SUPPORTED
    hMenu = buildSkinsMenu();

    if(hMenu != NULL) height += 24;
#endif

    hwnd = CreateWindow(szAppName,            /* window class name       */
                        caption,              /* window caption          */
                        WS_OVERLAPPEDWINDOW & /* window style; disable   */
                        (~WS_MAXIMIZEBOX),    /* the 'maximize' button   */
                        50,        /* initial x position      */
                        30,        /* initial y position      */
                        /* window made smaller to hide the external
                           screen part since it's not in use for now
                        */
                        (width/2),                 /* initial x size          */
                        (height),               /* initial y size          */
                        NULL,                 /* parent window handle    */
                        hMenu,                /* window menu handle      */
                        hInstance,            /* program instance handle */
                        NULL);                /* creation parameters     */

    hMainWindow = hwnd;

    /* create back buffer from mutable image, include the bottom bar. */
    initScreenBuffer(DISPLAY_WIDTH, DISPLAY_HEIGHT);

    /* colors chosen to match those used in topbar.h */
    whitePixel = 0xffffff;
    blackPixel = 0x000000;
    lightGrayPixel = RGB(182, 182, 170);
    darkGrayPixel = RGB(109, 109, 85);

    foregroundColor = blackPixel;
    backgroundColor = lightGrayPixel;

    /* brushes for borders and menu hilights */
    darkGrayBrush = CreateSolidBrush(darkGrayPixel);
    darkGrayPen = CreatePen(PS_SOLID, 1, darkGrayPixel);
    whiteBrush = CreateSolidBrush(whitePixel);
    whitePen = CreatePen(PS_SOLID, 1, whitePixel);

    BACKGROUND_BRUSH = CreateSolidBrush(backgroundColor);
    BACKGROUND_PEN   = CreatePen(PS_SOLID, 1, backgroundColor);
    FOREGROUND_BRUSH = CreateSolidBrush(foregroundColor);
    FOREGROUND_PEN   = CreatePen(PS_SOLID, 1, foregroundColor);

    hdc = GetDC(hwnd);
    setupMutex();
    ReleaseDC(hwnd, hdc);

    ShowWindow(hwnd, SW_SHOWNORMAL);
    UpdateWindow(hwnd);
}
void SecurityInitialize(void) throw (SecurityException)
{
	setupMutex();
}