⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lsgrip.c

📁 CC386 is a general-purpose 32-bit C compiler. It is not an optimizing compiler but given that the co
💻 C
📖 第 1 页 / 共 2 页
字号:
/* 
Copyright 2001-2003 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.  

You may contact the author at:

mailto::camille@bluegrass.net

or by snail mail at:

David Lindauer
850 Washburn Ave Apt 99
Louisville, KY 40222
 **********************************************************************

LSGRIP.C is a container window, like LSCTRL.  However instead of containing
standard windows, it contains toolbars.  When they are docked they will
be inside LSGRIP controls, otherwise inside standard windows.

 **********************************************************************

 */
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include "lsctrl.h"

#define TITLEWIDTH 15
#define EDGEWIDTH 1
#define TITLETOP 4
#define BARLEFT 2
#define BARRIGHT 2
#define BARTOP 0
#define BUTTONCORNER 1
#define BUTTONWIDTH 12

extern HWND hwndClient;
static char *szGripWindClassName = "ladSoftGripWindow";
static char *szTBContainerClassName = "ladSoftTBContainerWindow";
static char *szBlankWindowClassName = "ladSoftBlankWindow";

static HCURSOR mcurs;

static void DrawBorder(HWND hwnd, HDC dc)
{
    RECT r;
    GetClientRect(hwnd, &r);
    r.right += GetSystemMetrics(SM_CXBORDER) *2;
    r.bottom += GetSystemMetrics(SM_CYBORDER) *2;
    DrawEdge(dc, &r, EDGE_RAISED, BF_RECT | BF_FLAT);
}

//-------------------------------------------------------------------------

static void DrawTitle(HDC dc, RECT *r, int vertical)
{
    HPEN pen1, pen2, pen3, oldpen;
    pen1 = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT));
    pen2 = CreatePen(PS_SOLID, 2, GetSysColor(COLOR_3DHILIGHT));
    pen3 = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
    if (vertical)
    {
        r->top = TITLETOP;
        r->left += EDGEWIDTH;
        r->right -= EDGEWIDTH;
        oldpen = SelectObject(dc, pen1);
        SelectObject(dc, pen1);
        MoveToEx(dc, r->left + BARLEFT, r->top + BARTOP, 0);
        LineTo(dc, r->right - BARRIGHT + 1, r->top + BARTOP);
        SelectObject(dc, pen2);
        MoveToEx(dc, r->left + BARLEFT - 1, r->top + BARTOP + 1, 0);
        LineTo(dc, r->right - BARRIGHT, r->top + BARTOP + 1);
        SelectObject(dc, pen3);
        MoveToEx(dc, r->left + BARLEFT, r->top + BARTOP + 3, 0);
        LineTo(dc, r->right - BARRIGHT + 1, r->top + BARTOP + 3);
        SelectObject(dc, pen2);
        MoveToEx(dc, r->left + BARLEFT - 1, r->top + BARTOP + 5, 0);
        LineTo(dc, r->right - BARRIGHT, r->top + BARTOP + 5);
        SelectObject(dc, pen3);
        MoveToEx(dc, r->left + BARLEFT, r->top + BARTOP + 7, 0);
        LineTo(dc, r->right - BARRIGHT + 1, r->top + BARTOP + 7);
    }
    else
    {
        r->left = TITLETOP;
        r->top += EDGEWIDTH;
        r->bottom -= EDGEWIDTH;
        oldpen = SelectObject(dc, pen1);
        MoveToEx(dc, r->left + BARTOP, r->top + BARRIGHT - 1, 0);
        LineTo(dc, r->left + BARTOP, r->bottom - BARLEFT);
        SelectObject(dc, pen2);
        MoveToEx(dc, r->left + BARTOP + 1, r->top + BARRIGHT, 0);
        LineTo(dc, r->left + BARTOP + 1, r->bottom - BARLEFT + 1);
        SelectObject(dc, pen3);
        MoveToEx(dc, r->left + BARTOP + 3, r->top + BARRIGHT - 1, 0);
        LineTo(dc, r->left + BARTOP + 3, r->bottom - BARLEFT);
        SelectObject(dc, pen2);
        MoveToEx(dc, r->left + BARTOP + 5, r->top + BARRIGHT, 0);
        LineTo(dc, r->left + BARTOP + 5, r->bottom - BARLEFT + 1);
        SelectObject(dc, pen3);
        MoveToEx(dc, r->left + BARTOP + 7, r->top + BARRIGHT - 1, 0);
        LineTo(dc, r->left + BARTOP + 7, r->bottom - BARLEFT);
    }
    SelectObject(dc, oldpen);
    DeleteObject(pen1);
    DeleteObject(pen2);
    DeleteObject(pen3);
}

