aboutdlg.cpp
上传用户:kittypts
上传日期:2018-02-11
资源大小:241k
文件大小:3k
- /*****************************************************************************
- Windows Live Messenger Plugin Demo
- Copyright (C) 2008 Hern醤 Di Pietro
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- /*****************************************************************************/
- #include "wlmplugin.h"
- #include "clrzwind.h"
- #include "aboutdlg.h"
- #include "../resdll/resource.h"
- static WNDPROC pfnColorizedWndProc;
- HWND g_hwndNktAbout;
- void CreateAboutDlg(HWND* pHWnd)
- {
- *pHWnd = CreateWindowEx(NULL, wszColorizedWndClass, NULL, WS_POPUP,
- CW_USEDEFAULT, CW_USEDEFAULT, CX_DIALOGSIZE, CY_DIALOGSIZE,
- NULL, NULL, hDllInst, NULL );
- // subclass
- if (*pHWnd)
- {
- pfnColorizedWndProc = (WNDPROC) GetWindowLongPtr(*pHWnd, GWLP_WNDPROC);
- SetWindowLongPtr(*pHWnd, GWLP_WNDPROC, (LONG_PTR)AboutDlgProc);
- }
- }
- LRESULT AboutDlgProc (HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
- {
- static bool fChildCreated = false;
- static HBITMAP hLogo;
- switch(uMsg)
- {
- case WM_CREATECHILDCTRLS:
- if (!fChildCreated)
- {
- RECT r;
- HWND hOkButton;
- HFONT hfDefault;
- GetWindowRect(hwnd, &r);
- hOkButton = CreateWindow(L"button", L"OK", WS_VISIBLE | WS_TABSTOP | WS_CHILD | BS_DEFPUSHBUTTON,
- r.right - 80, r.bottom- 30, 60, 21, hwnd, (HMENU)ID_OK, hDllInst, 0);
- hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- SendMessage(hOkButton, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
- // Load logo bitmap
- hLogo = (HBITMAP) LoadImage (hResLib, MAKEINTRESOURCE(IDB_NKTLOGO),
- IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
- fChildCreated = true;
- break;
- }
- case WM_COMMAND:
- if (LOWORD(wparam) == ID_OK)
- AnimateWindow(hwnd, 300, AW_HIDE | AW_BLEND);
- break;
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdc;
- BITMAP bm;
- HDC hdcMem;
- RECT textRect;
-
- hdc = BeginPaint(hwnd, &ps);
- hdcMem = CreateCompatibleDC(hdc);
- HBITMAP hbmpOld = (HBITMAP) SelectObject(hdcMem, hLogo);
- GetObject(hLogo, sizeof(bm), &bm);
- TransparentBlt (hdc, 20, 20, bm.bmWidth, bm.bmHeight, hdcMem,
- 0,0, bm.bmWidth, bm.bmHeight, RGB(255,0,240));
- SelectObject(hdcMem, hbmpOld);
- DeleteDC(hdcMem);
- SetBkMode(hdc, TRANSPARENT);
- SetRect(&textRect, 20, bm.bmHeight + 30, CX_DIALOGSIZE - 20, CY_DIALOGSIZE - 20);
- SetTextAlign(hdc, TA_LEFT | TA_TOP | TA_NOUPDATECP);
- SelectObject(hdc, (HFONT)GetStockObject(DEFAULT_GUI_FONT));
- DrawText (hdc, wszMessage, -1, &textRect, DT_LEFT | DT_WORDBREAK );
- EndPaint(hwnd, &ps);
- }
- return 0L;
- case WM_CLOSE:
- SendMessage (hwnd, WM_COMMAND, MAKEWPARAM(ID_OK, 0), 0);
- return 0L;
- }
- return CallWindowProc(pfnColorizedWndProc, hwnd, uMsg, wparam, lparam);
- }