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

📄 defproc.c

📁 深圳市微逻辑电子有限公司 巨果&#8226 Kingmos&reg 系统核心
💻 C
📖 第 1 页 / 共 5 页
字号:
{
	LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
	LPSTR lpcsz = NULL;//
	_SCROLLDATA * lpvs = NULL;
	_SCROLLDATA * lphs = NULL;
	//DWORD dwStyle = SetWindowLong( hWnd, GWL_STYLE );
	//LPCSTR lpWinText = SetWindowLong( hWnd, GWL_TEXT_PTR, 0 );
	if( lpcs->lpszName )
	{		
		lpcsz = (LPSTR)NewStr(lpcs->lpszName);
		if( lpcsz )
			SetWindowLong( hWnd, GWL_TEXT_PTR, (LONG)lpcsz );
		else
			goto _error;
	}
	if( lpcs->style & WS_VSCROLL )
	{
		if( (lpvs = _GetWindowScrollBar( hWnd, SB_VERT )) == NULL )
		{
			goto _error;
		}
	}
	if( lpcs->style & WS_HSCROLL )
	{
		if( (lphs = _GetWindowScrollBar( hWnd, SB_HORZ )) == NULL )
			goto _error;
	}
	return TRUE;

_error:
	if( lpcsz )
		FreeStr( lpcsz );
	if( lpvs )
		_ReleaseWindowScrollBar( hWnd, SB_VERT );
	if( lphs )
		_ReleaseWindowScrollBar( hWnd, SB_HORZ );
	return FALSE;    
}


/**************************************************
声明:static LRESULT DoNcHitTest( HWND hWnd, WPARAM wParam, LPARAM lParam )
参数:
	IN hWnd - 窗口句柄
    wParam - 第一个参数
    lParam - 第二个参数

返回值:
	返回当前鼠标在窗口的哪个区域,为以下值:
		HTCLIENT - 客户区
		HTTOPLEFT - 左顶边框
		HTBOTTOMLEFT - 左底边框
		HTLEFT - 左边框
		HTTOPRIGHT - 右顶边框
		HTTOP - 顶边框
		HTBOTTOMRIGHT - 右底边框
		HTBOTTOM - 底边框
		HTRIGHT - 右边框
		HTERROR - 错误(没有任何区域)
		HTBORDER - 边框(窗口只有边框,没有其他风格)
		HTVSCROLL - 垂直滚动条
		HTHSCROLL - 水平滚动条
		HTGROWBOX - 右下角的缩放框
		HTCLOSEBOX - 标题栏上的关闭方框
		HTOKBOX - 标题栏上的确认方框
		HTHELPBOX - 标题栏上的帮助方框
		HTSYSMENU - 标题栏上的系统方框
		HTCAPTION - 标题栏
		HTCLIENTEDGE - 客户区边框

功能描述:
	处理WM_NCHITTEST消息

引用: 
************************************************/

