about.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. #include <windows.h>
  2. #include "main.h"
  3. #if 1
  4. BOOL CALLBACK AboutProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  5. {
  6. if (uMsg == WM_COMMAND && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)) EndDialog(hwndDlg,0);
  7. return 0;
  8. }
  9. #else
  10. #include <commctrl.h>
  11. #include ".\graphics\image.h"
  12. #include ".\graphics\imagefilters.h"
  13. #include <strsafe.h>
  14. #define random( min, max ) (( rand() % (int)((( max ) + 1 ) - ( min ))) + ( min ))
  15. HBITMAP LoadImageFromResource(INT_PTR handle);
  16. #define LEGAL_COUNT 4
  17. wchar_t *legal[] = {L"Copyright (C) 1998-2006 - Nullsoft, Inc.",
  18. L"MPEG Layer-3 audio compression technology licensed by Fraunhofer IIS and THOMSON multimedia.",
  19. L"VLB decoding copyright 1998-2002 by Dolby Laboratories, Inc. All rights reserved.",
  20. L"AAC && aacPlus decoding copyright 1998-2006 by Coding Technologies, Inc. All rights reserved."};
  21. HFONT fntPlugin, fntC, fntLegal;
  22. HBRUSH brhDlgBG;
  23. #define IMAGES_COUNT 6
  24. #define IMAGES_INDEX_MY 0
  25. #define IMAGES_INDEX_WA 1
  26. #define IMAGES_INDEX_CT 2
  27. #define IMAGES_INDEX_IIS 3
  28. #define IMAGES_INDEX_ID3V2 4
  29. #define IMAGES_INDEX_MP3S 5
  30. RECT rectLogo[IMAGES_COUNT];
  31. MLImage *imgLogo[IMAGES_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL};
  32. MLImage *imgLlama = NULL, *imgLlamaOrig = NULL, *imgMy = NULL;
  33. RECT rcLlama;
  34. int idxSelected;
  35. wchar_t *url[IMAGES_COUNT - 1] = { L"http://winamp.com/",
  36. L"http://www.codingtechnologies.com/index.htm",
  37. L"http://www.iis.fraunhofer.de/index.html",
  38. L"http://www.id3.org/",
  39. L"http://www.iis.fraunhofer.de/amm/download/mp3surround/index.html"};
  40. HWND hwndTT;
  41. wchar_t strTT[] = L"click here to visit this website";
  42. #define TIMER_ID_WATERRENDER 1980
  43. #define TIMER_ID_WATERPULSE 1978
  44. #define TIMER_DELAY_WATERRENDER 48
  45. #define TIMER_DELAY_WATERPULSE 12000
  46. #define TIMER_ID_LLAMAFADE 1987
  47. #define TIMER_DELAY_LLAMAFADE 200
  48. #define TIMER_ID_LOADDATA 1959
  49. #define TIMER_DELAY_LOADDATA 10
  50. MLImage *tmpImage = NULL;
  51. MLImageFilterWater *fltrWater = NULL;
  52. HCURSOR curHand = NULL;
  53. void about_OnInit(HWND hwndDlg);
  54. void about_OnDestroy(HWND hwndDlg);
  55. void about_OnMouseDown(HWND hwndDlg, int cx, int cy);
  56. void about_OnMouseMove(HWND hwndDlg, int cx, int cy);
  57. void about_OnDraw(HWND hwndDlg);
  58. void timer_OnWaterPulse(HWND hwndDlg);
  59. void timer_OnLlamaFade(HWND hwndDlg);
  60. void timer_OnLoadData(HWND hwndDlg);
  61. void SetRects(int cx, int cy)
  62. {
  63. int i, xl, yl;
  64. i = IMAGES_INDEX_MY; xl = (cx - imgLogo[i]->GetWidth())/2; yl = 64;
  65. if (imgLogo[i]) SetRect(&rectLogo[i], xl, yl, xl + imgLogo[i]->GetWidth(), yl + imgLogo[i]->GetHeight());
  66. xl = 2; yl = 2; i = IMAGES_INDEX_WA;
  67. if (imgLogo[i]) SetRect(&rectLogo[i], xl, yl, xl + imgLogo[i]->GetWidth(), yl + imgLogo[i]->GetHeight());
  68. xl = 2; yl = cy - 88; i = IMAGES_INDEX_CT;
  69. if (imgLogo[i]) SetRect(&rectLogo[i], xl, yl, xl + imgLogo[i]->GetWidth(), yl + imgLogo[i]->GetHeight());
  70. xl = rectLogo[i].right; i = IMAGES_INDEX_IIS;
  71. if (imgLogo[i]) SetRect(&rectLogo[i], xl, yl, xl + imgLogo[i]->GetWidth(), yl + imgLogo[i]->GetHeight());
  72. xl = rectLogo[i].right; i = IMAGES_INDEX_ID3V2;
  73. if (imgLogo[i]) SetRect(&rectLogo[i], xl, yl, xl + imgLogo[i]->GetWidth(), yl + imgLogo[i]->GetHeight());
  74. xl = rectLogo[i].right; i = IMAGES_INDEX_MP3S;
  75. if (imgLogo[i]) SetRect(&rectLogo[i], xl, yl, xl + imgLogo[i]->GetWidth(), yl + imgLogo[i]->GetHeight());
  76. if(imgLlama) SetRect(&rcLlama, 2, 1, imgLlama->GetWidth() + 2, imgLlama->GetHeight() + 1);
  77. }
  78. void CreateToolTipWnd(HWND hwndDlg)
  79. {
  80. INITCOMMONCONTROLSEX iccex;
  81. iccex.dwICC = ICC_WIN95_CLASSES;
  82. iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  83. InitCommonControlsEx(&iccex);
  84. hwndTT = CreateWindowExW(WS_EX_TOPMOST, TOOLTIPS_CLASSW, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
  85. CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndDlg, NULL, mod.hDllInstance, NULL);
  86. SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
  87. }
  88. void UpdateToolTips(HWND hwndDlg)
  89. {
  90. TOOLINFOW ti;
  91. unsigned int uid = 0;
  92. // delete tools
  93. int ttCount = SendMessage(hwndTT, TTM_GETTOOLCOUNT, 0, 0);
  94. for(int i = 0; i < ttCount; i++)
  95. {
  96. if (SendMessageW(hwndTT, TTM_ENUMTOOLSW, (WPARAM)i, (LPARAM)&ti)) SendMessageW(hwndTT, TTM_DELTOOLW, 0, (LPARAM)&ti);
  97. }
  98. /// add tools
  99. for (int i = 1; i < IMAGES_COUNT -1; i++)
  100. {
  101. ti.cbSize = sizeof(TOOLINFO);
  102. ti.uFlags = TTF_SUBCLASS;
  103. ti.hwnd = hwndDlg;
  104. ti.hinst = mod.hDllInstance;
  105. ti.uId = uid;
  106. ti.lpszText = strTT;
  107. ti.rect = rectLogo[i];
  108. SendMessageW(hwndTT, TTM_ADDTOOLW, 0, (LPARAM) (LPTOOLINFO) &ti);
  109. }
  110. }
  111. BOOL CALLBACK AboutProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  112. {
  113. switch(uMsg)
  114. {
  115. case WM_INITDIALOG:
  116. about_OnInit(hwndDlg);
  117. break;
  118. case WM_DESTROY:
  119. about_OnDestroy(hwndDlg);
  120. break;
  121. case WM_COMMAND:
  122. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  123. {
  124. EndDialog(hwndDlg,0);
  125. }
  126. break;
  127. case WM_SIZE:
  128. if (wParam != SIZE_MINIMIZED)
  129. {
  130. SetRects(LOWORD(lParam), HIWORD(lParam));
  131. UpdateToolTips(hwndDlg);
  132. }
  133. case WM_MOUSEMOVE:
  134. about_OnMouseMove(hwndDlg, LOWORD(lParam), HIWORD(lParam));
  135. break;
  136. case WM_LBUTTONDOWN:
  137. about_OnMouseDown(hwndDlg, LOWORD(lParam), HIWORD(lParam));
  138. break;
  139. case WM_PAINT:
  140. about_OnDraw(hwndDlg);
  141. break;
  142. case WM_TIMER:
  143. switch(wParam)
  144. {
  145. case TIMER_ID_WATERRENDER:
  146. if (idxSelected != -1 && fltrWater)
  147. {
  148. fltrWater->Render(tmpImage, imgLogo[idxSelected]);
  149. InvalidateRect(hwndDlg, &rectLogo[idxSelected], FALSE);
  150. }
  151. break;
  152. case TIMER_ID_WATERPULSE:
  153. timer_OnWaterPulse(hwndDlg);
  154. break;
  155. case TIMER_ID_LLAMAFADE:
  156. timer_OnLlamaFade(hwndDlg);
  157. break;
  158. case TIMER_ID_LOADDATA:
  159. timer_OnLoadData(hwndDlg);
  160. break;
  161. }
  162. break;
  163. case WM_CTLCOLORDLG:
  164. return (BOOL)brhDlgBG;
  165. break;
  166. }
  167. return 0;
  168. }
  169. void about_OnInit(HWND hwndDlg)
  170. {
  171. HDC hdc = GetDC(hwndDlg);
  172. fntPlugin = CreateFontW(-MulDiv(20, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"Microsoft Sans Serif");
  173. fntC = CreateFontW(-MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0, L"Arial");
  174. fntLegal = CreateFontW(-MulDiv(6, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0, L"Microsoft Sans Serif");
  175. ReleaseDC(hwndDlg, hdc);
  176. brhDlgBG = CreateSolidBrush(RGB(255,255,255));
  177. SetTimer(hwndDlg, TIMER_ID_LOADDATA, TIMER_DELAY_LOADDATA, NULL);
  178. }
  179. void about_OnDestroy(HWND hwndDlg)
  180. {
  181. for (int i = 0; i < IMAGES_COUNT; i++)
  182. {
  183. if (imgLogo[i]) delete(imgLogo[i]);
  184. imgLogo[i] = NULL;
  185. }
  186. if (imgLlama) delete(imgLlama);
  187. imgLlama = NULL;
  188. if (imgLlamaOrig) delete(imgLlamaOrig);
  189. imgLlamaOrig = NULL;
  190. if (imgMy) delete(imgMy);
  191. imgMy = NULL;
  192. if (fntPlugin) DeleteObject(fntPlugin);
  193. if (fntC) DeleteObject(fntC);
  194. if (fntLegal) DeleteObject(fntLegal);
  195. fntPlugin = NULL;
  196. fntC = NULL;
  197. fntLegal = NULL;
  198. if (brhDlgBG) DeleteObject(brhDlgBG);
  199. brhDlgBG = NULL;
  200. if (fltrWater) delete (fltrWater);
  201. fltrWater = NULL;
  202. if (tmpImage) delete(tmpImage);
  203. tmpImage = NULL;
  204. if (curHand) DestroyCursor(curHand);
  205. curHand = NULL;
  206. }
  207. void about_OnMouseDown(HWND hwndDlg, int cx, int cy)
  208. {
  209. if (idxSelected == -1) return;
  210. HCURSOR curWait = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(32514/*OCR_WAIT*/), IMAGE_CURSOR, 0, 0, LR_DEFAULTCOLOR);
  211. SetCursor(curWait);
  212. ShellExecuteW(hwndDlg, L"open", url[idxSelected -1], NULL, L"c:\\", SW_SHOW);
  213. SetCursor(curHand);
  214. DestroyCursor(curWait);
  215. }
  216. void about_OnMouseMove(HWND hwndDlg, int cx, int cy)
  217. {
  218. POINT pt = {cx, cy};
  219. int idxNew = -1;
  220. for (int i = 1; i < IMAGES_COUNT - 1; i ++)
  221. {
  222. if (PtInRect(&rectLogo[i], pt))
  223. {
  224. if (!curHand)
  225. {
  226. curHand = (HCURSOR)LoadImage(mod.hDllInstance, MAKEINTRESOURCE(IDC_CUR_HAND), IMAGE_CURSOR, 0, 0, LR_DEFAULTCOLOR);
  227. }
  228. SetCursor(curHand);
  229. idxNew = i;
  230. }
  231. }
  232. if (idxNew != idxSelected)
  233. {
  234. // stop animation
  235. KillTimer(hwndDlg, TIMER_ID_WATERPULSE);
  236. KillTimer(hwndDlg, TIMER_ID_WATERRENDER);
  237. if (idxSelected != -1) // redraw previously animated
  238. {
  239. InvalidateRect(hwndDlg, &rectLogo[idxSelected], FALSE);
  240. }
  241. // set new one
  242. idxSelected = idxNew;
  243. if (fltrWater) delete(fltrWater);
  244. fltrWater = NULL;
  245. if (tmpImage) delete(tmpImage);
  246. tmpImage = NULL;
  247. if (idxSelected != -1 && idxSelected != IMAGES_INDEX_WA) SetTimer(hwndDlg, TIMER_ID_WATERPULSE, 30, NULL); // start delay
  248. }
  249. }
  250. void about_OnDraw(HWND hwndDlg)
  251. {
  252. PAINTSTRUCT ps;
  253. HDC hdc;
  254. hdc = BeginPaint(hwndDlg, &ps);
  255. RECT rc, ri;
  256. GetClientRect(hwndDlg, &rc);
  257. // Draw Llama
  258. RECT rl;
  259. SetRect(&rl, rcLlama.left, rcLlama.top, rcLlama.right, rcLlama.bottom);
  260. if (imgLlama && IntersectRect(&ri, &rl, &ps.rcPaint))
  261. {
  262. HRGN hrgn = CreateRectRgn(rcLlama.left, rcLlama.top, rcLlama.right, rcLlama.bottom);
  263. HRGN hrgn1 = CreateRectRgn(rectLogo[IMAGES_INDEX_MY].left,
  264. rectLogo[IMAGES_INDEX_MY].top,
  265. rectLogo[IMAGES_INDEX_MY].right,
  266. rectLogo[IMAGES_INDEX_MY].bottom);
  267. CombineRgn(hrgn, hrgn, hrgn1, RGN_DIFF);
  268. DeleteObject(hrgn1);
  269. hrgn1 = CreateRectRgn(rectLogo[IMAGES_INDEX_WA].left,
  270. rectLogo[IMAGES_INDEX_WA].top,
  271. rectLogo[IMAGES_INDEX_WA].right,
  272. rectLogo[IMAGES_INDEX_WA].bottom);
  273. CombineRgn(hrgn, hrgn, hrgn1, RGN_DIFF);
  274. SelectClipRgn(hdc, hrgn);
  275. DeleteObject(hrgn);
  276. DeleteObject(hrgn1);
  277. imgLlama->Draw(hdc, rl.left, rl.top);
  278. SelectClipRgn(hdc, NULL);
  279. }
  280. MLImage *img;
  281. for (int i = 0; i < IMAGES_COUNT -1; i++)
  282. {
  283. if (IntersectRect(&ri, &rectLogo[i], &ps.rcPaint))
  284. {
  285. if (idxSelected == i && tmpImage)
  286. {
  287. img = tmpImage;
  288. HRGN hrgn = CreateRectRgn(rectLogo[i].left + 3, rectLogo[i].top + 3 , rectLogo[i].right - 3, rectLogo[i].bottom - 3);
  289. SelectClipRgn(hdc, hrgn);
  290. DeleteObject(hrgn);
  291. }
  292. else img = imgLogo[i];
  293. if (img == NULL || imgLlama == NULL) continue;
  294. if (i == IMAGES_INDEX_MY)
  295. { // blend Llama First
  296. MLImageFilter_Blend1(imgMy, img, 0, 0,
  297. imgLlama->GetWidth() - (rectLogo[i].left - rcLlama.left), img->GetHeight(), imgLlama,
  298. rectLogo[i].left - rcLlama.left, rectLogo[i].top - rcLlama.top, RGB(255,255,255));
  299. img = imgMy;
  300. }
  301. img->Draw(hdc, rectLogo[i].left, rectLogo[i].top);
  302. SelectClipRgn(hdc, NULL);
  303. }
  304. }
  305. RECT rt;
  306. SetBkMode(hdc, TRANSPARENT);
  307. rc.left += 6;
  308. rc.bottom -= 2;
  309. rc.right -= 4;
  310. HFONT oldF = NULL;
  311. SetRect(&rt, rc.right - 192, rc.top, rc.right, rc.top + 16);
  312. if (IntersectRect(&ri, &rt, &ps.rcPaint))
  313. {
  314. /// Nullsoft (c)
  315. HFONT oldF = (HFONT)SelectObject(hdc, fntC);
  316. SetTextColor(hdc, RGB(100,100,200));
  317. DrawTextW(hdc, legal[0], -1, &rt, DT_LEFT | DT_SINGLELINE);
  318. }
  319. SetRect(&rt, rc.left - 2, rc.bottom - 33, rc.right, rc.bottom);
  320. if (IntersectRect(&ri, &rt, &ps.rcPaint))
  321. {
  322. /// Separator
  323. MoveToEx(hdc, rt.left, rt.top, NULL);
  324. HPEN lp = CreatePen(PS_SOLID,1, RGB(190, 190, 190));
  325. HPEN op = (HPEN)SelectObject(hdc, lp);
  326. LineTo(hdc, rt.right, rt.top);
  327. SelectObject(hdc, lp);
  328. DeleteObject(lp);
  329. /// Legal...
  330. oldF = (oldF != NULL) ? oldF : (HFONT)SelectObject(hdc, fntLegal);
  331. SetTextColor(hdc, RGB(0,0,0));
  332. for(int i = 1; i < LEGAL_COUNT; i++)
  333. {
  334. int y = rc.bottom - (LEGAL_COUNT - i)*10;
  335. SetRect(&rt, rc.left, y, rc.right, y +10);
  336. if (IntersectRect(&ri, &rt, &ps.rcPaint))
  337. DrawTextW(hdc, legal[i], -1, &rt, DT_LEFT | DT_SINGLELINE);
  338. }
  339. }
  340. if (oldF != NULL) SelectObject(hdc, oldF);
  341. EndPaint(hwndDlg, &ps);
  342. }
  343. void timer_OnLoadData(HWND hwndDlg)
  344. {
  345. static step = 0;
  346. KillTimer(hwndDlg, TIMER_ID_LOADDATA);
  347. RECT rc;
  348. GetClientRect(hwndDlg, &rc);
  349. for (int i = 0; i < IMAGES_COUNT; i++)
  350. {
  351. imgLogo[i] = new MLImage(LoadImageFromResource, TRUE);
  352. imgLogo[i]->Load();
  353. }
  354. imgMy = new MLImage();
  355. MLImage::Copy(imgMy, imgLogo[IMAGES_INDEX_MY]);
  356. imgLlamaOrig = new MLImage(LoadImageFromResource, TRUE);
  357. imgLlamaOrig->Load();
  358. imgLlama = new MLImage();
  359. MLImage::Copy(imgLlama, imgLlamaOrig);
  360. CreateToolTipWnd(hwndDlg);
  361. UpdateToolTips(hwndDlg);
  362. idxSelected = -1;
  363. SetRects(rc.right - rc.left, rc.bottom - rc.top);
  364. InvalidateRect(hwndDlg, &rc, FALSE);
  365. // SetTimer(hwndDlg, TIMER_ID_LLAMAFADE, TIMER_DELAY_LLAMAFADE, NULL);
  366. }
  367. void timer_OnWaterPulse(HWND hwndDlg)
  368. {
  369. if (idxSelected == -1) return;
  370. BOOL startRender = (!fltrWater);
  371. if(!fltrWater)
  372. {
  373. KillTimer(hwndDlg, TIMER_ID_WATERPULSE); // stop timer - will change to slower interval
  374. fltrWater = new MLImageFilterWater();
  375. fltrWater->CreateFor(imgLogo[idxSelected]);
  376. tmpImage = new MLImage(imgLogo[idxSelected]->GetWidth(), imgLogo[idxSelected]->GetHeight());
  377. }
  378. int ow = imgLogo[idxSelected]->GetWidth();
  379. int oh = imgLogo[idxSelected]->GetHeight();
  380. for (int i = 0; i < oh*ow/1024; i++)
  381. {
  382. fltrWater->SineBlob(-1, -1, random(4,min(oh,ow)), 600, 0);
  383. }
  384. if (startRender)
  385. {
  386. SetTimer(hwndDlg, TIMER_ID_WATERRENDER, TIMER_DELAY_WATERRENDER, NULL);
  387. SetTimer(hwndDlg, TIMER_ID_WATERPULSE, TIMER_DELAY_WATERPULSE, NULL);
  388. }
  389. }
  390. void timer_OnLlamaFade(HWND hwndDlg)
  391. {
  392. static int c = -2;
  393. static int step = 2;
  394. c = c + step;
  395. if (c > 30 && step > 0) {step = 0 - step; c = 30;}
  396. else if (c < 0 && step < 0) { step = 0 - step; c = 0; }
  397. MLImageFilter_Fader3(imgLlama, imgLlamaOrig, c);
  398. InvalidateRect(hwndDlg, &rcLlama, FALSE);
  399. }
  400. HBITMAP LoadImageFromResource(INT_PTR handle)
  401. {
  402. int id = 0;
  403. BOOL incSize;
  404. MLImage *img = (MLImage*)handle;
  405. if (img == imgLogo[IMAGES_INDEX_WA]) {id = IDB_LOGO_WAPLUGINS; incSize = FALSE;}
  406. else if (img == imgLogo[IMAGES_INDEX_IIS]) {id = IDB_LOGO_IIS; incSize = TRUE;}
  407. else if (img == imgLogo[IMAGES_INDEX_CT]) {id = IDB_LOGO_CODETECH; incSize = TRUE;}
  408. else if (img == imgLogo[IMAGES_INDEX_ID3V2]) {id = IDB_LOGO_ID3V2; incSize = TRUE;}
  409. else if (img == imgLogo[IMAGES_INDEX_MP3S]) {id = IDB_LOGO_MP3SURROUND; incSize = FALSE;} // because we don't use it for now
  410. else if (img == imgLogo[IMAGES_INDEX_MY]) {id = IDB_LOGO_MY; incSize = FALSE;}
  411. else if (img == imgLlamaOrig) {id = IDB_LLAMA; incSize = FALSE;}
  412. if (id == 0) return NULL;
  413. HBITMAP hbmp = LoadBitmap(mod.hDllInstance, MAKEINTRESOURCE(id));
  414. if (hbmp == NULL) return hbmp;
  415. if (incSize)
  416. {// we want to add additional white border
  417. HDC hdcWnd = GetWindowDC(NULL);
  418. HDC hdcSrc = CreateCompatibleDC(hdcWnd);
  419. HDC hdcDest = CreateCompatibleDC(hdcWnd);
  420. BITMAP bmp;
  421. GetObject(hbmp, sizeof(BITMAP), &bmp);
  422. int extraW = 40;
  423. int extraH = 16;
  424. HBITMAP hbmpNew = CreateBitmap(bmp.bmWidth + extraW, bmp.bmHeight + extraH, bmp.bmPlanes, bmp.bmBitsPixel, NULL);
  425. SelectObject(hdcSrc, hbmp);
  426. SelectObject(hdcDest, hbmpNew);
  427. // fill borders
  428. HBRUSH br = CreateSolidBrush(RGB(255,255,255));
  429. RECT rc;
  430. SetRect(&rc, 0,0, bmp.bmWidth + extraW, extraH/2);
  431. FillRect(hdcDest, &rc, br);
  432. SetRect(&rc, 0, bmp.bmHeight + extraH/2, bmp.bmWidth + extraW, bmp.bmHeight + extraH);
  433. FillRect(hdcDest, &rc, br);
  434. SetRect(&rc, 0, extraH/2, extraW/2, bmp.bmHeight + extraH/2);
  435. FillRect(hdcDest, &rc, br);
  436. SetRect(&rc, bmp.bmWidth + extraW/2, extraH/2, bmp.bmWidth + extraW, bmp.bmHeight + extraH/2);
  437. FillRect(hdcDest, &rc, br);
  438. // copy original
  439. BitBlt(hdcDest, extraW/2, extraH/2, bmp.bmWidth, bmp.bmHeight, hdcSrc, 0,0, SRCCOPY);
  440. DeleteObject(br);
  441. DeleteObject(hbmp);
  442. DeleteDC(hdcSrc);
  443. DeleteDC(hdcDest);
  444. ReleaseDC(NULL, hdcWnd);
  445. hbmp = hbmpNew;
  446. }
  447. if (img == imgLogo[IMAGES_INDEX_MY])
  448. { // need to add vesion number
  449. HDC hdcWnd = GetWindowDC(NULL);
  450. HDC hdcSrc = CreateCompatibleDC(hdcWnd);
  451. HDC hdcDest = CreateCompatibleDC(hdcWnd);
  452. HFONT fnt = CreateFontW(-MulDiv(90, GetDeviceCaps(hdcDest, LOGPIXELSY), 72), 22, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0, L"Agency FB");
  453. SelectObject(hdcDest, fnt);
  454. char *ver = mod.description + lstrlen(mod.description);
  455. while(ver != mod.description && *ver != ' ')
  456. {
  457. ver = CharPrevA(mod.description, ver);
  458. }
  459. if (*ver == ' ') ver++;
  460. RECT rc;
  461. SetRect(&rc, 0, 0, 0, 0);
  462. DrawText(hdcDest, ver, -1, &rc, DT_CALCRECT | DT_RIGHT |DT_SINGLELINE);
  463. int extraW = rc.right + 6;
  464. int extraH = 16;
  465. BITMAP bmp;
  466. GetObject(hbmp, sizeof(BITMAP), &bmp);
  467. HBITMAP hbmpNew = CreateBitmap(bmp.bmWidth + extraW, bmp.bmHeight + extraH, bmp.bmPlanes, bmp.bmBitsPixel, NULL);
  468. SelectObject(hdcSrc, hbmp);
  469. SelectObject(hdcDest, hbmpNew);
  470. // fill new area
  471. HBRUSH br = CreateSolidBrush(RGB(255,255,255));
  472. SetRect(&rc, bmp.bmWidth,0, bmp.bmWidth + extraW, bmp.bmHeight + extraH);
  473. FillRect(hdcDest, &rc, br);
  474. SetRect(&rc, 0,0, bmp.bmWidth, extraH);
  475. FillRect(hdcDest, &rc, br);
  476. // copy original
  477. BitBlt(hdcDest, 0, extraH, bmp.bmWidth, bmp.bmHeight, hdcSrc, 0,0, SRCCOPY);
  478. // draw number
  479. SetTextColor(hdcDest, RGB(80, 60, 10));
  480. SetBkMode(hdcDest, TRANSPARENT);
  481. SetRect(&rc, bmp.bmWidth + 6, rc.top -= 22, bmp.bmWidth + extraW, bmp.bmHeight + extraH);
  482. DrawText(hdcDest, ver, -1, &rc, DT_RIGHT |DT_SINGLELINE);
  483. DeleteObject(fnt);
  484. DeleteObject(br);
  485. DeleteObject(hbmp);
  486. DeleteDC(hdcSrc);
  487. DeleteDC(hdcDest);
  488. ReleaseDC(NULL, hdcWnd);
  489. hbmp = hbmpNew;
  490. }
  491. return hbmp;
  492. }
  493. #endif