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

📄 untmsghdl.pas

📁 DELPHI下隐藏进程的方法,并附有源代码,学习很好.
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  brRgn := CreateBrushIndirect(brStruct);
  FillRgn(dc,RgnHour,brRgn);
  DeleteObject(brRgn);
  // draw minute hand
  brStruct.lbColor := RGB(0,255,124);
  brRgn := CreateBrushIndirect(brStruct);
  FillRgn(dc,RgnMinute,brRgn);
  DeleteObject(brRgn);
  // draw second hand
  brStruct.lbColor := RGB(255,0,0);
  brRgn := CreateBrushIndirect(brStruct);
  FillRgn(dc,RgnSecond,brRgn);
  DeleteObject(brRgn);

  {
  Pen := CreatePen(PS_SOLID,2,RGB(0,0,255));
  if BOOL(Pen) then
  begin
    oldPen := SelectObject(dc,pen);
  end;
  // draw a circle
  Arc(dc,1,1,2*WIN_HALF_WIDTH-2,2*WIN_HALF_WIDTH-2,
          1,1,1,1);
  // to create a new pen
  DeleteObject(Pen);
  Pen := CreatePen(PS_SOLID,2,RGB(0,255,0));
  SelectObject(dc,Pen);
  // draw two lines
  MoveToEx(dc,0,0,@p);
  LineTo(dc,2*WIN_HALF_WIDTH,2*WIN_HALF_WIDTH);
  MoveToEx(dc,0,2*WIN_HALF_WIDTH,@p);
  LineTo(dc,2*WIN_HALF_WIDTH,0);

  // reback some variable
  SelectObject(dc,oldPen);
  DeleteObject(pen);
  }
  ReleaseDC(hWnd,dc);
  result := BOOL(1);
end;

{******************************************************************************
*   Function WMPaintProc(hWnd,Msg,wParam,lParam);
*   Purpose:
*       To Deal with the WM_PAINT Message
*   Date    :   2001-1-9
******************************************************************************}
function WMPaintProc(hWnd : THandle;
                  Msg     : LongWord;
                  wParam  : WPARAM;
                  lParam  : LPARAM):BOOL;stdcall;
var
  dc , tmpDC: HDC;
  p   : TPoint;
  pStru:PAINTSTRUCT;
  pen,oldPen : HPEN;
  bmp , oldBmp: HBITMAP;
begin
  // initial about the Device

  BeginPaint(hWnd,pStru);
  WMEraseBkgndProc(hWnd,Msg,wParam,lParam);
  (*
  dc := GetDC(hWnd);
  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);
  *)
  {
  Pen := CreatePen(PS_SOLID,2,RGB(0,0,255));
  if BOOL(Pen) then
  begin
    oldPen := SelectObject(dc,pen);
  end;
  // draw a circle
  Arc(dc,1,1,2*WIN_HALF_WIDTH-2,2*WIN_HALF_WIDTH-2,
          1,1,1,1);
  // to create a new pen
  DeleteObject(Pen);
  Pen := CreatePen(PS_SOLID,2,RGB(0,255,0));
  SelectObject(dc,Pen);
  // draw two lines
  MoveToEx(dc,0,0,@p);
  LineTo(dc,2*WIN_HALF_WIDTH,2*WIN_HALF_WIDTH);
  MoveToEx(dc,0,2*WIN_HALF_WIDTH,@p);
  LineTo(dc,2*WIN_HALF_WIDTH,0);

  // reback some variable
  SelectObject(dc,oldPen);
  DeleteObject(pen);
  }
  (*
  ReleaseDC(hWnd,dc);
  *)
  result := true;
  EndPaint(hWnd,pStru);

  //result := BOOL(DefWindowProc(hWnd,Msg,wParam,lParam));
end;

{******************************************************************************
*   Function WMSysCommandProc(hWnd,Msg,wParam,lParam);
*   Purpose:
*       To shield the WM_SYSCOMMAND of SC_MINIMIZE and SC_MAXIMIZE
*   Date  :   2001-1-9
******************************************************************************}
function WMSysCommandProc(hWnd:THandle;
                  Msg     : LongWord;
                  wParam  : WPARAM;
                  lParam  : LPARAM):BOOL;stdcall;
