// CREATE THE NOTEBOOK WINDOW BOOL CreateNotebook(PNBHDR pNotebookHdr) { int i; // Set the page background and tab background colors to grey so they are the same as a dlg box. WinSendMsg(pNotebookHdr->hwndNB, BKM_SETNOTEBOOKCOLORS, MPFROMLONG(SYSCLR_FIELDBACKGROUND), MPFROMSHORT(BKA_BACKGROUNDPAGECOLORINDEX)); WinSendMsg(pNotebookHdr->hwndNB, BKM_SETNOTEBOOKCOLORS, MPFROMLONG(SYSCLR_FIELDBACKGROUND), MPFROMSHORT(BKA_BACKGROUNDMAJORCOLORINDEX)); WinSendMsg(pNotebookHdr->hwndNB, BKM_SETNOTEBOOKCOLORS, MPFROMLONG(SYSCLR_FIELDBACKGROUND), MPFROMSHORT(BKA_BACKGROUNDMINORCOLORINDEX)); if (!SetTabDimensions(pNotebookHdr)) return FALSE; // Insert all the pages into the notebook and configure them. The dialog // boxes are not going to be loaded and associated with those pages yet. for ( i = 0; ( i < pNotebookHdr->nPages ); i++ ) { if ( !SetUpPage( pNotebookHdr, i )) return FALSE; } return TRUE; }
BOOL CreateNotebookWindow( HWND hwndFrame ) { BOOL fSuccess = TRUE; // Make the notebook's id FID_CLIENT so we don't need a client window. This // will make the notebook automatically size with the frame window and // eliminate the need for a client window. hwndBook = WinCreateWindow( hwndFrame, WC_NOTEBOOK, NULL, BKS_BACKPAGESBR | BKS_MAJORTABRIGHT | BKS_ROUNDEDTABS | BKS_STATUSTEXTCENTER | BKS_SPIRALBIND | WS_VISIBLE, 0, 0, 0, 0, hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL ); if( hwndBook ) { int i, cxTab = 0, cyTab = 0, cxPage = 0, cyPage = 0; FONTMETRICS fm; HPS hps = WinGetPS( hwndBook ); if( GpiQueryFontMetrics( hps, sizeof fm, &fm ) ) { cyTab = fm.lMaxBaselineExt; // Set the page background color to grey so it is the same as // a dialog box. if( !WinSendMsg( hwndBook, BKM_SETNOTEBOOKCOLORS, MPFROMLONG( SYSCLR_FIELDBACKGROUND ), MPFROMSHORT( BKA_BACKGROUNDPAGECOLORINDEX ) ) ) Msg( "BKM_SETNOTEBOOKCOLRS (BACKPAGE) RC(%X)", HWNDERR( hwndBook ) ); // Set the tab background color to grey so it is the same as // the page background. Note that the page packground also // dictates the color of the foreground tab (the one attached // to the top page). We want to make the background of all the // tabs to be the same color. if( !WinSendMsg( hwndBook, BKM_SETNOTEBOOKCOLORS, MPFROMLONG( SYSCLR_FIELDBACKGROUND ), MPFROMSHORT( BKA_BACKGROUNDMAJORCOLORINDEX ) ) ) Msg( "BKM_SETNOTEBOOKCOLRS (BACKTAB) RC(%X)", HWNDERR( hwndBook ) ); // Insert all the pages into the notebook and configure them. // The dialog boxes will also be loaded now. Also, the width and // height of the biggest dialog will be passed back as well as the // width of the widest tab text. for( i = 0; i < PAGE_COUNT && fSuccess; i++ ) fSuccess = SetUpPage( hps, &PgConsts[ i ], &cxTab, &cxPage, &cyPage ); if( fSuccess ) { // Set the tab height and width based on the biggest bitmap. WinSendMsg( hwndBook, BKM_SETDIMENSIONS, MPFROM2SHORT( cxTab + TAB_CX_MARGIN, cyTab + TAB_CY_MARGIN ), MPFROMSHORT( BKA_MAJORTAB ) ); // Set the minor tab height/width to zero so we get rid of the // bottom part of the notebook. WinSendMsg( hwndBook, BKM_SETDIMENSIONS, MPFROM2SHORT( 0, 0 ), MPFROMSHORT( BKA_MINORTAB ) ); fSuccess = SetFramePos( hwndFrame, cxPage, cyPage ); if( !fSuccess ) WinDestroyWindow( hwndBook ); } else WinDestroyWindow( hwndBook ); } else { fSuccess = FALSE; WinDestroyWindow( hwndBook ); Msg( "CreateNBWindow GpiQuery..Metrics RC(%X)", HWNDERR(hwndBook) ); } WinReleasePS( hps ); } else { fSuccess = FALSE; Msg( "CreateNotebookWindow WinCreateWindow RC(%X)",HWNDERR(hwndFrame)); } return fSuccess; }