コード例 #1
0
ファイル: os2nb.c プロジェクト: ErisBlastar/osfree
// Set the notebook and top-level dialog sizes based on the page sizes
void SetNotebookSize(PNBHDR pNotebookHdr)
{
	int i;
	RECTL rcl;
	SWP swp;
	HWND hwndNB = pNotebookHdr->hwndNB;
	LONG cx, cy, px, py;

	(void) memset(&rcl, 0, sizeof(RECTL));

	// Get the size of a notebook page by finding the dimensions of the largest
	// dialog.

	for (i = 0; i < pNotebookHdr->nPages; i++) {

		// Get the height and width of the dialog. Also fill in the id of the
		// item that is to get focus when the dialog is brought up.
		if (pNotebookHdr->PageArray[i].idDlg) {
			GetDialogDimensions(pNotebookHdr->PageArray[i].idDlg, &cx, &cy, &(pNotebookHdr->PageArray[i].idFocus));
			if (cx > rcl.xRight)
				rcl.xRight = cx;
			if (cy > rcl.yTop)
				rcl.yTop = cy;
		}
	}

	// Adjust the notebook so it is big enough for the pages
	WinMapDlgPoints(HWND_DESKTOP, (PPOINTL) &rcl, 2, TRUE);
	WinSendMsg(hwndNB, BKM_CALCPAGERECT, MPFROMP(&rcl), MPFROMLONG(FALSE));
	WinSetWindowPos(hwndNB, NULLHANDLE, 0, 0, rcl.xRight-rcl.xLeft, rcl.yTop-rcl.yBottom, SWP_SIZE);

	// Calculate the size required for the dialog window
	WinQueryWindowPos(hwndNB, &swp);
	rcl.xLeft = 0;
	rcl.yBottom = 0;
	rcl.xRight = swp.x + swp.cx;
	rcl.yTop = swp.y + swp.cy;
	WinCalcFrameRect(pNotebookHdr->hwndNBDlg, &rcl, FALSE );

	// Find the centered position and size, and adjust the dialog window so
	// it is centered, and big enough for the notebook
	cx = rcl.xRight - rcl.xLeft;
	cy = rcl.yTop - rcl.yBottom;
	px = (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN) - cx) / 2;
	py = (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - cy) / 2;
	WinSetWindowPos(pNotebookHdr->hwndNBDlg, NULLHANDLE, px, py, cx, cy, SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ACTIVATE);
}
コード例 #2
0
BOOL SetUpPage( HPS hps, PPAGECONSTANTS pPgConsts, int *pcxTab, int *pcxPage,
                int *pcyPage )
{
    BOOL      fSuccess = TRUE;
    ULONG     ulPageId;
    PPAGEDATA pPageData;

    // Insert a page into the notebook. Specify that it is to have status text
    // and the window associated with each page will be automatically sized by
    // the notebook according to the size of the page.

    ulPageId = (ULONG) WinSendMsg( hwndBook, BKM_INSERTPAGE, NULL,
                                   MPFROM2SHORT( BKA_MAJOR | BKA_STATUSTEXTON |
                                   BKA_AUTOPAGESIZE, BKA_LAST ) );

    if( ulPageId )
    {
        POINTL aptl[ TXTBOX_COUNT ];

        pPageData = (PPAGEDATA) malloc( sizeof( PAGEDATA ) );

        if( pPageData )
        {
            memset( pPageData, 0, sizeof *pPageData );
            pPageData->cb       = sizeof *pPageData;
            pPageData->pfnwpDlg = pPgConsts->pfnwpDlg;
            pPageData->idDlg    = pPgConsts->idDlg;
            pPageData->idPage   = pPgConsts->idPage;

            // Insert a pointer to this page's info into the space available
            // in each page (its PAGE DATA that is available to the application).

            fSuccess = (BOOL) WinSendMsg( hwndBook, BKM_SETPAGEDATA,
                                          MPFROMLONG( ulPageId ),
                                          MPFROMP( pPageData ) );

            // Set the text into the status line.

            if( fSuccess )
            {
                fSuccess = (BOOL) WinSendMsg( hwndBook, BKM_SETSTATUSLINETEXT,
                                       MPFROMP( ulPageId ),
                                       MPFROMP( pPgConsts->szStatusLineText ) );

                if( fSuccess )
                    fSuccess = (BOOL) WinSendMsg( hwndBook, BKM_SETTABTEXT,
                                       MPFROMP( ulPageId ),
                                       MPFROMP( pPgConsts->szTabText ) );

                else
                    Msg( "BKM_SETSTATUSLINETEXT RC(%X)", HWNDERR( hwndBook ) );
            }
            else
                Msg( "BKM_SETPAGEDATA RC(%X)", HWNDERR( hwndBook ) );

            if( fSuccess )
            {
                // Get the size, in pixels, of the tab text for this page. If
                // it is longer than the currently longest text, set it as the
                // new longest text.

                if( GpiQueryTextBox( hps, strlen( pPgConsts->szTabText ),
                                   pPgConsts->szTabText, TXTBOX_COUNT, aptl ) )
                {
                    if( aptl[ TXTBOX_CONCAT ].x > *pcxTab )
                        *pcxTab = aptl[ TXTBOX_CONCAT ].x;
                }
                else
                {
                    fSuccess = FALSE;
                    Msg( "SetUpPage GpiQueryTextBox RC(%X)", HWNDERR( hwndBook ) );
                }
            }
        }
        else
        {
            fSuccess = FALSE;
            Msg( "Out of memory in SetUpPage!" );
        }
    }
    else
    {
        fSuccess = FALSE;
        Msg( "SetUpPage BKM_INSERTPAGE RC(%X)", HWNDERR( hwndBook ) );
    }

    if( fSuccess )
    {
        LONG cx, cy;

        // Keep an ongoing count of the widest and tallest dialog
        // dimensions needed for an optimal notebook size.

        if( GetDialogDimensions( pPgConsts->idDlg, &cx, &cy ) )
        {
            if( cx > *pcxPage )
                *pcxPage = cx;
            if( cy > *pcyPage )
                *pcyPage = cy;
        }
    }

    return fSuccess;
}