Пример #1
0
HWND
mswin_init_main_window()
{
    static int run_once = 0;
    HWND ret;
    RECT rc;

    /* register window class */
    if (!run_once) {
        LoadString(GetNHApp()->hApp, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
        register_main_window_class();
        run_once = 1;
    }

    /* create the main window */
    SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);

    ret = CreateWindow(szMainWindowClass,  /* registered class name */
                       szTitle,            /* window name */
                       WS_CLIPCHILDREN,    /* window style */
                       rc.left,            /* horizontal position of window */
                       rc.top,             /* vertical position of window */
                       rc.right - rc.left, /* window width */
                       rc.bottom - rc.top, /* window height */
                       NULL, /* handle to parent or owner window */
                       NULL, /* menu handle or child identifier */
                       GetNHApp()->hApp, /* handle to application instance */
                       NULL              /* window-creation data */
                       );

    if (!ret)
        panic("Cannot create main window");
    return ret;
}
Пример #2
0
HWND mswin_init_main_window () {
	static int run_once = 0;
	HWND ret;
    WINDOWPLACEMENT wp;

	/* register window class */
	if( !run_once ) {
		LoadString(GetNHApp()->hApp, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
		register_main_window_class( );
		run_once = 1;
	}
	
	/* create the main window */
	ret = CreateWindow(
			szMainWindowClass,		/* registered class name */
			szTitle,				/* window name */
			WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, /* window style */
			CW_USEDEFAULT,			/* horizontal position of window */
			CW_USEDEFAULT,			/* vertical position of window */
			CW_USEDEFAULT,			/* window width */
			CW_USEDEFAULT,			/* window height */
			NULL,					/* handle to parent or owner window */
			NULL,					/* menu handle or child identifier */
			GetNHApp()->hApp,		/* handle to application instance */
			NULL					/* window-creation data */
		);

	if( !ret ) panic("Cannot create main window");

    
    if (GetNHApp()->regMainMinX != CW_USEDEFAULT)
    {
        wp.length = sizeof(wp);
        wp.showCmd = GetNHApp()->regMainShowState;

        wp.ptMinPosition.x = GetNHApp()->regMainMinX;
        wp.ptMinPosition.y = GetNHApp()->regMainMinY;

        wp.ptMaxPosition.x = GetNHApp()->regMainMaxX;
        wp.ptMaxPosition.y = GetNHApp()->regMainMaxY;

        wp.rcNormalPosition.left = GetNHApp()->regMainLeft;
        wp.rcNormalPosition.top = GetNHApp()->regMainTop;
        wp.rcNormalPosition.right = GetNHApp()->regMainRight;
        wp.rcNormalPosition.bottom = GetNHApp()->regMainBottom;
        SetWindowPlacement(ret, &wp);
    }
    else
        ShowWindow(ret, SW_SHOWDEFAULT);
    UpdateWindow(ret);

	return ret;
}