static.c

来自「MinGUI 可视化程序代码」· C语言 代码 · 共 82 行

C
82
字号
/******************************************************************************
*
* Copyright  2006 National ASIC Center, All right Reserved
*
* FILE NAME:      Static.c
* PROGRAMMER:     ming.c
* Date of Creation:   2006/08/8
*
* DESCRIPTION:
*
* NOTE:
*
* FUNCTIONS LIST:
* -----------------------------------------------------------------------------
*
* -----------------------------------------------------------------------------
* 
* MODIFICATION HISTORY
*     LastModify  2006/10/30
******************************************************************************/
#include "mingui.h"
//---------------------------------------------------------------------------
static HRESULT CALLBACK DefStaticProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{ switch(message)
  { case WM_PAINT:
         { HDC dc = BeginPaint(hWnd);
           char *LabelCaption;
		   int clientwidth=crWidth(hWnd);
		   int clientheight=crHeight(hWnd);

           if(WNDPTR(hWnd)->Logo)
           { int x,y;
             if( WNDPTR(hWnd)->Logo->Width < clientwidth )
             { x  =  (clientwidth - WNDPTR(hWnd)->Logo->Width)>>1 ;
             } else x=0;
             
             if( WNDPTR(hWnd)->Logo->Height < clientheight )
             { y = (clientheight - WNDPTR(hWnd)->Logo->Height)>>1 ;
             } else y=0;
             DrawBitmap(dc,x,y,WNDPTR(hWnd)->Logo);
           }

           LabelCaption=GetWindowText(hWnd);
           if(LabelCaption && *LabelCaption)
           { DrawText(dc,0,0,clientwidth,clientheight,LabelCaption,alCenter|alMiddle);
           }
           EndPaint(hWnd);
         } 
         return 0;
    case WM_SETTEXT:
         if(SaveWindowText(hWnd,(char *)lParam))
         { Invalidate(hWnd);
		 }
         return 0;
    case WM_SETLOGO:
           WNDPTR(hWnd)->Logo=(TBitmap *)lParam;
           Invalidate(hWnd);
         return 0;
    case WM_ENABLE:
           Invalidate(hWnd);
         return 0;
 }
 return DefWindowProc(hWnd,message,wParam,lParam);
}

//---------------------------------------------------------------------------
void CM_RegisterStatic(void)
{  TWNDCLASS wc;
   memset(&wc,0,sizeof(wc));
   wc.clForeground=CL_BTNTEXT;
   wc.clBackground=CL_BTNFACE;   
   wc.lpfnWndProc=DefStaticProc;
   wc.lpszClassName="static";
   RegisterClass(&wc);
}
/*---------------------------------------------------------------------------
END --- Thank you!                                                  ming.c
---------------------------------------------------------------------------*/



⌨️ 快捷键说明

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