📄 untmsghdl.~pas
字号:
{******************************************************************************
* Uint untMsgHdl
* This module is to define the Messages on Clock Application should
* Deal with
* CopyRight (C) By GanHuaXin 2001
* All Right Reserved
* Email : huiyugan@263.net
* Date:
* New Develop : 2001-1-9
* Modify : 2001-1-9
******************************************************************************}
unit untMsgHdl;
interface
uses
Windows,
Messages,
untConst,
untTool,
untHint,
Sysutils,
ShellAPI;
function ParentMainProc(
hWnd:LongWord;
Message:LongWord;
wParam:WPARAM;
lParam:LPARAM
):BOOL;stdcall;
function MainProc(hWnd:LongWord;
Message : LongWord;
wParam : WPARAM;
lParam : LPARAM):BOOL;stdcall;
implementation
//
// some function forward announce
//
function DlgAboutProc(hDlg: THandle;
Msg : LongWord;
wParam : WPARAM;
lParam : LPARAM):BOOL;stdcall;forward;
function DlgOptionProc(hDlg : THandle;
Msg : LongWord;
wParam : WPARAM;
lParam : LPARAM):BOOL;stdcall;forward;
function DlgClockSetProc(hDlg : THandle;
Msg : LongWord;
wParam : WPARAM;
lParam : LPARAM):BOOL;stdcall;forward;
function WMParentGetMinMaxInfo(
hWnd : THandle;
Msg : LongWord;
wParam : WPARAM;
lParam : LPARAM):BOOL;stdcall;
var
info : ^MINMAXINFO;
begin
result := BOOL(0);
info := Pointer(lParam);
info^.ptMaxSize.x := GetSystemMetrics(SM_CXFULLSCREEN);
info^.ptMaxSize.y := GetSystemMetrics(SM_CYFULLSCREEN);
info^.ptMinTrackSize.x := 0;
info^.ptMinTrackSize.y := 0;
info^.ptMaxTrackSize.x := GetSystemMetrics(SM_CXFULLSCREEN);
info^.ptMaxTrackSize.y := GetSystemMetrics(SM_CYFULLSCREEN);
end;
function ParentMainProc(
hWnd:LongWord;
Message:LongWord;
wParam:WPARAM;
lParam:LPARAM
):BOOL;stdcall;
begin
case Message of
WM_CLOSE :
begin
PostQuitMessage(0);
result := BOOL(0);
end;
WM_GETMINMAXINFO:
result := WMParentGetMinMaxInfo(hWnd,Message,wParam,lParam);
WM_SYSCOMMAND:
begin
case wParam of
SC_CLOSE:
begin
if (MessageBox(hWnd,'Would you like to quit?','Hello :-)',
MB_YESNO or MB_ICONWARNING) = IDYES) then
begin
SendMessage(ClockWnd,WM_CLOSE,0,0);
end;
end;
else
SendMessage(ClockWnd,WM_COMMAND,wParam,0);
end;
end;
else
result := BOOL(DefWindowProc(hWnd,Message,wParam,lParam));
end;
end;
//
//*** The following functions worked for the Main Window of Application ***
//
{******************************************************************************
* Function RButtonUpProc(hWnd,Msg,wParam,lParam);
* Purpose:
* To Deal with message when user right click mouse on window
* Date : 2001-1-9
******************************************************************************}
function WMRButtonUpProc(
hWnd :LongWord;
Msg :LongWord;
wParam :WPARAM;
lParam :LPARAM
):BOOL;stdcall;
const
CHECK_BOOL : Array[false..true] of UINT =
(MF_UNCHECKED, MF_CHECKED);
var
pMenu:HMENU;
subMenu:HMENU;
MousePos:TPoint;
bTrans,bOnTop:Boolean;
iClkStyle:integer;
clksetBmp : HBITMAP;
begin
pMenu := LoadMenu(hInstance,'MENU_POP');
if (pMenu<>0) then begin
subMenu := GetSubMenu(pMenu,0);
if (subMenu<>0) then begin
//
// to set the customer drawn of menu bar
//
{
CheckMenuItem(subMenu,IDM_CLOCKSET, MF_BYCOMMAND or MF_CHECKED);
clkSetBmp := GetCheckBitmaps(MF_CHECKED,0);
SetMenuItemBitmaps(subMenu,IDM_CLOCKSET, MF_BYCOMMAND,clkSetBmp,clkSetBmp);
}
//SetMenuOwnerDraw(subMenu,IDM_HINTSET);
SetMenuOwnerDraw(subMenu,IDM_CLOCKSET);
// set check and radio
GetRegAllOnTop(bOnTop);
GetRegTransparent(bTrans);
CheckMenuItem(subMenu,IDM_ALLONTOP,CHECK_BOOL[bOnTop]);
CheckMenuItem(subMenu,IDM_TRANSPARENT,CHECK_BOOL[bTrans]);
CheckMenuItem(subMenu,IDM_STARTWITHWIN,CHECK_BOOL[GetAppAtStart]);
GetRegClockStyle(iClkStyle);
CheckMenuRadioItem(GetSubMenu(subMenu,8),IDM_CIRCLK,IDM_DIGCLK,
iClkStyle,MF_BYCOMMAND);
GetCursorPos(MousePos);
TrackPopupMenu(subMenu,
TPM_RIGHTALIGN,
MousePos.x,
MousePos.y,
0,hWnd,nil);
//DeleteObject(hintsetBmp);
//DeleteObject(clksetBmp);
end;
DestroyMenu(pMenu);
end;
result := BOOL(true);
end;
function WMMeasureItemProc(hWnd : THandle;
Msg :LongWord;
wParam :WPARAM;
lParam :LPARAM):BOOL;stdcall;
var
item : ^MEASUREITEMSTRUCT;
begin
result := TRUE;
item := Pointer(lParam);
case item^.CtlType of
ODT_MENU :
begin
//item^.itemHeight := 46;
item^.itemHeight := GetSystemMetrics(SM_CYMENU);
//item^.itemWidth := 200;
end;
end;
end;
function WMDrawItemProc(hWnd : THandle;
Msg :LongWord;
wParam :WPARAM;
lParam :LPARAM):BOOL;stdcall;
var
item : ^DRAWITEMSTRUCT;
begin
result := TRUE;
item := Pointer(lParam);
case item^.CtlType of
ODT_MENU :
begin
DrawBmpMenu(item^);
end;
end;
end;
{******************************************************************************
* Function TrayIconNotifyProc(hWnd,Msg,wParam,lParam);
* Purpose:
* To dealwith the message when user do something about TrayIcon
* Date : 2001-1-9
******************************************************************************}
function TrayIconNotifyProc(hWnd :THandle;
Msg :LongWord;
wParam :WPARAM;
lParam :LPARAM):BOOL;stdcall;
var
mousePos : TPoint;
begin
result := BOOL(false);
case wParam of
ID_TRAYICON:
case lParam of
WM_LBUTTONUP:
begin
MessageBox(hWnd,'Mouse Left Button Up','GanClock',MB_OK);
result := BOOL(true);
end;
//ShowWindow(hWnd,Sw_SHOW);
WM_RBUTTONUP:
begin
SetForegroundWindow(hWnd);
result := WMRButtonUpProc(hWnd,Msg,wParam,lParam);
end;
end;
end;
end;
{******************************************************************************
* Function CommandProc(hWnd,Msg,wParam,lParam);
* Purpose:
* To Deal with the COMMAND of Application Such as button,menu,Accelerator
* Date : 2001-1-9
******************************************************************************}
function WMCommandProc(hWnd : THandle;
Msg : LongWord;
wParam : WPARAM;
lParam : LPARAM):BOOL;stdcall;
var
bMenu : boolean;
iClkStyle : integer;
begin
if (lParam = 0) then begin // not from a control
if (HI(wParam)=0) then begin // form menu
case LO(wParam) of
IDM_QUIT :
SendMessage(hWnd,WM_SYSCOMMAND,SC_CLOSE,0);
IDM_ABOUT:
begin
//MessageBox(GetFocus(),'Click About Menu','Hello :-)',MB_OK);
DialogBox(hInstance,'DIALOG_ABOUT',hWnd,@DlgAboutProc);
end;
IDM_OPTION:
//MessageBox(GetFocus(),'Click Option Menu','Hello :-)',MB_OK);
begin
DialogBox(hInstance,'DIALOG_OPTION',hWnd,@DlgOptionProc);
end;
IDM_ALLONTOP:
begin
GetRegAllOnTop(bMenu);
bMenu := not bMenu;
SetWindowAllOnTop(hWnd,bMenu);
SetRegAllOnTop(bMenu);
end;
IDM_TRANSPARENT:
begin
GetRegTransparent(bMenu);
bMenu := not bMenu;
SetWindowTransparent(hWnd,bMenu);
SetRegTransparent(bMenu);
end;
IDM_STARTWITHWIN:
begin
SetAppAtStart(not GetAppAtStart());
end;
IDM_CIRCLK,
IDM_DIGCLK:
begin
SetRegClockStyle(LO(wParam));
end;
IDM_CLOCKSET:
begin
GetRegClockStyle(iClkStyle);
if iClkStyle = IDM_CIRCLK then
DialogBox(hInstance,'DIALOG_CLOCKCIRSET',hWnd,@DlgClockSetProc)
else
DialogBox(hInstance,'DIALOG_CLOCKDIGSET',hWnd,@DlgClockSetProc);
end;
IDM_HINTSET:
begin
end;
end;
end
else begin // form accelerator
end;
end;
result := BOOL(true);
end;
function WMEraseBkgndProc(hWnd : THandle;
Msg : LongWord;
wParam : WPARAM;
lParam : LPARAM):BOOL;stdcall;
var
dc , tmpDC: HDC;
p : TPoint;
pStru:PAINTSTRUCT;
pen,oldPen : HPEN;
bmp , oldBmp: HBITMAP;
bmpSize : BITMAP;
brStruct : LOGBRUSH;
brRgn : HBRUSH;
begin
dc := GetDC(hWnd);
// draw the clock frame
tmpDc := CreateCompatibleDC(DC);
bmp := LoadBitmap(hInstance,'BITMAP_CLOCK');
Oldbmp := SelectObject(tmpDC,bmp);
BitBlt(DC,0,0,2*WIN_HALF_WIDTH,2*WIN_HALF_WIDTH,tmpDC,0,0,SRCCOPY);
SelectObject(tmpDC,oldbmp);
DeleteDC(tmpDC);
DeleteObject(bmp);
// draw center BMP
tmpDc := CreateCompatibleDC(DC);
bmp := LoadBitmap(hInstance,'BITMAP_CLOCKCENTER');
Oldbmp := SelectObject(tmpDC,bmp);
GetObject(bmp,SizeOf(bmpSize),@bmpSize);
BitBlt(DC,WIN_HALF_WIDTH - bmpSize.bmWidth div 2,
WIN_HALF_WIDTH - bmpSize.bmHeight div 2,
bmpSize.bmWidth,
bmpSize.bmHeight,tmpDC,0,0,SRCCOPY);
SelectObject(tmpDC,oldbmp);
DeleteDC(tmpDC);
DeleteObject(bmp);
// draw hour hand
brStruct.lbStyle := BS_SOLID;
brStruct.lbColor := RGB(0,0,255);
brStruct.lbHatch := 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -