ImageVerifierCode 换一换
格式:DOCX , 页数:12 ,大小:18.09KB ,
资源ID:26114735      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/26114735.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Transparent CLOCK.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Transparent CLOCK.docx

1、Transparent CLOCK/*- CLOCK.C - Analog Clock Program (c) Charles Petzold, 1998 -*/#define _WIN32_WINNT 0x0500#include #include #include resource.htypedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags); lpfnSetLayeredWindowAttributes SetLayeredWind

2、owAttributesW;#define ID_TIMER 1#define TWOPI (2 * 3.14159)LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;LRESULT CALLBACK SubClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);BOOL MakeWndTrans(HWND hWnd, int nAlpha);LRESULT CALLBACK HookCallWndProc(int nCode, WPARAM wParam, L

3、PARAM lParam);HINSTANCE hInst;TCHAR szAppName = TEXT (Clock) ;int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)/ static TCHAR szAppName = TEXT (Clock) ; HWND hwnd; MSG msg; WNDCLASS wndclass ; HMODULE hUser32; HRGN WndRGN; int iCapHeight; wndclass.style

4、= CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = NULL ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.lpszMe

5、nuName = NULL ; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass) MessageBox (NULL, TEXT (Program requires Windows NT!), szAppName, MB_ICONERROR) ; return 0 ; hInst = hInstance; iCapHeight = GetSystemMetrics(SM_CYCAPTION); hwnd = CreateWindowEx (WS_EX_LAYERED | WS_EX_TOPMOST, szApp

6、Name, TEXT (Transparent Clock), WS_POPUP , CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, hInstance, NULL) ; SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TOPMOST); hUser32 = GetModuleHandle(TEXT(user32.dll); SetLayeredWindowAttributesW = (lpfnSetLaye

7、redWindowAttributes)GetProcAddress(hUser32,SetLayeredWindowAttributes); SetLayeredWindowAttributesW(hwnd, 0, 80, LWA_ALPHA); FreeLibrary(hUser32); WndRGN = CreateEllipticRgn(0 ,0 , 200, 200); SetWindowRgn(hwnd, WndRGN, FALSE); ShowWindow (hwnd, iCmdShow) ; UpdateWindow (hwnd) ; while (GetMessage (&m

8、sg, NULL, 0, 0) TranslateMessage (&msg) ; DispatchMessage (&msg) ; return msg.wParam ;void SetIsotropic (HDC hdc, int cxClient, int cyClient) SetMapMode (hdc, MM_ISOTROPIC) ; SetWindowExtEx (hdc, 1000, 1000, NULL) ; SetViewportExtEx (hdc, cxClient / 2, -cyClient / 2, NULL) ; SetViewportOrgEx (hdc, c

9、xClient / 2, cyClient / 2, NULL) ;void RotatePoint (POINT pt, int iNum, int iAngle) int i ; POINT ptTemp ; for (i = 0 ; i iNum ; i+) ptTemp.x = (int) (pti.x * cos (TWOPI * iAngle / 360) + pti.y * sin (TWOPI * iAngle / 360) ; ptTemp.y = (int) (pti.y * cos (TWOPI * iAngle / 360) - pti.x * sin (TWOPI *

10、 iAngle / 360) ; pti = ptTemp ; void DrawClock (HDC hdc, HBRUSH hBrush) int iAngle ; POINT pt3 ; for (iAngle = 0 ; iAngle wHour * 30) % 360 + pst-wMinute / 2 ; iAngle1 = pst-wMinute * 6 ; iAngle2 = pst-wSecond * 6 ; memcpy (ptTemp, pt, sizeof (pt) ; for (i = fChange ? 0 : 2 ; i 3 ; i+) RotatePoint (

11、ptTempi, 5, iAnglei) ; Polyline (hdc, ptTempi, 5) ; LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) static int cxClient, cyClient ; static SYSTEMTIME stPrevious ; BOOL fChange ; HDC hdc ; PAINTSTRUCT ps ; SYSTEMTIME st ; static HHOOK hHookID; POINT p; static HMENU hM

12、enu; static HPEN hPen; static HBRUSH hBrush; RECT rect; switch (message) case WM_CREATE : hHookID = SetWindowsHookEx(WH_CALLWNDPROC, HookCallWndProc, 0,GetWindowThreadProcessId(hwnd,0); hMenu = LoadMenu(hInst, szAppName); hMenu = GetSubMenu(hMenu, 0); hPen=CreatePen(PS_SOLID,4,RGB(255,0,0); hBrush=C

13、reateSolidBrush(RGB(255,0,0); SetTimer (hwnd, ID_TIMER, 1000, NULL) ; GetLocalTime (&st) ; stPrevious = st ; return 0 ; case WM_SIZE : cxClient = LOWORD (lParam) ; cyClient = HIWORD (lParam) ; return 0 ; case WM_RBUTTONUP: case WM_NCRBUTTONUP: p.x = LOWORD(lParam); p.y = HIWORD(lParam);/ ClientToScr

14、een( hwnd , &p ); TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, p.x, p.y, 0, hwnd, NULL); return 0; case WM_NCHITTEST: GetClientRect(hwnd ,&rect ); p.x = LOWORD(lParam); p.y = HIWORD(lParam); ScreenToClient( hwnd , &p ); if( PtInRect(&rect, p ) return HTCAPTION; else return DefWindowProc (hwnd, message, wP

15、aram, lParam) ; break; case WM_TIMER : GetLocalTime (&st) ; fChange = st.wHour != stPrevious.wHour | st.wMinute != stPrevious.wMinute ; hdc = GetDC (hwnd) ; SetIsotropic (hdc, cxClient, cyClient) ; SelectObject (hdc, GetStockObject (WHITE_PEN) ; DrawHands (hdc, &stPrevious, fChange) ; SelectObject (

16、hdc, hPen) ; DrawHands (hdc, &st, TRUE) ; ReleaseDC (hwnd, hdc) ; stPrevious = st ; return 0 ; case WM_PAINT : hdc = BeginPaint (hwnd, &ps) ; SetIsotropic (hdc, cxClient, cyClient) ; DrawClock (hdc, hBrush) ; DrawHands (hdc, &stPrevious, TRUE) ; EndPaint (hwnd, &ps) ; return 0 ; case WM_COMMAND: swi

17、tch(LOWORD(wParam) case IDM_APP_EXIT: SendMessage(hwnd, WM_CLOSE, 0 ,0); return 0; break; case WM_DESTROY : if(hHookID!=0) UnhookWindowsHookEx(hHookID); DestroyMenu(hMenu); DeleteObject(hPen); DeleteObject(hBrush); KillTimer (hwnd, ID_TIMER) ; PostQuitMessage (0) ; return 0 ; return DefWindowProc (h

18、wnd, message, wParam, lParam) ;BOOL MakeWndTrans(HWND hWnd, int nAlpha) HMODULE hUser32; long ret; hUser32 = GetModuleHandle(TEXT(user32.dll); SetLayeredWindowAttributesW = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32,SetLayeredWindowAttributes); SetLayeredWindowAttributesW(hWnd, 0, 80, LW

19、A_ALPHA); FreeLibrary(hUser32); ret = SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributesW(hWnd, 0, (BYTE)nAlpha, LWA_ALPHA); return TRUE;LRESULT CALLBACK SubClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LONG lRet = (LONG)

20、 GetProp(hWnd, TEXT(OldWndProc); /LONG dwStyle; switch(uMsg) case WM_CREATE: MakeWndTrans(hWnd, 80); break; case WM_DESTROY: RemoveProp(hWnd, TEXT(OldWndProc); SetWindowLong(hWnd, GWL_WNDPROC, lRet); break; return CallWindowProc(WNDPROC)lRet, hWnd, uMsg, wParam, lParam);LRESULT CALLBACK HookCallWndP

21、roc(int nCode, WPARAM wParam, LPARAM lParam) CWPSTRUCT cwps; LONG lRet; if( nCode = HC_ACTION ) CopyMemory(&cwps, (LPVOID)lParam, sizeof(CWPSTRUCT); switch(cwps.message) case WM_CREATE: TCHAR szClass128; GetClassName(cwps.hwnd, szClass, 127 * sizeof(TCHAR);/should fix here if(lstrcmpi(szClass, TEXT(#32768)=0) lRet = SetWindowLong(cwps.hwnd, GWL_WNDPROC, (LONG)SubClassWndProc); SetProp(cwps.hwnd, TEXT(OldWndProc), (HANDLE)lRet); break; return CallNextHookEx(HHOOK)WH_CALLWNDPROC, nCode, wParam, lParam);

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1