static LRESULT DoNcHitTest( HWND hWnd, WPARAM wParam, LPARAM lParam )
{
    POINT pt, ptClient;
    RECT rect, rectInter;
    RECT rClient;
    DWORD dwMainStyle, dwExStyle;

    int cx, cy;

    pt.x = LOWORD(lParam); // 屏幕x坐标
    pt.y = HIWORD(lParam); // 屏幕y坐标
	ptClient = pt;

    GetClientRect( hWnd, &rClient );
    ScreenToClient( hWnd, &ptClient ); //转化为客户坐标
    if( PtInRect( &rClient, ptClient ) )	//在客户区吗?
        return HTCLIENT;

    GetWindowRect( hWnd, &rect ); //得到该窗口的屏幕矩形

    dwMainStyle = GetWindowLong( hWnd, GWL_MAINSTYLE );
    dwExStyle = GetWindowLong( hWnd, GWL_EXSTYLE );

    rectInter = rect;
    if( GetInterFrame( &rectInter, dwMainStyle ) )	//得到除边框外的内矩形
    {
        if( !PtInRect( &rectInter, pt ) )	//在内矩形?
        {  //不在,必然在边框上。 pt is within window but not within rectInter
            if( (dwMainStyle & WS_THICKFRAME) == WS_THICKFRAME )	//粗边框吗?
            {	// 是,以下代码测试在那一个边框上。test which border or corner
            	//cx, cy为上部可缩放边框的高度和宽度
                cy = GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYFRAME );                
                cx = GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CXFRAME );
                if( IN_RANGE( pt.x, rect.left, rectInter.left ) )	//左边框?
                {  // 是,x 在左边框 left border
                    if( IN_RANGE( pt.y, rect.top, rect.top + cy ) )
                        return HTTOPLEFT;	//在上左边框的可缩放边框
                    if( IN_RANGE( pt.y, rect.bottom - cy, rect.bottom ) )
                        return HTBOTTOMLEFT;	//在下左边框的可缩放边框
                    else
                        return HTLEFT;	//其他左边框
                }
                else if( IN_RANGE( pt.y, rect.top, rectInter.top ) )	//上边框?
                {  // 是,y 在上边框 top border
                    if( IN_RANGE( pt.x, rect.left, rect.left + cx ) )
                        return HTTOPLEFT;	//在上左边框的可缩放边框
                    if( IN_RANGE( pt.x, rect.right - cx, rect.right ) )
                        return HTTOPRIGHT;	//在上右边框的可缩放边框
                    else
                        return HTTOP;	//其它上边框
                }
                else if( IN_RANGE( pt.x, rectInter.right, rect.right ) )	//右边框
                {   // right border
                    if( IN_RANGE( pt.y, rect.top, rect.top + cy ) )
                        return HTTOPRIGHT;
                    if( IN_RANGE( pt.y, rect.bottom - cy, rect.bottom ) )
                        return HTBOTTOMRIGHT;
                    else
                        return HTRIGHT;
                }
                else if( IN_RANGE( pt.y, rectInter.bottom, rect.bottom ) )	//下边框
                {  // bottom border
                    if( IN_RANGE( pt.x, rect.left, rect.left + cx ) )
                        return HTBOTTOMLEFT;
                    if( IN_RANGE( pt.x, rect.right - cx, rect.right ) )
                        return HTBOTTOMRIGHT;
                    else
                        return HTBOTTOM;
                }
                else
                {
                    ASSERT( 0 ); // 错误!!,不应该发生。 error
                    return HTERROR;
                }
            }
            //非粗边框
            return HTBORDER;
        }
    }
	// 不在边框上。以下代码测试是否在其他区域。test in scroll bar ?
    if( dwMainStyle & (WS_HSCROLL | WS_VSCROLL) )
    {	//窗口有滚动条
        // save rect
    	if( dwMainStyle & WS_VSCROLL )
    	{
            rectInter = rect;
            // 得到垂直滚动条的矩形
            Scrl_GetBarRect( &rectInter, dwMainStyle, dwExStyle, SB_VERT );
            if( PtInRect( &rectInter, pt ) )
                return HTVSCROLL; // 在垂直滚动条上
    	}
    	if( dwMainStyle & WS_HSCROLL )
    	{
            rectInter = rect;
            // 得到水平滚动条的矩形
            Scrl_GetBarRect( &rectInter, dwMainStyle, dwExStyle, SB_HORZ );
            if( PtInRect( &rectInter, pt ) )
                return HTHSCROLL;	//在水平滚动条上
    	}
    	if( (dwMainStyle & (WS_HSCROLL | WS_VSCROLL)) == (WS_HSCROLL | WS_VSCROLL) )
    	{
            rectInter = rect;
            // 得到缩放框的的矩形            
            Scrl_GetBarRect( &rectInter, dwMainStyle, dwExStyle, SB_CORNER );
            if( PtInRect( &rectInter, pt ) )
                return HTGROWBOX;	//在缩放框上
    	}
    }

	// test in caption or icon or syscommand button
    if( (dwMainStyle & WS_CAPTION) == WS_CAPTION ||
		 ( dwExStyle & WS_EX_TITLE ) )
    {	//窗口有标题栏
        rectInter = rect;
        //得到标题栏的矩形
        GetCaptionRect( &rect, dwMainStyle );
        if( PtInRect( &rect, pt ) )
        {	//在标题栏里
            if( dwExStyle & WS_EX_CLOSEBOX )
            {	//标题栏上有关闭框
                GetCaptionCloseBoxRect( &rect, dwExStyle );
                if( PtInRect( &rect, pt ) )
                    return HTCLOSEBOX;
            }
            
            if( dwExStyle & WS_EX_OKBOX )
            {	//标题栏上有确认框
                rect = rectInter;
                GetCaptionOkBoxRect( &rect, dwExStyle );
                if( PtInRect( &rect, pt ) )
                    return HTOKBOX;
            }
            
            if( dwExStyle & WS_EX_HELPBOX )
            {	//标题栏上有帮助框
                rect = rectInter;
                GetCaptionHelpBoxRect( &rect, dwExStyle );
                if( PtInRect( &rect, pt ) )
                    return HTHELPBOX;
            }

			if( dwMainStyle & WS_SYSMENU )
			{	//标题栏上有系统框
				rect = rectInter;
				GetCaptionSysBoxRect( &rect, dwMainStyle );
				if( PtInRect( &rect, pt ) )
					return HTSYSMENU;
			}
			//在标题栏的文字框里
            return HTCAPTION;
        }
    }

    if( dwExStyle & WS_EX_CLIENTEDGE )
	{   //有客户边框,客户边框只有1点粗,这里将客户矩形扩大一点粗
		InflateRect( &rClient, 1, 1 );
		//客户边框里包含滚动条,因此,如果有滚动条,应相应中间客户边框的大小
        if( dwMainStyle & WS_HSCROLL )
			rClient.bottom += GetSystemMetrics( SM_CYHSCROLL );			
        if( dwMainStyle & WS_VSCROLL )
			rClient.right += GetSystemMetrics( SM_CXVSCROLL );
		if( PtInRect( &rClient, ptClient ) )
			return HTCLIENTEDGE;	//在客户边框上
	}

    ASSERT( 0 );	//不应该执行到这里
    return HTERROR;
}

// **************************************************
// 声明:static void DrawScrollBar( HWND hWnd, HDC hdc, DWORD dwMainStyle )
// 参数:
//	IN hWnd - 窗口句柄
//	IN hdc - DC句柄
//	IN dwMainStyle - 窗口风格
// 返回值:
//	无
// 功能描述:
//	绘制滚动条
// 引用: 
// ************************************************

static void DrawScrollBar( HWND hWnd, HDC hdc, DWORD dwMainStyle )
{
    if( dwMainStyle & WS_VSCROLL )
    {	// 画垂直滚动条
        Scrl_RedrawScrollBar( hWnd, hdc, SB_VERT );
    }
    if( dwMainStyle & WS_HSCROLL )
    {	// 画水平滚动条
        Scrl_RedrawScrollBar( hWnd, hdc, SB_HORZ );
    }
    if( (dwMainStyle & WS_HSCROLL) && (dwMainStyle & WS_VSCROLL) )
    {	//画右下角的缩放框
        Scrl_RedrawScrollBar( hWnd, hdc, SB_CORNER );
    }
}
/*   the version is show text mask of close and help and ok 
// **************************************************
// 声明:static void ShowCaption( HWND hWnd, HDC hdc, DWORD dwMainStyle, BOOL fActive )
// 参数:
//	IN hWnd - 窗口句柄
//	IN hdc - DC句柄
//	IN dwMainStyle - 窗口风格
//	IN fActive - 标题条是否是活动的
// 返回值:
//	无
// 功能描述:
//	画窗口上的整个标题条
// 引用: 
// ************************************************

static void ShowCaption( HWND hWnd, HDC hdc, DWORD dwMainStyle, BOOL fActive )
{
    extern void * _Win_GetTextAdr( HWND hWnd );
    RECT rect;
    DWORD dwExStyle;

    //char buf[32];

    if( (dwMainStyle & WS_CAPTION) == WS_CAPTION )
    {
        GetWindowRect( hWnd, &rect );
        OffsetRect( &rect, -rect.left, -rect.top );
        GetInterFrame( &rect, dwMainStyle );
        rect.bottom = rect.top + GetSystemMetrics( SM_CYCAPTION );
        DrawCaption( hWnd, hdc, &rect, fActive ? DC_ACTIVE|DC_TEXT|DC_ICON : DC_TEXT|DC_ICON );
        dwExStyle = GetWindowLong( hWnd, GWL_EXSTYLE );
        if( dwExStyle & (WS_EX_CLOSEBOX | WS_EX_OKBOX | WS_EX_HELPBOX) )
        {            
			extern const HFONT __hSymbol16x16;
			BYTE bSymbol;
			HFONT hFont = SelectObject( hdc, __hSymbol16x16 );

            SetTextColor(hdc, fActive ? CL_WHITE : CL_BLACK );
            SetBkMode(hdc, TRANSPARENT);
            if( dwExStyle & WS_EX_CLOSEBOX )
            {
				bSymbol = SYM_CLOSE;

                WinGdi_TextOut( hdc, rect.right - 16, rect.top, &bSymbol, 1 );
                rect.right -= 16;
            }
            if( dwExStyle & WS_EX_OKBOX )
            {
				bSymbol = SYM_OK;
                WinGdi_TextOut( hdc, rect.right - 16, rect.top, &bSymbol, 1 );
                rect.right -= 16;
            }
            if( dwExStyle & WS_EX_HELPBOX )
            {
				bSymbol = SYM_HELP;
                WinGdi_TextOut( hdc, rect.right - 16, rect.top, &bSymbol, 1 );
            }
			SelectObject( hdc, hFont );
            SetBkMode(hdc, OPAQUE);
        }
    }
}
*/

// **************************************************
// 声明:static void ShowCaption( HWND hWnd, HDC hdc, DWORD dwMainStyle, BOOL fActive )
// 参数:
//	IN hWnd - 窗口句柄
//	IN hdc - DC句柄
//	IN dwMainStyle - 窗口风格
//	IN fActive - 标题条是否是活动的
// 返回值:
//	无
// 功能描述:
//	画窗口上的整个标题条
// 引用: 
// ************************************************

static void ShowCaption( HWND hWnd, HDC hdc, DWORD dwMainStyle, BOOL fActive )
{
    RECT rtCaption, rt;
    //DWORD dwExStyle;
	//_LPWINDATA lpws = _GetHWNDPtr( hWnd );
	BITMAP bitmap;
	DWORD dwExStyle = GetWindowLong( hWnd, GWL_EXSTYLE );


    if( //lpws && 
		(  (dwMainStyle & WS_CAPTION) == WS_CAPTION || 
		   (dwExStyle & WS_EX_TITLE) 
		) 
	  )	//有标题栏吗?
    {	//有
        //int yIconHeight, xIconWidth;

		//rtCaption = lpws->rectWindow;
		GetWindowRect( hWnd, &rtCaption );
        OffsetRect( &rtCaption, -rtCaption.left, -rtCaption.top );
        //得到标题栏矩形
		GetCaptionRect( &rtCaption, dwMainStyle );
		//画标题栏背景
        DrawCaption( hWnd, hdc, &rtCaption, fActive ? DC_ACTIVE : 0 );

		//得到系统栏图标的大小
		//2004-07-08, modify
        //yIconHeight = GetSystemMetrics(SM_CYSMICON);
		//xIconWidth = GetSystemMetrics(SM_CXSMICON);
        //yIconHeight = GetSystemMetrics(SM_CYSIZE);
		//xIconWidth = GetSystemMetrics(SM_CXSIZE);
		//


		// 如果有系统栏,则画之。now , draw sysmenu icon if possible
        if( dwMainStyle & WS_SYSMENU )
        {
			HICON hIcon;
			ICONINFO iconInfo;

            hIcon = (HICON)GetWindowLong( hWnd, GWL_HICONSM );//lpws->hSmallIcon;//小图标
			if( hIcon == NULL )
			{	//如果没有用户提供的小图标,则用系统默认的
				if( fActive )
				{
					hIcon = GetStockObject( SYS_STOCK_LOGO );//hicoSysMenu;//系统活动图标
				}
				else
				{
					hIcon = GetStockObject( SYS_STOCK_LOGO_GRAY );//hicoGraySysMenu;//系统非活动图标
				}
			}
			GetIconInfo( hIcon, &iconInfo );
			GetObject( iconInfo.hbmColor, sizeof(bitmap), &bitmap );
			
		    rt = rtCaption;

⌨️ 快捷键说明

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