home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / msysjour / vol04 / 01b / macsl / mpmfig4.txt < prev    next >
Text File  |  1988-10-27  |  3KB  |  95 lines

  1. HWND APIENTRY WinCreateStdWindow( hwndParent, flStyle, pCtlData,
  2.                                   pszClassClient, pszTitle,
  3.                                   flStyleClient, hmod, idResources,
  4.                                   phwndClient )
  5.     HWND        hwndParent;
  6.     ULONG       flStyle, flStyleClient;
  7.     PVOID       pCtlData;
  8.     PSZ         pszClassClient, pszTitle;
  9.     HMODULE     hmod;
  10.     USHORT      idResources;
  11.     PHWND       phwndClient;
  12. {
  13.     HWND        hwndFrame, hwndClient;
  14.     SHORT       x, y, cx, cy;
  15.     ULONG       flFrameFlags;
  16.  
  17.     /* Pick up frame flags, take care of special hwndParent values */
  18.  
  19.     flFrameFlags = ( pCtlData ? *(PULONG)pCtlData : 0 );
  20.  
  21.     if( ! hwndParent || hwndParent == HWND_DESKTOP )
  22.       hwndParent = _hwndDesktop;
  23.  
  24.     ASSERT( hwndParent == _hwndDesktop,
  25.             "WinCreateStdWindow: Must be a top level window" );
  26.     ASSERT( ! hmod,
  27.             "WinCreateStdWindow: hmod must be NULL" );
  28.     ASSERT( ! (flStyle & WS_CLIPCHILDREN),
  29.             "WinCreateStdWindow: WS_CLIPCHILDREN not allowed" );
  30.  
  31.     /* Assign default position if visible */
  32.  
  33.     if( flStyle & WS_VISIBLE )
  34.     {
  35.       x = 10;       /* TEMP HACK */
  36.       y = screenBits.bounds.bottom - 200;
  37.       cx = 250;
  38.       cy = 150;
  39.     }
  40.     else
  41.       x = y = cx = cy = 0;
  42.  
  43.     /* Create the frame window itself */
  44.  
  45.     hwndFrame =
  46.       WinCreateWindow( hwndParent, WC_FRAME, _szNull,
  47.                        flStyle & ~WS_VISIBLE, x, y, cx, cy,
  48.                        NULL, HWND_TOP, idResources, pCtlData, NULL );
  49.  
  50.     if( ! hwndFrame )
  51.       return NULL;
  52.  
  53.     /* Create frame controls according to flFrameFlags */
  54.  
  55.     MpmFrameUpdate( hwndFrame, flFrameFlags );
  56.  
  57.     /* Create client window if requested */
  58.  
  59.     if( pszClassClient && *pszClassClient )
  60.     {
  61.       *phwndClient = hwndClient =
  62.         WinCreateWindow(
  63.           hwndFrame, pszClassClient, _szNull, flStyleClient,
  64.           0, 0, 0, 0, hwndFrame, HWND_BOTTOM, FID_CLIENT, NULL, NULL
  65.         );
  66.       if( ! hwndClient )
  67.         goto exitDestroy;
  68.     }
  69.  
  70.     /* Create menu and initialize title */
  71.  
  72.     if( flFrameFlags & FCF_MENU )
  73.       if( ! MpmMenuLoad( hwndFrame, idResources ) )
  74.         goto exitDestroy;
  75.  
  76.     if( flFrameFlags & FCF_TITLEBAR )
  77.       WinSetWindowText( hwndFrame, pszTitle );
  78.  
  79.     /* Make window visible if requested */
  80.  
  81.     if( flStyle & WS_VISIBLE )
  82.     {
  83.       WinSendMsg( hwndFrame, WM_FORMATFRAME, 0L, 0L );
  84.       WinShowWindow( hwndFrame, TRUE );
  85.     }
  86.  
  87.     return hwndFrame;
  88.  
  89. exitDestroy:
  90.     if( pszClassClient && *pszClassClient )
  91.       *phwndClient = NULL;
  92.     WinDestroyWindow( hwndFrame );
  93.     return NULL;
  94. }
  95.