//-------------------------------------------------------------------------

static LRESULT CALLBACK _export GripWindWndProc(HWND hwnd, UINT iMessage,
    WPARAM wParam, LPARAM lParam)
{
    RECT r,  *pr;
    PAINTSTRUCT ps;
    HDC dc;
    CCW_params *ptr;
    static int skip;
    static int dragging, oncursor, sizing;
    static HCURSOR oldCursor;
    POINT temppt;
    int temp;
    HBRUSH brush;
    int cx, cy;
    switch (iMessage)
    {
        case WM_SETTEXT:
            break;
        case WM_NOTIFY:
            break;
        case WM_COMMAND:
            ptr = (CCW_params*)GetWindowLong(hwnd, 0);
            break;
        case WM_NCPAINT:
            {
                HDC hdc;
                hdc = GetWindowDC(hwnd);
                DrawBorder(hwnd, hdc);
                ReleaseDC(hwnd, hdc);
            }
            return 0;
            break;
        case WM_LBUTTONDOWN:
            ptr = (CCW_params*)GetWindowLong(hwnd, 0);
            temppt.x = (long)(short)LOWORD(lParam);
            temppt.y = (long)(short)HIWORD(lParam);
            if ((ptr->vertical && temppt.y < 17) || (!ptr->vertical && temppt.x
                < 17))
            {
                dmgrStartMoveGrip(ptr, lParam);
                oldCursor = SetCursor(mcurs);
                SetCapture(hwnd);
                dragging = TRUE;
            }
            break;
        case WM_LBUTTONUP:
            ptr = (CCW_params*)GetWindowLong(hwnd, 0);
            if (dragging)
            {
                SetCursor(oldCursor);
                oldCursor = 0;
            }
            if (dragging)
                ReleaseCapture();
            dragging = FALSE;
            sizing = FALSE;
            dmgrEndMoveGrip(ptr);
            break;
        case WM_MOUSEMOVE:
            ptr = (CCW_params*)GetWindowLong(hwnd, 0);
            if (dragging)
            {
                dmgrMoveGrip(ptr, lParam);
            }
            break;
        case WM_PAINT:
            ptr = (CCW_params*)GetWindowLong(hwnd, 0);
            dc = BeginPaint(hwnd, &ps);
            GetClientRect(hwnd, &r);

            DrawTitle(dc, &r, ptr->vertical);
            EndPaint(hwnd, &ps);
            break;
        case WM_CREATE:
            ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof
                (CCW_params));
            SetWindowLong(hwnd, 0, (DWORD)ptr);
            *ptr = *(CCW_params*)(((LPCREATESTRUCT)lParam)->lpCreateParams);
            ptr->self = hwnd;
            ptr->type = LSGRIP;
            dmgrAddGrip(ptr);
            GetClientRect(hwnd, &r);
            return 0;
        case WM_DESTROY:
            ptr = (CCW_params*)GetWindowLong(hwnd, 0);
            HeapFree(GetProcessHeap(), 0, ptr);
            break;
        case WM_CLOSE:
            return 0;
        case LCF_SETVERTICAL:
            ptr = (CCW_params*)GetWindowLong(hwnd, 0);
            ptr->vertical = (int)lParam;
            InvalidateRect(hwnd, 0, 0);
            return 0;
        case WM_SIZE:
            ptr = (CCW_params*)GetWindowLong(hwnd, 0);
            cx = 0; // GetSystemMetrics(SM_CXFRAME) ;
            cy = 0; // GetSystemMetrics(SM_CYFRAME) ;
            if (ptr->vertical)
                MoveWindow(ptr->u.gp.child, cx, TITLEWIDTH + cy, LOWORD(lParam)
                    - cx, HIWORD(lParam) - TITLEWIDTH - cy, TRUE);
            else
                MoveWindow(ptr->u.gp.child, TITLEWIDTH + cx, cy, LOWORD(lParam)
                    - TITLEWIDTH - cx, HIWORD(lParam) - cy, TRUE);
            return 0;
    }
    return DefWindowProc(hwnd, iMessage, wParam, lParam);
}

//-------------------------------------------------------------------------

LRESULT CALLBACK _export TBContainerProc(HWND hwnd, UINT iMessage, WPARAM
    wParam, LPARAM lParam)
{
    CCW_params *ptr,  *ptr1;
    int rv;
    static int selected, sizingbottom;
    RECT r,  *pr;
    TC_ITEM tie;
    NMHDR *h;
    DRAWITEMSTRUCT *dr;
    HFONT font;
    HBITMAP hbmp;
    HDC hMemDC;
    HDWP deferstruct;
    HDC dc;
    PAINTSTRUCT ps;
    static int dragging, oncursor, sizing;
    static HCURSOR oldCursor;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -