Ignore:
Timestamp:
Oct 2, 2001, 8:28:47 PM (24 years ago)
Author:
umoeller
Message:

Misc helpers updates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/winh.c

    r101 r106  
    5858#define INCL_WINSWITCHLIST
    5959#define INCL_WINBUTTONS
     60#define INCL_WINSTATICS
    6061#define INCL_WINMENUS
    6162#define INCL_WINSCROLLBARS
     
    8485#include "helpers\prfh.h"
    8586#include "helpers\gpih.h"
     87#include "helpers\standards.h"
    8688#include "helpers\stringh.h"
    8789#include "helpers\undoc.h"
     
    42754277
    42764278/*
     4279 *@@category: Helpers\PM helpers\Extended frame windows
     4280 */
     4281
     4282/* ******************************************************************
     4283 *
     4284 *   Extended frame
     4285 *
     4286 ********************************************************************/
     4287
     4288/*
     4289 *@@ fnwpSubclExtFrame:
     4290 *      subclassed frame window proc.
     4291 *
     4292 *@@added V0.9.16 (2001-09-29) [umoeller]
     4293 */
     4294
     4295MRESULT EXPENTRY fnwpSubclExtFrame(HWND hwndFrame, ULONG msg, MPARAM mp1, MPARAM mp2)
     4296{
     4297    MRESULT mrc = 0;
     4298
     4299    PEXTFRAMEDATA pData = (PEXTFRAMEDATA)WinQueryWindowPtr(hwndFrame, QWL_USER);
     4300
     4301    switch (msg)
     4302    {
     4303        case WM_QUERYFRAMECTLCOUNT:
     4304        {
     4305            // query the standard frame controls count
     4306            ULONG ulrc = (ULONG)pData->pfnwpOrig(hwndFrame, msg, mp1, mp2);
     4307
     4308            // if we have a status bar, increment the count
     4309            ulrc++;
     4310
     4311            mrc = (MPARAM)ulrc;
     4312        }
     4313        break;
     4314
     4315        case WM_FORMATFRAME:
     4316        {
     4317            // query the number of standard frame controls
     4318            ULONG ulCount = (ULONG)pData->pfnwpOrig(hwndFrame, msg, mp1, mp2);
     4319
     4320            // we have a status bar:
     4321            // format the frame
     4322            ULONG       ul;
     4323            PSWP        swpArr = (PSWP)mp1;
     4324
     4325            for (ul = 0; ul < ulCount; ul++)
     4326            {
     4327                if (WinQueryWindowUShort( swpArr[ul].hwnd, QWS_ID ) == 0x8008 )
     4328                                                                 // FID_CLIENT
     4329                {
     4330                    POINTL      ptlBorderSizes;
     4331                    ULONG       ulStatusBarHeight = 20;
     4332                    WinSendMsg(hwndFrame,
     4333                               WM_QUERYBORDERSIZE,
     4334                               (MPARAM)&ptlBorderSizes,
     4335                               0);
     4336
     4337                    // first initialize the _new_ SWP for the status bar.
     4338                    // Since the SWP array for the std frame controls is
     4339                    // zero-based, and the standard frame controls occupy
     4340                    // indices 0 thru ulCount-1 (where ulCount is the total
     4341                    // count), we use ulCount for our static text control.
     4342                    swpArr[ulCount].fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER;
     4343                    swpArr[ulCount].x  = ptlBorderSizes.x;
     4344                    swpArr[ulCount].y  = ptlBorderSizes.y;
     4345                    swpArr[ulCount].cx = swpArr[ul].cx;  // same as cnr's width
     4346                    swpArr[ulCount].cy = ulStatusBarHeight;
     4347                    swpArr[ulCount].hwndInsertBehind = HWND_BOTTOM; // HWND_TOP;
     4348                    swpArr[ulCount].hwnd = WinWindowFromID(hwndFrame, FID_STATUSBAR);
     4349
     4350                    // adjust the origin and height of the container to
     4351                    // accomodate our static text control
     4352                    swpArr[ul].y  += swpArr[ulCount].cy;
     4353                    swpArr[ul].cy -= swpArr[ulCount].cy;
     4354                }
     4355            }
     4356
     4357            // increment the number of frame controls
     4358            // to include our status bar
     4359            mrc = (MRESULT)(ulCount + 1);
     4360        }
     4361        break;
     4362
     4363        case WM_CALCFRAMERECT:
     4364        {
     4365            mrc = pData->pfnwpOrig(hwndFrame, msg, mp1, mp2);
     4366
     4367            // we have a status bar: calculate its rectangle
     4368            // CalcFrameRect(mp1, mp2);
     4369        }
     4370        break;
     4371
     4372        case WM_DESTROY:
     4373            WinSubclassWindow(hwndFrame, pData->pfnwpOrig);
     4374            free(pData);
     4375            WinSetWindowPtr(hwndFrame, QWL_USER, NULL);
     4376        break;
     4377
     4378        default:
     4379            mrc = pData->pfnwpOrig(hwndFrame, msg, mp1, mp2);
     4380    }
     4381
     4382    return (mrc);
     4383}
     4384
     4385/*
     4386 *@@ winhCreateStatusBar:
     4387 *      creates a status bar for a frame window.
     4388 *
     4389 *      Normally there's no need to call this manually,
     4390 *      this gets called by winhCreateExtStdWindow
     4391 *      automatically.
     4392 *
     4393 *@@added V0.9.16 (2001-09-29) [umoeller]
     4394 */
     4395
     4396HWND winhCreateStatusBar(HWND hwndFrame,
     4397                         HWND hwndOwner,
     4398                         const char *pcszText,      // in: initial status bar text
     4399                         const char *pcszFont,      // in: font to use for status bar
     4400                         LONG lColor)               // in: foreground color for status bar
     4401{
     4402    // create status bar
     4403    HWND        hwndReturn = NULLHANDLE;
     4404    PPRESPARAMS ppp = NULL;
     4405    winhStorePresParam(&ppp, PP_FONTNAMESIZE, strlen(pcszFont)+1, (PVOID)pcszFont);
     4406    lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
     4407    winhStorePresParam(&ppp, PP_BACKGROUNDCOLOR, sizeof(lColor), &lColor);
     4408    lColor = CLR_BLACK;
     4409    winhStorePresParam(&ppp, PP_FOREGROUNDCOLOR, sizeof(lColor), &lColor);
     4410    hwndReturn = WinCreateWindow(hwndFrame,
     4411                                 WC_STATIC,
     4412                                 (PSZ)pcszText,
     4413                                 SS_TEXT | DT_VCENTER | WS_VISIBLE,
     4414                                 0, 0, 0, 0,
     4415                                 hwndOwner,
     4416                                 HWND_TOP,
     4417                                 FID_STATUSBAR,
     4418                                 NULL,
     4419                                 ppp);
     4420    free(ppp);
     4421    return (hwndReturn);
     4422}
     4423
     4424/*
     4425 *@@ winhCreateExtStdWindow:
     4426 *      creates an extended frame window.
     4427 *
     4428 *      pData must point to an EXTFRAMECDATA structure
     4429 *      which contains a copy of the parameters to be
     4430 *      passed to winhCreateStdWindow. In addition,
     4431 *      this contains the flExtFlags field, which allows
     4432 *      you to automatically create a status bar for
     4433 *      the window.
     4434 *
     4435 *      Note that we subclass the frame here and require
     4436 *      QWL_USER for that. The frame's QWL_USER points
     4437 *      to an EXTFRAMEDATA structure whose pUser parameter
     4438 *      you may use for additional data, if you want to
     4439 *      do further subclassing.
     4440 *
     4441 *@@added V0.9.16 (2001-09-29) [umoeller]
     4442 */
     4443
     4444HWND winhCreateExtStdWindow(PEXTFRAMECDATA pData,        // in: extended frame data
     4445                            PHWND phwndClient)          // out: created client wnd
     4446{
     4447    HWND hwndFrame;
     4448
     4449    if (hwndFrame = winhCreateStdWindow(HWND_DESKTOP,
     4450                                        pData->pswpFrame,
     4451                                        pData->flFrameCreateFlags,
     4452                                        pData->ulFrameStyle,
     4453                                        pData->pcszFrameTitle,
     4454                                        pData->ulResourcesID,
     4455                                        pData->pcszClassClient,
     4456                                        pData->flStyleClient,
     4457                                        pData->ulID,
     4458                                        pData->pClientCtlData,
     4459                                        phwndClient))
     4460    {
     4461        if (pData->flExtFlags & XFCF_STATUSBAR)
     4462        {
     4463            // create status bar as child of the frame
     4464            HWND hwndStatusBar = winhCreateStatusBar(hwndFrame,
     4465                                                     hwndFrame,
     4466                                                     NULL,
     4467                                                     "9.WarpSans",
     4468                                                     CLR_BLACK);
     4469
     4470            // subclass frame for supporting status bar and msgs
     4471            PEXTFRAMEDATA pFrameData;
     4472            if (pFrameData = NEW(EXTFRAMEDATA))
     4473            {
     4474                ZERO(pFrameData),
     4475                memcpy(&pFrameData->CData, pData, sizeof(pFrameData->CData));
     4476                if (pFrameData->pfnwpOrig = WinSubclassWindow(hwndFrame,
     4477                                                              fnwpSubclExtFrame))
     4478                {
     4479                    WinSetWindowPtr(hwndFrame, QWL_USER, pFrameData);
     4480                }
     4481                else
     4482                    free(pFrameData);
     4483            }
     4484        }
     4485    }
     4486
     4487    return (hwndFrame);
     4488}
     4489
     4490/*
    42774491 *@@category: Helpers\PM helpers\Workplace Shell\WPS class list
    42784492 */
Note: See TracChangeset for help on using the changeset viewer.