begin
  //result := false;
  case wParam of
    SC_MINIMIZE,
    SC_MAXIMIZE:
      begin
        MessageBox(GetFocus,'heel','hel',MB_OK);
        result := true;
      end;
    SC_CLOSE:
      begin
      (*
        if (MessageBox(GetFocus(),
            'Would you like to quit?',
            'Hello :-)',
            MB_YESNO or MB_ICONWARNING) = IDYES) then
        begin
          SendMessage(hWnd,WM_CLOSE,0,0);
        end;
      *)
      end;
    else
      result := BOOL(DefWindowProc(hWnd,Msg,wParam,lParam));
  end;
end;


function WMMyPosChange(
                  hWnd    : THandle;
                  Msg     : LongWord;
                  wParam  : WPARAM;
                  lParam  : LPARAM):BOOL;stdcall;
var
  Pos : TMyWindowPos;
  dwStyle : Integer;
begin
  GetPlacePos(Pos);
  dwStyle := GetWindowLong(hWnd,GWL_STYLE);
  MoveWindow(hWnd,Pos.Left,Pos.Top,Pos.Width,Pos.Width,True);
  SetWindowLong(hWnd,GWL_STYLE,dwStyle);
  //InitWindow(hWnd);
  result := true;

end;

function WMCloseProc(
                  hWnd    : THandle;
                  Msg     : LongWord;
                  wParam  : WPARAM;
                  lParam  : LPARAM):BOOL;stdcall;
var
  bOpt : boolean;
begin
  SetRegWindowPos(hWnd);
  CloseClockWalk(hWnd);
  //GetRegShowTray(bOpt);
  //if bOpt then
  DelOnTray(hWnd);
  if BOOL(RgnFrame) then DeleteObject(RgnFrame);
  if BOOL(RgnCenter) then DeleteObject(RgnCenter);
  if BOOL(RgnHour) then DeleteObject(RgnHour);
  if BOOL(RgnMinute) then DeleteObject(RgnMinute);
  if BOOL(RgnSecond) then DeleteObject(RgnSecond);
  PostQuitMessage(0);
  result := BOOL(0);
end;

function WMGetMinMaxInfo(
                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 := 6;
  info^.ptMinTrackSize.y := 6;
  info^.ptMaxTrackSize.x := GetSystemMetrics(SM_CXFULLSCREEN);
  info^.ptMaxTrackSize.y := GetSystemMetrics(SM_CYFULLSCREEN);
end;

function WMCreateProc(hWnd : THandle;
                  Msg     : LongWord;
                  wParam  : WPARAM;
                  lParam  : LPARAM):BOOL;stdcall;
var
  bmp : HBITMAP;
  bmpSize : BITMAP;
  hRgn {, RgnCenter}: THandle;
  time : SYSTEMTIME;
begin
  //
  // to initial the region if window is create from a bitmap !!
  //
  bmp := LoadBitmap(hInstance,'BITMAP_CLOCK');
  RgnFrame := CreateRgnFromBmp(bmp);
  DeleteObject(bmp);

  bmp := LoadBitmap(hInstance,'BITMAP_CLOCKCENTER');
  RgnCenter := CreateRgnFromBmp(bmp);
  GetObject(bmp,SizeOf(bmpSize),@bmpSize);
  OffsetRgn(RgnCenter,WIN_HALF_WIDTH - bmpSize.bmWidth div 2,
    WIN_HALF_WIDTH - bmpSize.bmHeight div 2);
  DeleteObject(bmp);
  // combone two regins as RgnFrame
  CombineRgn(RgnFrame,RgnFrame,RgnCenter,RGN_OR);
  //DeleteObject(RgnCenter);

  GetLocalTime(time);
  RgnHour := CreateHourRgn(time.wHour,time.wMinute);
  RgnMinute := CreateMinuteRgn(time.wMinute);
  RgnSecond := CreateSecondRgn(time.wSecond);
  LastMinute := time.wMinute;
  LastSecond := time.wSecond;

  hRgn := CreateRectRgn(0,0,0,0);
  CombineRgn(hRgn,RgnFrame,hRgn,RGN_OR);
  CombineRgn(hRgn,RgnHour,hRgn,RGN_OR);
  CombineRgn(hRgn,RgnMinute,hRgn,RGN_OR);
  CombineRgn(hRgn,RgnSecond,hRgn,RGN_OR);
  SetWindowRgn(hWnd,hRgn,TRUE);
  DeleteObject(hRgn);

  result := BOOL(0);
end;

{******************************************************************************
*   Function WMTimeChangeProc
*   Description:
*       This function will called when system time is changed
******************************************************************************}
function WMTimeChangeProc(hWnd : THandle;
                  Msg     : LongWord;
                  wParam  : WPARAM;
                  lParam  : LPARAM):BOOL;stdcall;
var
  time : SYSTEMTIME;
  hRgn  : THandle;
begin
  CloseClockWalk(hWnd);
  result := BOOL(0);
  //MessageBox(Getfocus,'System time changed','HuiyuClock',MB_OK);
  if BOOL(RgnHour) then DeleteObject(RgnHour);
  if BOOL(RgnMinute) then DeleteObject(RgnMinute);
  if BOOL(RgnSecond) then DeleteObject(RgnSecond);
  GetLocalTime(time);
  RgnHour := CreateHourRgn(time.wHour,time.wMinute);
  RgnMinute := CreateMinuteRgn(time.wMinute);
  RgnSecond := CreateSecondRgn(time.wSecond);
  LastMinute := time.wMinute;
  LastSecond := time.wSecond;
  hRgn := CreateRectRgn(0,0,0,0);
  CombineRgn(hRgn,RgnFrame,hRgn,RGN_OR);
  CombineRgn(hRgn,RgnHour,hRgn,RGN_OR);
  CombineRgn(hRgn,RgnMinute,hRgn,RGN_OR);
  CombineRgn(hRgn,RgnSecond,hRgn,RGN_OR);
  SetWindowRgn(hWnd,hRgn,TRUE);
  InvalidateRect(hWnd,nil,TRUE);
  DeleteObject(hRgn);
  SetClockWalk(hWnd);
end;

{******************************************************************************
*   Function MainProc(hWnd,Message,wParam,lParam)
*   Purpose:
*       The Applicaiton Message Deal with function
*   Parmeters:
*       hWnd        :   The recevied message window handle
*       Message     :   The Message Code
*       wParam      :   The WPARAM
*       lParam      :   The LPARAM
******************************************************************************}
function MainProc(
    hWnd:LongWord;
    Message:LongWord;
    wParam:WPARAM;
    lParam:LPARAM
    ):BOOL;stdcall;
begin
  result := false;
  case Message of
    WM_CREATE:
      result := WMCreateProc(hWnd,Message,wParam,lParam);
    WM_CLOSE :
      begin
        SendMessage(ParentWnd,WM_CLOSE,0,0);
        result := WMCloseProc(hWnd,Message,wParam,lParam);
      end;
    WM_DESTROY      :
      begin
        DestroyWindow(hWnd);
      end;
    WM_LBUTTONDOWN    :
      begin
          SendMessage(hWnd, WM_NCLBUTTONDOWN,HTCAPTION,0);
      end;
    WM_RBUTTONDOWN  : //MessageBox(GetFocus(),'Hahaha','R button down',MB_OK);
        result := WMRButtonUpProc(hWnd,Message,wParam,lParam);
        //MoveWindow(hWnd,20,20,140,140,TRUE);
    WM_TRAYICONNOTIFY:
        result := TrayIconNotifyProc(hWnd,Message,wParam,lParam);
    WM_COMMAND:
        result := WMCommandProc(hWnd,Message,wParam,lParam);
    WM_PAINT:
        result := WMPaintProc(hWnd,Message,wParam,lParam);
    WM_SYSCOMMAND:
        result := WMSysCommandProc(hWnd,Message,wParam,lParam);
    WM_MYPOSCHANGE:
        result := WMMYPOSCHANGE(hWnd,Message,wParam,lParam);
    WM_MEASUREITEM:
        result := WMMeasureItemProc(hWnd,Message,wParam,lParam);
    WM_DRAWITEM:
        result := WMDrawItemProc(hWnd,Message,wParam,lParam);
    WM_GETMINMAXINFO:
        result := WMGetMinMaxInfo(hWnd,Message,wParam,lParam);
    WM_ERASEBKGND:
        result := WMEraseBkgndProc(hWnd,Message,wParam,lParam);
    WM_TIMECHANGE:
        result := WMTimeChangeProc(hWnd,Message,wParam,lParam);
    WM_THREADEXIT:
        result := DelOnTray(hWnd);
    else
      begin
        result := BOOL(DefWindowProc(hWnd,Message,wParam,lParam));
        exit;
      end;
  end;
end;

//
//***  The Following function is Worked for About Doalog box  ***
//

function DlgAboutLblEmailProc(
              hWnd    : THandle;
              Msg     : LongWord;
              wParam  : WPARAM;
              lParam  : LPARAM):BOOL;stdcall;
begin
end;

⌨️ 快捷键说明

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