browserPopup.cpp 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093
  1. #include "main.h"
  2. #include "./browser.h"
  3. #include "./browserUiInternal.h"
  4. #include "./browserPopup.h"
  5. #include "./browserHost.h"
  6. #include "./browserThread.h"
  7. #include "./graphics.h"
  8. #include "./resource.h"
  9. #include "./toolbar.h"
  10. #include "./statusbar.h"
  11. #include "./curtain.h"
  12. #include "../winamp/skinWindowIPC.h"
  13. #include "../Plugins/General/gen_ml/colors.h"
  14. #include "./obj_ombrowser.h"
  15. #include "./ifc_omservice.h"
  16. #include "./ifc_omserviceeventmngr.h"
  17. #include "./ifc_omserviceevent.h"
  18. #include "./ifc_ombrowserwndmngr.h"
  19. #include "./ifc_ombrowsereventmngr.h"
  20. #include "./ifc_omconfig.h"
  21. #include "./ifc_omtoolbarconfig.h"
  22. #include "./ifc_omstatusbarconfig.h"
  23. #include "./ifc_wasabihelper.h"
  24. #include "./ifc_skinhelper.h"
  25. #include "./ifc_skinnedbrowser.h"
  26. #include "./browserUiHook.h"
  27. #ifdef _DEBUG
  28. #pragma warning( push )
  29. #pragma warning( disable : 4244 )
  30. #endif
  31. #include <api/wnd/api_window.h>
  32. #ifdef _DEBUG
  33. #pragma warning( pop )
  34. #endif
  35. #include "../winamp/wa_dlg.h"
  36. #include <exdispid.h>
  37. #include <strsafe.h>
  38. #define IDC_BROWSER 0x1000
  39. #define IDC_TOOLBAR 0x1001
  40. #define IDC_STATUSBAR 0x1002
  41. #define BPT_ACTIVATEFRAME 27
  42. #define BPT_ACTIVATEFRAME_DELAY 300
  43. #define OSWNDHOST_REQUEST_IDEAL_SIZE (WM_USER + 2048)
  44. typedef struct __BROWSERPOPUPCREATEPARAM
  45. {
  46. obj_ombrowser *browserManager;
  47. ifc_omservice *service;
  48. WPARAM callbackParam;
  49. DISPATCHAPC callback;
  50. HWND hOwner;
  51. } BROWSERPOPUPCREATEPARAM;
  52. typedef struct __POPUPRESTORE
  53. {
  54. UINT style;
  55. UINT exStyle;
  56. RECT rect;
  57. UINT embedStyle;
  58. UINT embedFlags;
  59. GUID embedGuid;
  60. HWND hOwner; // NULL - if DlgParent
  61. } POPUPRESTORE;
  62. #define BPF_LOCKRESIZE 0x00000001
  63. #define BPF_FORCEDTOPMOST 0x00000002
  64. #define BPF_MODECHANGELOCK 0x00000004
  65. typedef struct __BROWSERPOPUP
  66. {
  67. UINT extendedStyle;
  68. UINT flags;
  69. obj_ombrowser *browserManager;
  70. ifc_omservice *service;
  71. LPWSTR storedUrl;
  72. BSTR storedData;
  73. HWND lastFocus;
  74. BrowserUiHook *browserHook;
  75. WPARAM callbackParam;
  76. DISPATCHAPC callback;
  77. COLORREF rgbBack;
  78. POPUPRESTORE *restore;
  79. HWND hOwner;
  80. } BROWSERPOPUP;
  81. #define FULLSCREEN_STYLE_FILTER (WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_POPUP)
  82. #define FULLSCREEN_EXSTYLE_FILTER (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_DLGMODALFRAME | WS_EX_TOOLWINDOW)
  83. #define GetPopup(__hwnd) ((BROWSERPOPUP*)(LONG_PTR)(LONGX86)GetWindowLongPtr((__hwnd), 0))
  84. static LRESULT CALLBACK BrowserPopup_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  85. static BOOL BrowserPopup_RegisterClass(HINSTANCE hInstance)
  86. {
  87. WNDCLASS wc;
  88. if (GetClassInfo(hInstance, NWC_OMBROWSERPOPUP, &wc)) return TRUE;
  89. ZeroMemory(&wc, sizeof(WNDCLASS));
  90. wc.hInstance = hInstance;
  91. wc.lpszClassName = NWC_OMBROWSERPOPUP;
  92. wc.lpfnWndProc = BrowserPopup_WindowProc;
  93. wc.style = CS_DBLCLKS;
  94. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  95. wc.hbrBackground = NULL;
  96. wc.cbWndExtra = sizeof(BROWSERPOPUP*);
  97. if (0 == RegisterClassW(&wc))
  98. return FALSE;
  99. return TRUE;
  100. }
  101. HWND BrowserPopup_Create(obj_ombrowser *browserManager, ifc_omservice *service, UINT fStyle, INT x, INT y, INT cx, INT cy, HWND hOwner, DISPATCHAPC callback, ULONG_PTR callbackParam)
  102. {
  103. if (FALSE == BrowserPopup_RegisterClass(Plugin_GetInstance()))
  104. return NULL;
  105. Toolbar_RegisterClass(Plugin_GetInstance());
  106. Statusbar_RegisterClass(Plugin_GetInstance());
  107. if (NULL == hOwner && FAILED(Plugin_GetWinampWnd(&hOwner)))
  108. hOwner = NULL;
  109. BROWSERPOPUPCREATEPARAM param;
  110. ZeroMemory(&param, sizeof(BROWSERPOPUPCREATEPARAM));
  111. param.browserManager = browserManager;
  112. param.service = service;
  113. param.callback = callback;
  114. param.callbackParam = callbackParam;
  115. param.hOwner = hOwner;
  116. HWND hPopup = CreateWindowEx(WS_EX_WINDOWEDGE,
  117. NWC_OMBROWSERPOPUP, OMBROWSER_NAME,
  118. WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | (0x0000FFFFF & fStyle),
  119. x, y, cx, cy,
  120. hOwner, NULL,
  121. Plugin_GetInstance(), &param);
  122. return hPopup;
  123. }
  124. static HWND BrowserPopup_GetFrame(HWND hwnd)
  125. {
  126. HWND hFrame = hwnd;
  127. while (NULL != hFrame &&
  128. 0 != (WS_CHILD & GetWindowLongPtr(hFrame, GWL_STYLE)))
  129. {
  130. hFrame = GetAncestor(hFrame, GA_PARENT);
  131. }
  132. return hFrame;
  133. }
  134. static void BrowserPopup_Paint(HWND hwnd, HDC hdc, const RECT *prcPaint, BOOL fErase)
  135. {
  136. BROWSERPOPUP *popup = GetPopup(hwnd);
  137. if (NULL == popup) return;
  138. SetBkColor(hdc, popup->rgbBack);
  139. ExtTextOut(hdc, 0, 0, ETO_OPAQUE, prcPaint, NULL, 0, NULL);
  140. }
  141. static void BrowserPopup_UpdateTitle(HWND hwnd, LPCWSTR pszTitle)
  142. {
  143. if (NULL == hwnd) return;
  144. WCHAR szBuffer[256] = {0};
  145. LPWSTR cursor = szBuffer;
  146. size_t remaining = ARRAYSIZE(szBuffer);
  147. BROWSERPOPUP *popup = GetPopup(hwnd);
  148. if (NULL != popup)
  149. {
  150. if (NULL != popup->service)
  151. {
  152. WCHAR szName[128] = {0};
  153. if (SUCCEEDED(popup->service->GetName(szName, ARRAYSIZE(szName))) && L'\0' != szName[0])
  154. StringCchCopyEx(cursor, remaining, szName, &cursor, &remaining, STRSAFE_NULL_ON_FAILURE);
  155. }
  156. HWND hFrame = (SENDWAIPC(hwnd, IPC_SKINWINDOW_GETEMBEDNUMS, 0) ? NULL : BrowserPopup_GetFrame(hwnd));
  157. if (NULL != pszTitle && hFrame != hwnd) // for now we can't update title in classic skin
  158. {
  159. if (cursor != szBuffer)
  160. StringCchCopyEx(cursor, remaining, L": ", &cursor, &remaining, STRSAFE_NULL_ON_FAILURE);
  161. StringCchCopyEx(cursor, remaining, pszTitle, &cursor, &remaining, STRSAFE_NULL_ON_FAILURE);
  162. }
  163. else
  164. {
  165. /* if (NULL != popup->container)
  166. {
  167. IWebBrowser2 *pWeb2;
  168. if (SUCCEEDED(popup->container->GetIWebBrowser2(&pWeb2)))
  169. {
  170. BSTR bstrTitle;
  171. if (SUCCEEDED(pWeb2->get_LocationName(&bstrTitle)) && NULL != bstrTitle)
  172. {
  173. StringCchCopyEx(cursor, remaining, bstrTitle, &cursor, &remaining, STRSAFE_NULL_ON_FAILURE);
  174. SysFreeString(bstrTitle);
  175. }
  176. pWeb2->Release();
  177. }
  178. }*/
  179. }
  180. }
  181. if (cursor == szBuffer)
  182. StringCchCopy(szBuffer, ARRAYSIZE(szBuffer), OMBROWSER_NAME);
  183. SetWindowText(hwnd, szBuffer);
  184. }
  185. static HWND BrowserPopup_CreateToolbar(HWND hwnd)
  186. {
  187. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  188. if (NULL != hToolbar) return hToolbar;
  189. BROWSERPOPUP *popup = GetPopup(hwnd);
  190. if (NULL == popup) return NULL;
  191. UINT fStyle = GetWindowStyle(hwnd);
  192. UINT toolbarStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBS_LOCKUPDATE | TBS_SHOWADDRESS;
  193. if (0 == (NBCS_NOTOOLBAR & fStyle))
  194. toolbarStyle |= WS_VISIBLE;
  195. ifc_omtoolbarconfig *toolbarConfig;
  196. if (NULL != popup->browserManager && SUCCEEDED(popup->browserManager->GetConfig(&IFC_OmToolbarConfig, (void**)&toolbarConfig)))
  197. {
  198. if (S_OK == toolbarConfig->GetBottomDockEnabled())
  199. toolbarStyle |= TBS_BOTTOMDOCK;
  200. if (S_OK == toolbarConfig->GetAutoHideEnabled())
  201. toolbarStyle |= TBS_AUTOHIDE;
  202. if (S_OK == toolbarConfig->GetTabStopEnabled())
  203. toolbarStyle |= TBS_TABSTOP;
  204. if (S_OK == toolbarConfig->GetForceAddressbarEnabled())
  205. toolbarStyle |= TBS_FORCEADDRESS;
  206. if (S_OK == toolbarConfig->GetFancyAddressbarEnabled())
  207. toolbarStyle |= TBS_FANCYADDRESS;
  208. toolbarConfig->Release();
  209. }
  210. HINSTANCE hInstance = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
  211. hToolbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY,
  212. NWC_ONLINEMEDIATOOLBAR, NULL, toolbarStyle,
  213. 0, 0, 0, 0, hwnd, (HMENU)IDC_TOOLBAR, hInstance, NULL);
  214. if (NULL == hToolbar)
  215. return NULL;
  216. UINT populateStyle = TBPF_NORMAL | TBPF_READONLYADDRESS;
  217. if (0 != (NBCS_NOSERVICECOMMANDS & fStyle))
  218. populateStyle |= TBPF_NOSERVICECOMMANDS;
  219. Toolbar_AutoPopulate(hToolbar, popup->service, populateStyle);
  220. toolbarStyle = GetWindowStyle(hToolbar);
  221. if (0 != (TBS_LOCKUPDATE & toolbarStyle))
  222. Toolbar_LockUpdate(hToolbar, FALSE);
  223. return hToolbar;
  224. }
  225. static HWND BrowserPopup_CreateStatusbar(HWND hwnd)
  226. {
  227. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  228. if (NULL != hStatusbar) return hStatusbar;
  229. BROWSERPOPUP *popup = GetPopup(hwnd);
  230. if (NULL == popup) return NULL;
  231. UINT fStyle = GetWindowStyle(hwnd);
  232. UINT statusbarStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED;
  233. if (0 == (NBCS_NOSTATUSBAR & fStyle))
  234. {
  235. ifc_omstatusbarconfig *statusbarConfig;
  236. if (NULL != popup->browserManager && SUCCEEDED(popup->browserManager->GetConfig(&IFC_OmStatusbarConfig, (void**)&statusbarConfig)))
  237. {
  238. if (S_OK == statusbarConfig->GetEnabled())
  239. statusbarStyle &= ~WS_DISABLED;
  240. statusbarConfig->Release();
  241. }
  242. }
  243. HINSTANCE hInstance = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
  244. hStatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY,
  245. NWC_ONLINEMEDIASTATUSBAR, NULL, statusbarStyle,
  246. 0, 0, 0, 0, hwnd, (HMENU)IDC_STATUSBAR, hInstance, NULL);
  247. return hStatusbar;
  248. }
  249. static BOOL BrowserPopup_PushRect(HWND hwnd, const RECT *rectIn, BOOL fOnlyIfExist)
  250. {
  251. if (NULL == rectIn) return FALSE;
  252. RECT *rect = (RECT*)GetProp(hwnd, TEXT("omBrowserPopupRect"));
  253. if (FALSE != fOnlyIfExist && NULL == rect)
  254. return FALSE;
  255. if (NULL == rect)
  256. {
  257. rect = (RECT*)calloc(1, sizeof(RECT));
  258. if (NULL == rect || FALSE == SetProp(hwnd, TEXT("omBrowserPopupRect"), rect))
  259. {
  260. if (NULL != rect) free(rect);
  261. return FALSE;
  262. }
  263. }
  264. return CopyRect(rect, rectIn);
  265. }
  266. static BOOL BrwoserPopup_PushClientRect(HWND hwnd, BOOL fOnlyIfExists)
  267. {
  268. RECT clientRect;
  269. if (!GetClientRect(hwnd, &clientRect))
  270. return FALSE;
  271. MapWindowPoints(hwnd, HWND_DESKTOP, (POINT*)&clientRect, 2);
  272. return BrowserPopup_PushRect(hwnd, &clientRect, fOnlyIfExists);
  273. }
  274. static BOOL BrowserPopup_PopRect(HWND hwnd, RECT *rectOut, BOOL fNoRemove)
  275. {
  276. RECT *rect = (RECT*)GetProp(hwnd, TEXT("omBrowserPopupRect"));
  277. if (FALSE == fNoRemove)
  278. {
  279. RemoveProp(hwnd, TEXT("omBrowserPopupRect"));
  280. }
  281. if (NULL == rect)
  282. return FALSE;
  283. if (NULL != rectOut)
  284. CopyRect(rectOut, rect);
  285. if (FALSE == fNoRemove)
  286. free(rect);
  287. return TRUE;
  288. }
  289. static BOOL BrowserPopup_ClientToFrame(HWND hwnd, RECT *rect)
  290. {
  291. if (NULL == rect) return FALSE;
  292. RECT frameRect, clientRect;
  293. ifc_window *wasabiWnd = (ifc_window*)SENDWAIPC(hwnd, IPC_SKINWINDOW_GETWASABIWND, 0);
  294. if (NULL != wasabiWnd)
  295. {
  296. ifc_window *wasabiParent = wasabiWnd->getDesktopParent();
  297. if (NULL == wasabiParent) wasabiParent = wasabiWnd;
  298. if (!wasabiParent->getWindowRect(&frameRect))
  299. return FALSE;
  300. wasabiWnd->getClientRect(&clientRect);
  301. MapWindowPoints(wasabiWnd->gethWnd(), HWND_DESKTOP, (POINT*)&clientRect, 2);
  302. }
  303. else
  304. {
  305. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  306. if (!GetWindowRect(hFrame, &frameRect) || !GetClientRect(hwnd, &clientRect))
  307. return FALSE;
  308. MapWindowPoints(hwnd, HWND_DESKTOP, (POINT*)&clientRect, 2);
  309. }
  310. rect->left += (frameRect.left - clientRect.left);
  311. rect->top += (frameRect.top - clientRect.top);
  312. rect->right += (frameRect.right - clientRect.right);
  313. rect->bottom += (frameRect.bottom - clientRect.bottom);
  314. return TRUE;
  315. }
  316. static INT CALLBACK BrowserPopup_FFCallback(embedWindowState *windowState, INT eventId, LPARAM param)
  317. {
  318. switch(eventId)
  319. {
  320. case FFC_CREATEEMBED:
  321. if(NULL != windowState && NULL != param)
  322. {
  323. RECT rect;
  324. if (BrowserPopup_PopRect(windowState->me, &rect, FALSE))
  325. {
  326. BrowserPopup_ClientToFrame(windowState->me, &rect);
  327. BrowserPopup_SetFramePos(windowState->me, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
  328. SWP_NOACTIVATE | SWP_NOZORDER);
  329. }
  330. }
  331. break;
  332. case FFC_DESTROYEMBED:
  333. if(NULL != windowState && NULL != param)
  334. {
  335. ifc_window *window = (ifc_window*)param;
  336. if (NULL != window)
  337. {
  338. RECT clientRect;
  339. window->getClientRect(&clientRect);
  340. MapWindowPoints(window->gethWnd(), HWND_DESKTOP, (POINT*)&clientRect, 2);
  341. BrowserPopup_PushRect(windowState->me, &clientRect, FALSE);
  342. }
  343. }
  344. break;
  345. }
  346. return 0;
  347. }
  348. static BOOL BrowserPopup_SkinWindow(HWND hwnd, const GUID *windowGuid)
  349. {
  350. GUID windowId;
  351. if (NULL == windowGuid || IsEqualGUID(*windowGuid, GUID_NULL))
  352. {
  353. static ULONG counter = 0L;
  354. windowId = SkinClass_BrowserPopup;
  355. windowId.Data1 += counter;
  356. counter++;
  357. }
  358. else
  359. CopyMemory(&windowId, windowGuid, sizeof(GUID));
  360. BrwoserPopup_PushClientRect(hwnd, FALSE);
  361. ifc_skinhelper *skinHelper;
  362. HRESULT hr = Plugin_GetSkinHelper(&skinHelper);
  363. if (SUCCEEDED(hr))
  364. {
  365. hr = skinHelper->SkinWindow(hwnd, &windowId, SWF_NOWINDOWMENU, BrowserPopup_FFCallback);
  366. if (SUCCEEDED(hr))
  367. {
  368. SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
  369. }
  370. skinHelper->Release();
  371. }
  372. return SUCCEEDED(hr);
  373. }
  374. static BOOL BrowserPopup_SwitchToFullscreen(HWND hwnd)
  375. {
  376. BROWSERPOPUP *popup = GetPopup(hwnd);
  377. if (NULL == popup) return FALSE;
  378. RECT clientRect;
  379. GetClientRect(hwnd, &clientRect);
  380. MapWindowPoints(hwnd, HWND_DESKTOP, (POINT*)&clientRect, 2);
  381. HMONITOR hMonitor = MonitorFromRect(&clientRect, MONITOR_DEFAULTTONEAREST);
  382. MONITORINFO mi;
  383. ZeroMemory(&mi, sizeof(MONITORINFO));
  384. mi.cbSize = sizeof(MONITORINFO);
  385. if (!GetMonitorInfo(hMonitor, &mi)) return FALSE;
  386. POPUPRESTORE *restore = popup->restore;
  387. if (NULL == restore)
  388. {
  389. restore = (POPUPRESTORE*)calloc(1, sizeof(POPUPRESTORE));
  390. if (NULL == restore) return FALSE;
  391. popup->restore = restore;
  392. }
  393. popup->flags |= BPF_MODECHANGELOCK;
  394. CopyRect(&restore->rect, &clientRect);
  395. restore->embedStyle = (UINT)SENDWAIPC(hwnd, IPC_SKINWINDOW_GETEXSTYLE, 0);
  396. restore->embedFlags = (UINT)SENDWAIPC(hwnd, IPC_SKINWINDOW_GETEMBEDFLAGS, 0);
  397. if (FALSE == SENDWAIPC(hwnd, IPC_SKINWINDOW_GETEMBEDFLAGS, &restore->embedGuid))
  398. ZeroMemory(&restore->embedGuid, sizeof(GUID));
  399. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  400. BOOL fTopmost = (NULL != hFrame && 0 != (WS_EX_TOPMOST & GetWindowStyleEx(hFrame)));
  401. SENDWAIPC(hwnd, IPC_SKINWINDOW_UNSKIN, 0);
  402. restore->hOwner = (HWND)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_HWNDPARENT);
  403. HWND hWinamp;
  404. if (FAILED(Plugin_GetWinampWnd(&hWinamp)))
  405. hWinamp = NULL;
  406. HWND hDlgParent = (HWND)SENDWAIPC(hWinamp, IPC_GETDIALOGBOXPARENT, 0);
  407. if (NULL != hDlgParent && restore->hOwner == hDlgParent)
  408. restore->hOwner = NULL;
  409. HWND hDesktop = GetDesktopWindow();
  410. SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONGX86)(LONG_PTR)hDesktop);
  411. DWORD style = GetWindowStyle(hwnd);
  412. restore->style = (FULLSCREEN_STYLE_FILTER & style);
  413. SetWindowLongPtr(hwnd, GWL_STYLE, style & ~FULLSCREEN_STYLE_FILTER);
  414. style = GetWindowStyleEx(hwnd);
  415. restore->exStyle = (FULLSCREEN_EXSTYLE_FILTER & style);
  416. SetWindowLongPtr(hwnd, GWL_EXSTYLE, style & ~FULLSCREEN_EXSTYLE_FILTER);
  417. if (FALSE == fTopmost)
  418. {
  419. SetWindowPos(hwnd, HWND_TOPMOST, mi.rcMonitor.left, mi.rcMonitor.top,
  420. mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOACTIVATE | SWP_FRAMECHANGED);
  421. SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW);
  422. }
  423. else
  424. {
  425. SetWindowPos(hwnd, HWND_TOPMOST, mi.rcMonitor.left, mi.rcMonitor.top,
  426. mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_FRAMECHANGED);
  427. }
  428. popup->flags &= ~BPF_MODECHANGELOCK;
  429. return TRUE;
  430. }
  431. static BOOL BrowserPopup_Restore(HWND hwnd)
  432. {
  433. BROWSERPOPUP *popup = GetPopup(hwnd);
  434. if (NULL == popup || NULL == popup->restore) return FALSE;
  435. POPUPRESTORE *restore = popup->restore;
  436. popup->restore = NULL;
  437. popup->flags |= BPF_MODECHANGELOCK;
  438. ShowWindow(hwnd, SW_HIDE);
  439. if (NULL == restore->hOwner)
  440. {
  441. HWND hWinamp;
  442. if (SUCCEEDED(Plugin_GetWinampWnd(&hWinamp)))
  443. {
  444. restore->hOwner = (HWND)SENDWAIPC(hWinamp, IPC_GETDIALOGBOXPARENT, 0);
  445. }
  446. }
  447. SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONGX86)(LONG_PTR)restore->hOwner);
  448. DWORD style;
  449. style = GetWindowStyleEx(hwnd);
  450. SetWindowLongPtr(hwnd, GWL_EXSTYLE, style | restore->exStyle);
  451. style = GetWindowStyle(hwnd);
  452. SetWindowLongPtr(hwnd, GWL_STYLE, style | restore->style);
  453. BrowserPopup_SkinWindow(hwnd, &restore->embedGuid);
  454. SENDWAIPC(hwnd, IPC_SKINWINDOW_SETEXSTYLE, restore->embedStyle);
  455. SENDWAIPC(hwnd, IPC_SKINWINDOW_SETEMBEDFLAGS, restore->embedFlags);
  456. BrowserPopup_PushRect(hwnd, &restore->rect, TRUE);
  457. BrowserPopup_ClientToFrame(hwnd, &restore->rect);
  458. SetWindowPos(hwnd, NULL, restore->rect.left, restore->rect.top,
  459. restore->rect.right - restore->rect.left, restore->rect.bottom - restore->rect.top, SWP_NOACTIVATE | SWP_NOZORDER);
  460. popup->flags &= ~BPF_MODECHANGELOCK;
  461. ShowWindow(hwnd, SW_SHOWNA);
  462. BrowserPopup_ActivateFrame(hwnd);
  463. free(restore);
  464. return TRUE;
  465. }
  466. static void BrowserPopup_CloseWindow(HWND hwnd)
  467. {
  468. POINT pt;
  469. GetCursorPos(&pt);
  470. SendMessage(hwnd, WM_SYSCOMMAND, (WPARAM)SC_CLOSE, MAKELPARAM(pt.x, pt.y));
  471. }
  472. static BOOL BrowserPopup_SetStatusText(HWND hwnd, LPCWSTR pszText)
  473. {
  474. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  475. if (NULL == hStatusbar) return FALSE;
  476. Statusbar_Update(hStatusbar, pszText);
  477. return TRUE;
  478. }
  479. static BOOL BrowserPopup_SetStatusTextRes(HWND hwnd, LPCWSTR pszText)
  480. {
  481. if (NULL != pszText && IS_INTRESOURCE(pszText))
  482. {
  483. WCHAR szBuffer[512] = {0};
  484. pszText = Plugin_LoadString((INT)(INT_PTR)pszText, szBuffer, ARRAYSIZE(szBuffer));
  485. }
  486. return BrowserPopup_SetStatusText(hwnd, pszText);
  487. }
  488. static BOOL BrowserPopup_ToggleFullscreen(HWND hwnd)
  489. {
  490. BROWSERPOPUP *popup = GetPopup(hwnd);
  491. if (NULL == popup) return FALSE;
  492. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  493. if (NULL == hBrowser) return FALSE;
  494. UINT embedFlags = 0;
  495. if (0 == (NBCS_EX_FULLSCREEN & popup->extendedStyle))
  496. {
  497. UINT windowStyle = GetWindowStyle(hwnd);
  498. if (0 != (NBCS_DISABLEFULLSCREEN & windowStyle))
  499. return FALSE;
  500. embedFlags = (UINT)SENDWAIPC(hwnd, IPC_SKINWINDOW_GETEMBEDFLAGS, 0);
  501. }
  502. else
  503. {
  504. BROWSERPOPUP *popup = GetPopup(hwnd);
  505. if (NULL != popup && NULL != popup->restore)
  506. embedFlags = popup->restore->embedFlags;
  507. }
  508. if (0 != (SWF_NORESIZE & embedFlags))
  509. return FALSE;
  510. return PostMessage(hBrowser, NBHM_TOGGLEFULLSCREEN, 0, 0L);
  511. }
  512. static void BrowserPopup_RegisterUiHook(HWND hwnd)
  513. {
  514. BROWSERPOPUP *popup = GetPopup(hwnd);
  515. if (NULL == popup || NULL != popup->browserHook) return;
  516. if (FAILED(BrowserUiHook::CreateInstance(hwnd, TRUE, &popup->browserHook)))
  517. return;
  518. popup->browserHook->Register(popup->browserManager, popup->service);
  519. }
  520. static LRESULT BrowserPopup_OnCreate(HWND hwnd, CREATESTRUCT *pcs)
  521. {
  522. BROWSERPOPUPCREATEPARAM *createParam = (BROWSERPOPUPCREATEPARAM*)pcs->lpCreateParams;
  523. BROWSERPOPUP *popup = (BROWSERPOPUP*)calloc(1, sizeof(BROWSERPOPUP));
  524. if (NULL != popup)
  525. {
  526. SetLastError(ERROR_SUCCESS);
  527. if (!SetWindowLongPtr(hwnd, 0, (LONGX86)(LONG_PTR)popup) && ERROR_SUCCESS != GetLastError())
  528. {
  529. free(popup);
  530. popup = NULL;
  531. }
  532. }
  533. if (NULL == popup)
  534. {
  535. DestroyWindow(hwnd);
  536. return -1;
  537. }
  538. if (NULL != createParam)
  539. {
  540. popup->browserManager = createParam->browserManager;
  541. if (NULL != popup->browserManager)
  542. popup->browserManager->AddRef();
  543. popup->service = createParam->service;
  544. if (NULL != popup->service)
  545. popup->service->AddRef();
  546. popup->callback = createParam->callback;
  547. popup->callbackParam = createParam->callbackParam;
  548. popup->hOwner = createParam->hOwner;
  549. }
  550. BrowserPopup_RegisterUiHook(hwnd);
  551. SendMessage(hwnd, WM_CHANGEUISTATE, MAKEWPARAM(UIS_SET, UISF_HIDEACCEL | UISF_HIDEFOCUS), 0L);
  552. HWND hToolbar = BrowserPopup_CreateToolbar(hwnd);
  553. HWND hStatusbar = BrowserPopup_CreateStatusbar(hwnd);
  554. RECT clientRect;
  555. GetClientRect(hwnd, &clientRect);
  556. UINT hostStyle = NBHS_POPUP;
  557. if (0 != (NBCS_DISABLECONTEXTMENU & pcs->style)) hostStyle |= NBHS_DISABLECONTEXTMENU;
  558. if (0 != (NBCS_DIALOGMODE & pcs->style)) hostStyle |= NBHS_DIALOGMODE;
  559. if (0 != (NBCS_DISABLEHOSTCSS & pcs->style)) hostStyle |= NBHS_DISABLEHOSTCSS;
  560. HACCEL hAccel = BrowserControl_GetAccelTable(ACCELTABLE_POPUP);
  561. HWND hHost = BrowserHost_CreateWindow(popup->browserManager, hwnd, hostStyle, clientRect.left, clientRect.top,
  562. clientRect.right - clientRect.left, clientRect.bottom - clientRect.top, IDC_BROWSER, hAccel);
  563. if (NULL == hHost)
  564. {
  565. DestroyWindow(hwnd);
  566. return -1;
  567. }
  568. if (NULL != hToolbar)
  569. {
  570. Toolbar_SetBrowserHost(hToolbar, hHost);
  571. }
  572. if (NULL != hStatusbar)
  573. {
  574. Statusbar_SetBrowserHost(hStatusbar, hHost);
  575. Statusbar_SetActive(hStatusbar, (0 == (WS_DISABLED & GetWindowLongPtr(hStatusbar, GWL_STYLE))));
  576. }
  577. ifc_wasabihelper *wasabiHelper;
  578. if (SUCCEEDED(Plugin_GetWasabiHelper(&wasabiHelper)))
  579. {
  580. api_application *app;
  581. if (SUCCEEDED(wasabiHelper->GetApplicationApi(&app)))
  582. {
  583. app->app_registerGlobalWindow(hwnd);
  584. if (NULL != hAccel)
  585. app->app_addAccelerators(hwnd, &hAccel, 1, TRANSLATE_MODE_CHILD);
  586. app->Release();
  587. }
  588. wasabiHelper->Release();
  589. }
  590. BrowserPopup_UpdateTitle(hwnd, NULL);
  591. BrowserPopup_SkinWindow(hwnd, NULL);
  592. if (NULL != popup->browserManager)
  593. {
  594. ifc_ombrowserwndmngr *windowManager;
  595. if (SUCCEEDED(popup->browserManager->QueryInterface(IFC_OmBrowserWindowManager, (void**)&windowManager)))
  596. {
  597. windowManager->RegisterWindow(hwnd, &WTID_BrowserPopup);
  598. windowManager->Release();
  599. }
  600. ifc_ombrowsereventmngr *eventManager;
  601. if (SUCCEEDED(popup->browserManager->QueryInterface(IFC_OmBrowserEventManager, (void**)&eventManager)))
  602. {
  603. eventManager->Signal_WindowCreate(hwnd, &WTID_BrowserPopup);
  604. eventManager->Release();
  605. }
  606. }
  607. return 0;
  608. }
  609. static void BrowserPopup_OnDestroy(HWND hwnd)
  610. {
  611. BROWSERPOPUP *popup = GetPopup(hwnd);
  612. SetWindowLongPtr(hwnd, 0, 0L);
  613. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  614. if (NULL != hBrowser)
  615. {
  616. DWORD browserStyle = GetWindowStyle(hBrowser);
  617. if (0 != (WS_VISIBLE & browserStyle))
  618. SetWindowLongPtr(hBrowser, GWL_STYLE, browserStyle & ~WS_VISIBLE);
  619. HWND hWinamp = NULL;
  620. if (Plugin_GetWinampWnd(&hWinamp))
  621. hWinamp = NULL;
  622. SetWindowLongPtr(hBrowser, GWLP_HWNDPARENT, (LONGX86)(LONG_PTR)hWinamp);
  623. if (NULL == popup || NULL == popup->browserManager ||
  624. S_OK == popup->browserManager->IsFinishing() ||
  625. 0 == PostMessage(hBrowser, NBHM_DESTROY, 0, 0L))
  626. {
  627. DWORD_PTR result;
  628. SendMessageTimeout(hBrowser, NBHM_DESTROY, TRUE, 0L, SMTO_NOTIMEOUTIFNOTHUNG | SMTO_BLOCK, 500, &result);
  629. }
  630. }
  631. BrowserPopup_PopRect(hwnd, NULL, FALSE);
  632. if (NULL != popup)
  633. {
  634. popup->extendedStyle &= ~(NBCS_EX_BROWSERREADY | NBCS_EX_NAVCOMPLETED);
  635. popup->extendedStyle |= NBCS_EX_BLOCKNAVIGATION;
  636. if (NULL != popup->browserHook)
  637. {
  638. popup->browserHook->Unregister(popup->browserManager, popup->service);
  639. popup->browserHook->Release();
  640. }
  641. if (NULL != popup->service)
  642. {
  643. popup->service->Release();
  644. popup->service = NULL;
  645. }
  646. if (NULL != popup->restore)
  647. {
  648. free(popup->restore);
  649. }
  650. Plugin_FreeResString(popup->storedUrl);
  651. popup->storedUrl = NULL;
  652. SysFreeString(popup->storedData);
  653. popup->storedData = NULL;
  654. if (NULL != popup->browserManager)
  655. {
  656. ifc_ombrowserwndmngr *windowManager;
  657. if (SUCCEEDED(popup->browserManager->QueryInterface(IFC_OmBrowserWindowManager, (void**)&windowManager)))
  658. {
  659. windowManager->UnregisterWindow(hwnd);
  660. windowManager->Release();
  661. }
  662. ifc_ombrowsereventmngr *eventManager = NULL;
  663. if (SUCCEEDED(popup->browserManager->QueryInterface(IFC_OmBrowserEventManager, (void**)&eventManager)))
  664. {
  665. eventManager->Signal_WindowClose(hwnd, &WTID_BrowserPopup);
  666. eventManager->Release();
  667. }
  668. popup->browserManager->Release();
  669. popup->browserManager = NULL;
  670. }
  671. free(popup);
  672. }
  673. ifc_wasabihelper *wasabiHelper = NULL;
  674. if (SUCCEEDED(Plugin_GetWasabiHelper(&wasabiHelper)))
  675. {
  676. api_application *app;
  677. if (SUCCEEDED(wasabiHelper->GetApplicationApi(&app)))
  678. {
  679. app->app_unregisterGlobalWindow(hwnd);
  680. app->app_removeAccelerators(hwnd);
  681. app->Release();
  682. }
  683. wasabiHelper->Release();
  684. }
  685. }
  686. static void BrowserPopup_OnPaint(HWND hwnd)
  687. {
  688. PAINTSTRUCT ps;
  689. if (BeginPaint(hwnd, &ps))
  690. {
  691. if (ps.rcPaint.left != ps.rcPaint.right)
  692. BrowserPopup_Paint(hwnd, ps.hdc, &ps.rcPaint, ps.fErase);
  693. EndPaint(hwnd, &ps);
  694. }
  695. }
  696. static void BrowserPopup_OnPrintClient(HWND hwnd, HDC hdc, UINT options)
  697. {
  698. RECT clientRect;
  699. if (GetClientRect(hwnd, &clientRect))
  700. BrowserPopup_Paint(hwnd, hdc, &clientRect, 0 != (PRF_ERASEBKGND & options));
  701. }
  702. static void BrowserPopup_OnWindowPosChanging(HWND hwnd, WINDOWPOS *pwp)
  703. {
  704. BROWSERPOPUP *popup = GetPopup(hwnd);
  705. if (NULL != popup && 0 != (BPF_LOCKRESIZE & popup->flags))
  706. {
  707. HWND hWinamp = NULL;
  708. if (FAILED(Plugin_GetWinampWnd(&hWinamp)))
  709. hWinamp = NULL;
  710. if (NULL != hWinamp && hWinamp == (HWND)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_HWNDPARENT))
  711. {
  712. RECT rect;
  713. if (BrowserPopup_PopRect(hwnd, &rect, TRUE))
  714. {
  715. BrowserPopup_ClientToFrame(hwnd, &rect);
  716. pwp->x = rect.left;
  717. pwp->y = rect.top;
  718. pwp->cx = rect.right - rect.left;
  719. pwp->cy = rect.bottom - rect.top;
  720. }
  721. }
  722. }
  723. }
  724. static void BrowserPopup_OnWindowPosChanged(HWND hwnd, WINDOWPOS *pwp)
  725. {
  726. if (SWP_NOSIZE == ((SWP_NOSIZE | SWP_FRAMECHANGED) & pwp->flags))
  727. return;
  728. BROWSERPOPUP *popup = GetPopup(hwnd);
  729. if (NULL != popup)
  730. {
  731. BrowserControl_UpdateLayout(hwnd, 0 == (SWP_NOREDRAW & pwp->flags),
  732. 0 != (SWP_FRAMECHANGED & pwp->flags), NULL, NULL);
  733. }
  734. }
  735. static void BrowserPopup_OnCommand(HWND hwnd, INT commandId, INT eventId, HWND hControl)
  736. {
  737. switch(commandId)
  738. {
  739. case IDC_TOOLBAR: BrowserControl_ProcessToolbarCommand(hwnd, eventId); break;
  740. case IDC_STATUSBAR: BrowserControl_ProcessStatusbarCommand(hwnd, eventId); break;
  741. default:
  742. if (FALSE == BrowserControl_ProcessCommonCommand(hwnd, commandId))
  743. {
  744. switch(commandId)
  745. {
  746. case ID_WINDOW_CLOSE: BrowserPopup_CloseWindow(hwnd); break;
  747. case ID_WINDOW_FULLSCREEN: BrowserPopup_ToggleFullscreen(hwnd); break;
  748. }
  749. }
  750. break;
  751. }
  752. }
  753. static LRESULT BrowserPopup_OnAppCommand(HWND hwnd, HWND hTarget, INT commandId, INT deviceId, INT keys)
  754. {
  755. return BrowserControl_ProcessAppCommand(hwnd, commandId);
  756. }
  757. static void BrowserPopup_OnBrowserReady(HWND hwnd)
  758. {
  759. ReplyMessage(0);
  760. BROWSERPOPUP *popup = GetPopup(hwnd);
  761. if (NULL == popup) return;
  762. popup->extendedStyle |= NBCS_EX_BROWSERREADY;
  763. BrowserControl_UpdateLayout(hwnd, FALSE, FALSE, NULL, NULL);
  764. HWND hToolbar = BrowserControl_GetToolbar(hwnd);
  765. if (NULL != hToolbar)
  766. Toolbar_EnableItem(hToolbar, TOOLITEM_ADDRESSBAR, TRUE);
  767. if (NULL != popup->callback)
  768. {
  769. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  770. if (NULL == hBrowser ||
  771. FALSE == PostMessage(hBrowser, NBHM_GETDISPATCHAPC, (WPARAM)popup->callbackParam, (LPARAM)popup->callback))
  772. {
  773. // sucks
  774. popup->callback(NULL, popup->callbackParam);
  775. }
  776. popup->callback = NULL;
  777. return;
  778. }
  779. if (NULL != popup->storedUrl)
  780. {
  781. LPWSTR pszUrl = popup->storedUrl;
  782. popup->storedUrl = NULL;
  783. BrowserPopup_Navigate(hwnd, pszUrl, TRUE);
  784. Plugin_FreeResString(pszUrl);
  785. }
  786. else
  787. {
  788. BrowserPopup_NavigateHome(hwnd, TRUE);
  789. }
  790. }
  791. static void CALLBACK BrowserPopup_ActivateTimer(HWND hwnd, UINT uMsg, UINT_PTR eventId, DWORD time)
  792. {
  793. KillTimer(hwnd, eventId);
  794. BROWSERPOPUP *popup = GetPopup(hwnd);
  795. if (NULL == popup) return;
  796. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  797. if (NULL != hFrame)
  798. {
  799. DWORD frameStyle = GetWindowStyleEx(hFrame);
  800. if (0 != (WS_EX_TOPMOST & frameStyle) && 0 != (BPF_FORCEDTOPMOST & popup->flags))
  801. {
  802. popup->flags &= ~BPF_FORCEDTOPMOST;
  803. SetWindowPos(hFrame, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE| SWP_NOMOVE | SWP_NOOWNERZORDER);
  804. }
  805. SetWindowPos(hFrame, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE| SWP_NOMOVE | SWP_NOOWNERZORDER);
  806. }
  807. PostMessage(hwnd, NBPM_ACTIVATEFRAME, 0, 0L);
  808. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  809. if (NULL != hBrowser)
  810. PostMessage(hBrowser, NBHM_ACTIVATE, 0, 0L);
  811. }
  812. static void BrowserPopup_OnNavigateComplete(HWND hwnd, IDispatch *pDispath, VARIANT *URL, BOOL fTopFrame)
  813. {
  814. if (FALSE == fTopFrame)
  815. return;
  816. BROWSERPOPUP *popup = GetPopup(hwnd);
  817. if (NULL == popup) return;
  818. popup->extendedStyle |= NBCS_EX_NAVIGATEDONCE;
  819. LPWSTR pszUrl = NULL;
  820. if (NULL != URL && VT_BSTR == URL->vt && NULL != URL->bstrVal)
  821. pszUrl = Plugin_CopyString(URL->bstrVal);
  822. ReplyMessage(0);
  823. if (NULL != pszUrl)
  824. {
  825. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  826. if (NULL != hToolbar)
  827. {
  828. INT itemId = Toolbar_FindItem(hToolbar, TOOLITEM_ADDRESSBAR);
  829. if (ITEM_ERR != itemId)
  830. Toolbar_SetItemString(hToolbar, MAKEINTRESOURCE(itemId), pszUrl);
  831. }
  832. Plugin_FreeString(pszUrl);
  833. }
  834. }
  835. static void BrowserPopup_OnDocumentReady(HWND hwnd, IDispatch *pDispath, VARIANT *URL, BOOL fTopFrame)
  836. {
  837. ReplyMessage(0);
  838. BROWSERPOPUP *popup = GetPopup(hwnd);
  839. if (NULL == popup) return;
  840. if (0 == (NBCS_EX_NAVCOMPLETED & popup->extendedStyle))
  841. {
  842. popup->extendedStyle |= NBCS_EX_NAVCOMPLETED;
  843. BROWSERPOPUP *popup = GetPopup(hwnd);
  844. if (NULL != popup && NULL != popup->storedData)
  845. {
  846. BrowserPopup_WriteDocument(hwnd, popup->storedData, FALSE);
  847. }
  848. if(0 == (NBCS_EX_SCRIPTMODE & popup->extendedStyle))
  849. {
  850. HWND hHost = GetDlgItem(hwnd, IDC_BROWSER);
  851. if (NULL != hHost &&
  852. 0 == (WS_VISIBLE & GetWindowLongPtr(hHost, GWL_STYLE)))
  853. {
  854. ShowWindowAsync(hHost, SW_SHOWNA);
  855. }
  856. }
  857. }
  858. }
  859. static void BrowserPopup_OnBrowserActive(HWND hwnd, BOOL fActive)
  860. {
  861. ReplyMessage(0);
  862. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  863. if (NULL != hToolbar)
  864. {
  865. Toolbar_EnableItem(hToolbar, TOOLITEM_DOWNLOADPROGRESS, fActive);
  866. }
  867. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  868. if (NULL != hStatusbar)
  869. {
  870. if (FALSE != fActive && (0 != (WS_DISABLED & GetWindowLongPtr(hStatusbar, GWL_STYLE))))
  871. fActive = FALSE;
  872. Statusbar_SetActive(hStatusbar, fActive);
  873. }
  874. }
  875. static void BrowserPopup_OnCommandStateChange(HWND hwnd, UINT commandId, BOOL fEnable)
  876. {
  877. ReplyMessage(0);
  878. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  879. if (NULL != hToolbar)
  880. {
  881. switch(commandId)
  882. {
  883. case Browser::commandBack:
  884. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_BACK, fEnable);
  885. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_HISTORY, (FALSE != fEnable) ?
  886. TRUE :
  887. (0 == Toolbar_GetItemStyle(hToolbar, TOOLITEM_BUTTON_FORWARD, TBIS_DISABLED)));
  888. break;
  889. case Browser::commandForward:
  890. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_FORWARD, fEnable);
  891. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_HISTORY, (FALSE != fEnable) ?
  892. TRUE :
  893. (0 == Toolbar_GetItemStyle(hToolbar, TOOLITEM_BUTTON_BACK, TBIS_DISABLED)));
  894. break;
  895. case Browser::commandStop: Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_STOP, fEnable); break;
  896. case Browser::commandRefresh:
  897. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_REFRESH, fEnable);
  898. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_HOME, fEnable);
  899. break;
  900. }
  901. }
  902. }
  903. static void BrowserPopup_OnStatusChange(HWND hwnd, LPCWSTR pszText)
  904. {
  905. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  906. if (NULL == hStatusbar) return;
  907. WCHAR szBuffer[512] = {0};
  908. if (NULL == pszText || L'\0' == *pszText) szBuffer[0] = L'\0';
  909. else StringCchCopy(szBuffer, ARRAYSIZE(szBuffer), pszText);
  910. ReplyMessage(0);
  911. Statusbar_Update(hStatusbar, szBuffer);
  912. }
  913. static void BrowserPopup_OnTitleChange(HWND hwnd, LPCWSTR pszText)
  914. {
  915. WCHAR szBuffer[256] = {0};
  916. if (NULL == pszText || L'\0' == *pszText) szBuffer[0] = L'\0';
  917. else StringCchCopy(szBuffer, ARRAYSIZE(szBuffer), pszText);
  918. ReplyMessage(0);
  919. BrowserPopup_UpdateTitle(hwnd, szBuffer);
  920. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  921. if (NULL != hToolbar)
  922. {
  923. INT itemId = Toolbar_FindItem(hToolbar, TOOLITEM_ADDRESSBAR);
  924. if (ITEM_ERR != itemId)
  925. Toolbar_SetItemDescription(hToolbar, MAKEINTRESOURCE(itemId), szBuffer);
  926. }
  927. }
  928. static void BrowserPopup_OnSecureIconChange(HWND hwnd, UINT iconId)
  929. {
  930. ReplyMessage(0);
  931. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  932. if (NULL != hToolbar)
  933. {
  934. INT itemId = Toolbar_FindItem(hToolbar, TOOLITEM_BUTTON_SECURECONNECTION);
  935. if (ITEM_ERR != itemId)
  936. {
  937. WCHAR szBuffer[256] = {0};
  938. if(FAILED(FormatEncryptionString(iconId, szBuffer, ARRAYSIZE(szBuffer))))
  939. szBuffer[0] = L'\0';
  940. Toolbar_ShowItem(hToolbar, MAKEINTRESOURCE(itemId), (secureLockIconUnsecure != iconId));
  941. Toolbar_SetItemDescription(hToolbar, MAKEINTRESOURCE(itemId), szBuffer);
  942. }
  943. }
  944. }
  945. static LRESULT BrowserPopup_OnCreatePopup(HWND hwnd, DISPATCHAPC callback, ULONG_PTR param)
  946. {
  947. ReplyMessage(TRUE);
  948. HWND hPopup = NULL;
  949. UINT windowStyle = GetWindowStyle(hwnd);
  950. if (0 == (NBCS_BLOCKPOPUP & windowStyle))
  951. {
  952. BROWSERPOPUP *popup = GetPopup(hwnd);
  953. if (NULL != popup)
  954. {
  955. RECT windowRect;
  956. GetWindowRect(hwnd, &windowRect);
  957. UINT popupStyle = NBCS_NOSERVICECOMMANDS | NBCS_DISABLEHOSTCSS;
  958. popupStyle |= (NBCS_POPUPOWNER & GetWindowStyle(hwnd));
  959. HWND hOwner = NULL;
  960. if (0 != (NBCS_POPUPOWNER & popupStyle))
  961. hOwner = popup->hOwner;
  962. hPopup = BrowserPopup_Create(popup->browserManager, popup->service, popupStyle,
  963. windowRect.left + 12, windowRect.top + 12, 640, 480, hOwner, callback, param);
  964. }
  965. }
  966. if (NULL == hPopup)
  967. {
  968. if (NULL != callback)
  969. callback(NULL, param);
  970. return FALSE;
  971. }
  972. BrowserControl_SetExtendedStyle(hPopup, NBCS_EX_SCRIPTMODE, NBCS_EX_SCRIPTMODE);
  973. BrowserPopup_UpdateSkin(hPopup, FALSE);
  974. return TRUE;
  975. }
  976. static void BrowserPopup_OnVisibleChange(HWND hwnd, BOOL fVisible)
  977. {
  978. ReplyMessage(0);
  979. BROWSERPOPUP *popup = GetPopup(hwnd);
  980. if (NULL == popup) return;
  981. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  982. if (NULL == hFrame) hFrame = hwnd;
  983. if (FALSE != fVisible)
  984. {
  985. ShowWindow(hFrame, (0 == (WS_VISIBLE & GetWindowLongPtr(hFrame, GWL_STYLE))) ? SW_SHOWNOACTIVATE : SW_SHOW);
  986. HWND hWinamp;
  987. if (FAILED(Plugin_GetWinampWnd(&hWinamp)))
  988. hWinamp = NULL;
  989. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  990. HWND hDlgParent = (HWND)SENDWAIPC(hWinamp, IPC_GETDIALOGBOXPARENT, 0);
  991. if (NULL != hFrame && NULL != hDlgParent && hFrame != hDlgParent)
  992. {
  993. DWORD frameStyle = GetWindowStyleEx(hFrame);
  994. if (0 == (WS_EX_TOPMOST & frameStyle))
  995. {
  996. popup->flags |= BPF_FORCEDTOPMOST;
  997. SetWindowPos(hFrame, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE| SWP_NOMOVE | SWP_NOOWNERZORDER);
  998. }
  999. SetWindowPos(hFrame, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE| SWP_NOMOVE | SWP_NOOWNERZORDER);
  1000. }
  1001. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  1002. if (NULL != hBrowser)
  1003. {
  1004. ShowWindowAsync(hBrowser, SW_SHOWNA);
  1005. }
  1006. SetTimer(hwnd, BPT_ACTIVATEFRAME, BPT_ACTIVATEFRAME_DELAY, BrowserPopup_ActivateTimer);
  1007. }
  1008. else
  1009. {
  1010. ShowWindow(hFrame, SW_HIDE);
  1011. }
  1012. }
  1013. static void BrowserPopup_OnSetResizable(HWND hwnd, BOOL fEnabled)
  1014. {
  1015. ReplyMessage(0);
  1016. UINT flags = (UINT)SENDWAIPC(hwnd, IPC_SKINWINDOW_GETEMBEDFLAGS, 0);
  1017. if ((0 != (SWF_NORESIZE & flags)) != (FALSE == fEnabled))
  1018. {
  1019. if (FALSE == fEnabled) flags |= SWF_NORESIZE;
  1020. else flags &= ~EMBED_FLAGS_NORESIZE;
  1021. SENDWAIPC(hwnd, IPC_SKINWINDOW_SETEMBEDFLAGS, (WPARAM)flags);
  1022. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  1023. if (NULL != hFrame)
  1024. {
  1025. SetWindowPos(hFrame, NULL, 0, 0, 0, 0,
  1026. SWP_NOSIZE | SWP_NOMOVE| SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
  1027. }
  1028. }
  1029. }
  1030. static void BrowserPopup_OnBrowserClosing(HWND hwnd, BOOL isChild, BOOL *fCancel)
  1031. {
  1032. // we telling ie to cancel in order to skip user prompt
  1033. *fCancel = TRUE;
  1034. ReplyMessage(0);
  1035. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  1036. if (NULL != hFrame)
  1037. {
  1038. ShowWindow(hFrame, SW_HIDE);
  1039. DestroyWindow(hFrame);
  1040. }
  1041. }
  1042. static void BrowserPopup_OnShowUiElement(HWND hwnd, UINT elementId, BOOL fShow)
  1043. {
  1044. ReplyMessage(0);
  1045. HWND hControl;
  1046. UINT fStyle = GetWindowStyle(hwnd);
  1047. switch(elementId)
  1048. {
  1049. case HTMLContainer2::uiToolbar:
  1050. hControl = GetDlgItem(hwnd, IDC_TOOLBAR);
  1051. if (NULL != hControl && 0 == (NBCS_NOTOOLBAR & fStyle))
  1052. {
  1053. ShowWindow(hControl, (FALSE != fShow) ? SW_SHOW : SW_HIDE);
  1054. BrowserControl_UpdateLayout(hwnd, TRUE, FALSE, NULL, NULL);
  1055. }
  1056. break;
  1057. case HTMLContainer2::uiStatusbar:
  1058. hControl = GetDlgItem(hwnd, IDC_STATUSBAR);
  1059. if (NULL != hControl && 0 == (NBCS_NOSTATUSBAR & fStyle))
  1060. {
  1061. EnableWindow(hControl, fShow);
  1062. BrowserControl_UpdateLayout(hwnd, TRUE, FALSE, NULL, NULL);
  1063. }
  1064. break;
  1065. }
  1066. }
  1067. static void BrowserPopup_OnClientToHost(HWND hwnd, LONG *cx, LONG *cy)
  1068. {
  1069. RECT frameRect, browserRect;
  1070. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  1071. if (NULL == hFrame || !GetWindowRect(hFrame, &frameRect))
  1072. return;
  1073. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  1074. if (NULL == hBrowser || !GetClientRect(hBrowser, &browserRect))
  1075. return;
  1076. *cx += ((frameRect.right - frameRect.left) - (browserRect.right - browserRect.left));
  1077. *cy += ((frameRect.bottom - frameRect.top) - (browserRect.bottom - browserRect.top));
  1078. }
  1079. static void BrowserPopup_OnSetWindowPos(HWND hwnd, UINT flags, LONG x, LONG y, LONG cx, LONG cy)
  1080. {
  1081. ReplyMessage(0);
  1082. RECT frameRect;
  1083. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  1084. if (NULL == hFrame || !GetWindowRect(hFrame, &frameRect)) return;
  1085. UINT swpFlags = SWP_NOACTIVATE | SWP_NOZORDER;
  1086. if (0 == ((HTMLContainer2::wndLeft | HTMLContainer2::wndTop) & flags))
  1087. {
  1088. swpFlags |= SWP_NOMOVE;
  1089. }
  1090. else
  1091. {
  1092. if (0 == (HTMLContainer2::wndLeft & flags)) x = frameRect.left;
  1093. else if (0 != (HTMLContainer2::wndRelative & flags)) x += frameRect.left;
  1094. if (0 == (HTMLContainer2::wndTop & flags)) y = frameRect.top;
  1095. else if (0 != (HTMLContainer2::wndRelative & flags)) y += frameRect.top;
  1096. }
  1097. if (0 == ((HTMLContainer2::wndWidth | HTMLContainer2::wndHeight) & flags))
  1098. {
  1099. swpFlags |= SWP_NOSIZE;
  1100. }
  1101. else
  1102. {
  1103. if (0 == (HTMLContainer2::wndWidth & flags)) cx = (frameRect.right - frameRect.left);
  1104. else if (0 != (HTMLContainer2::wndRelative & flags)) cx += (frameRect.right - frameRect.left);
  1105. if (0 == (HTMLContainer2::wndHeight & flags)) cy = (frameRect.bottom - frameRect.top);
  1106. else if (0 != (HTMLContainer2::wndRelative & flags)) cy += (frameRect.bottom - frameRect.top);
  1107. }
  1108. BrowserPopup_SetFramePos(hwnd, NULL, x, y, cx, cy, swpFlags);
  1109. }
  1110. static void BrowserPopup_OnAllowFocusChange(HWND hwnd, BOOL *fAllow)
  1111. {
  1112. *fAllow = TRUE;
  1113. }
  1114. static void BrowserPopup_OnSetFullscreen(HWND hwnd, BOOL fEnable)
  1115. {
  1116. BROWSERPOPUP *popup = GetPopup(hwnd);
  1117. if (NULL == popup) return;
  1118. if (0 != (NBCS_EX_FULLSCREEN & popup->extendedStyle) == (FALSE != fEnable))
  1119. return;
  1120. if (FALSE == fEnable)
  1121. popup->extendedStyle &= ~NBCS_EX_FULLSCREEN;
  1122. else
  1123. {
  1124. UINT windowStyle = GetWindowStyle(hwnd);
  1125. if (0 != (NBCS_DISABLEFULLSCREEN & windowStyle))
  1126. return;
  1127. popup->extendedStyle |= NBCS_EX_FULLSCREEN;
  1128. }
  1129. SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
  1130. }
  1131. static void BrowserPopup_OnClosePopup(HWND hwnd)
  1132. {
  1133. ReplyMessage(0);
  1134. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  1135. if (NULL != hFrame)
  1136. {
  1137. ShowWindow(hFrame, SW_HIDE);
  1138. DestroyWindow(hFrame);
  1139. }
  1140. }
  1141. static LRESULT BrowserPopup_OnBrowserNotify(HWND hwnd, NMHDR *pnmh)
  1142. {
  1143. switch(pnmh->code)
  1144. {
  1145. case NBHN_READY:
  1146. BrowserPopup_OnBrowserReady(hwnd);
  1147. break;
  1148. case NBHN_NAVIGATECOMPLETE:
  1149. BrowserPopup_OnNavigateComplete(hwnd, ((BHNNAVCOMPLETE*)pnmh)->pDispatch, ((BHNNAVCOMPLETE*)pnmh)->URL, ((BHNNAVCOMPLETE*)pnmh)->fTopFrame);
  1150. break;
  1151. case NBHN_DOCUMENTREADY:
  1152. BrowserPopup_OnDocumentReady(hwnd, ((BHNNAVCOMPLETE*)pnmh)->pDispatch, ((BHNNAVCOMPLETE*)pnmh)->URL, ((BHNNAVCOMPLETE*)pnmh)->fTopFrame);
  1153. break;
  1154. case NBHN_BROWSERACTIVE:
  1155. BrowserPopup_OnBrowserActive(hwnd, ((BHNACTIVE*)pnmh)->fActive);
  1156. break;
  1157. case NBHN_COMMANDSTATECHANGE:
  1158. BrowserPopup_OnCommandStateChange(hwnd, ((BHNCMDSTATE*)pnmh)->commandId, ((BHNCMDSTATE*)pnmh)->fEnabled);
  1159. break;
  1160. case NBHN_STATUSCHANGE:
  1161. BrowserPopup_OnStatusChange(hwnd, ((BHNTEXTCHANGE*)pnmh)->pszText);
  1162. break;
  1163. case NBHN_TITLECHANGE:
  1164. BrowserPopup_OnTitleChange(hwnd, ((BHNTEXTCHANGE*)pnmh)->pszText);
  1165. break;
  1166. case NBHN_SECUREICONCHANGE:
  1167. BrowserPopup_OnSecureIconChange(hwnd, ((BHNSECUREICON*)pnmh)->iconId);
  1168. break;
  1169. case NBHN_GETOMSERVICE:
  1170. return BrowserPopup_GetService(hwnd, &((BHNSERVICE*)pnmh)->instance);
  1171. case NBHN_CREATEPOPUP:
  1172. return BrowserPopup_OnCreatePopup(hwnd, ((BHNCREATEPOPUP*)pnmh)->callback, ((BHNCREATEPOPUP*)pnmh)->param);
  1173. case NBHN_VISIBLECHANGE:
  1174. BrowserPopup_OnVisibleChange(hwnd, ((BHNVISIBLE*)pnmh)->fVisible);
  1175. break;
  1176. case NBHN_RESIZABLE:
  1177. BrowserPopup_OnSetResizable(hwnd, ((BHNRESIZABLE*)pnmh)->fEnabled);
  1178. break;
  1179. case NBHN_CLOSING:
  1180. BrowserPopup_OnBrowserClosing(hwnd, ((BHNCLOSING*)pnmh)->isChild, &((BHNCLOSING*)pnmh)->cancel);
  1181. break;
  1182. case NBHN_SHOWUI:
  1183. BrowserPopup_OnShowUiElement(hwnd, ((BHNSHOWUI*)pnmh)->elementId, ((BHNSHOWUI*)pnmh)->fShow);
  1184. break;
  1185. case NBHN_CLIENTTOHOST:
  1186. BrowserPopup_OnClientToHost(hwnd, &((BHNCLIENTTOHOST*)pnmh)->cx, &((BHNCLIENTTOHOST*)pnmh)->cy);
  1187. break;
  1188. case NBHN_SETWINDOWPOS:
  1189. BrowserPopup_OnSetWindowPos(hwnd, ((BHNSETWINDOWPOS*)pnmh)->flags, ((BHNSETWINDOWPOS*)pnmh)->x,
  1190. ((BHNSETWINDOWPOS*)pnmh)->y, ((BHNSETWINDOWPOS*)pnmh)->cx, ((BHNSETWINDOWPOS*)pnmh)->cy);
  1191. break;
  1192. case NBHN_FOCUSCHANGE:
  1193. BrowserPopup_OnAllowFocusChange(hwnd, &((BHNFOCUSCHANGE*)pnmh)->fAllow);
  1194. break;
  1195. case NBHN_FULLSCREEN:
  1196. BrowserPopup_OnSetFullscreen(hwnd, ((BHNFULLSCREEN*)pnmh)->fEnable);
  1197. break;
  1198. case NBHN_CLOSEPOPUP:
  1199. BrowserPopup_OnClosePopup(hwnd);
  1200. break;
  1201. }
  1202. return 0;
  1203. }
  1204. static LRESULT BrowserPopup_OnNotify(HWND hwnd, INT controlId, NMHDR *pnmh)
  1205. {
  1206. switch(controlId)
  1207. {
  1208. case IDC_BROWSER:
  1209. return BrowserPopup_OnBrowserNotify(hwnd, pnmh);
  1210. }
  1211. return 0;
  1212. }
  1213. static void BrowserPopup_OnSetFocus(HWND hwnd, HWND hLost)
  1214. {
  1215. BROWSERPOPUP *popup = GetPopup(hwnd);
  1216. HWND hChild, hTab;
  1217. hChild = FindWindowEx(hwnd, NULL, NULL, NULL);
  1218. hTab = NULL;
  1219. if (NULL != popup)
  1220. {
  1221. while(popup->lastFocus && IsChild(hwnd, popup->lastFocus))
  1222. {
  1223. if (IsWindowEnabled(popup->lastFocus) && IsWindowVisible(popup->lastFocus) &&
  1224. 0 != (WS_TABSTOP & GetWindowLongPtrW(popup->lastFocus, GWL_STYLE)))
  1225. {
  1226. hTab = popup->lastFocus;
  1227. break;
  1228. }
  1229. popup->lastFocus = GetParent(popup->lastFocus);
  1230. }
  1231. }
  1232. if (NULL == hTab)
  1233. {
  1234. hTab = (hChild) ? GetNextDlgTabItem(hwnd, hChild, FALSE) : hwnd;
  1235. }
  1236. if (NULL != hTab && hwnd != hTab &&
  1237. IsWindowEnabled(hTab) &&
  1238. IsWindowVisible(hTab))
  1239. {
  1240. TCHAR szName[128] = {0};
  1241. if (NULL != hChild &&
  1242. GetClassName(hChild, szName, ARRAYSIZE(szName)) &&
  1243. CSTR_EQUAL == CompareString(CSTR_INVARIANT, NORM_IGNORECASE, szName, -1, TEXT("#32770"), -1))
  1244. {
  1245. if (IsWindowEnabled(hChild))
  1246. PostMessage(hChild, WM_NEXTDLGCTL, (WPARAM)hTab, TRUE);
  1247. else
  1248. DefWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hLost, 0L);
  1249. }
  1250. else
  1251. {
  1252. SetFocus(hTab);
  1253. }
  1254. return;
  1255. }
  1256. DefWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hLost, 0L);
  1257. }
  1258. static void BrowserPopup_OnActivate(HWND hwnd, UINT uActivate, HWND hwndOther, BOOL bMinimized)
  1259. {
  1260. BROWSERPOPUP *popup = GetPopup(hwnd);
  1261. if (NULL == popup) return;
  1262. POINT pt;
  1263. switch(uActivate)
  1264. {
  1265. case WA_INACTIVE:
  1266. popup->lastFocus = GetFocus();
  1267. if (!IsChild(hwnd, popup->lastFocus))
  1268. popup->lastFocus = NULL;
  1269. break;
  1270. case WA_CLICKACTIVE:
  1271. if (GetCursorPos(&pt))
  1272. {
  1273. MapWindowPoints(HWND_DESKTOP, hwnd, &pt, 1);
  1274. HWND hTarget = ChildWindowFromPointEx(hwnd, pt, CWP_SKIPINVISIBLE | CWP_SKIPDISABLED | CWP_SKIPTRANSPARENT);
  1275. if (hTarget && hTarget != hwnd && hTarget != GetDlgItem(hwnd, IDC_TOOLBAR))
  1276. {
  1277. popup->lastFocus = hTarget;
  1278. }
  1279. }
  1280. break;
  1281. }
  1282. }
  1283. static void BrowserPopup_OnStyleChanged(HWND hwnd, UINT nStyleType, STYLESTRUCT *pss)
  1284. {
  1285. #define ISSTYLECHANGED(__style) ((__style) & pss->styleOld) != ((__style) & pss->styleNew)
  1286. if (GWL_STYLE == nStyleType)
  1287. {
  1288. if (ISSTYLECHANGED(WS_CHILD) && 0 != pss->styleNew && 0 != pss->styleOld)
  1289. {
  1290. BROWSERPOPUP *popup = GetPopup(hwnd);
  1291. if (NULL != popup && 0 == (BPF_MODECHANGELOCK & popup->flags))
  1292. {
  1293. popup->flags |= BPF_LOCKRESIZE;
  1294. PostMessage(hwnd, NBPM_PARENTCHANGED, 0, 0L);
  1295. }
  1296. }
  1297. }
  1298. }
  1299. static void BrowserPopup_OnGetMinMaxInfo(HWND hwnd, MINMAXINFO *minMax)
  1300. {
  1301. minMax->ptMinTrackSize.x = 275;
  1302. minMax->ptMinTrackSize.y = 116;
  1303. }
  1304. static LRESULT BrowserPopup_OnNavigate(HWND hwnd, LPCWSTR navigateUrl, BOOL fScheduleBlocked)
  1305. {
  1306. BROWSERPOPUP *popup = GetPopup(hwnd);
  1307. if (NULL == popup) return FALSE;
  1308. UINT windowStyle = GetWindowStyle(hwnd);
  1309. if (NULL != popup->browserHook)
  1310. popup->browserHook->CheckBlockedState(popup->service);
  1311. SysFreeString(popup->storedData);
  1312. popup->storedData = NULL;
  1313. Plugin_FreeResString(popup->storedUrl);
  1314. popup->storedUrl = NULL;
  1315. if (NBCS_EX_BROWSERREADY != ((NBCS_EX_BROWSERREADY | NBCS_EX_BLOCKNAVIGATION) & popup->extendedStyle))
  1316. {
  1317. if (FALSE == fScheduleBlocked)
  1318. return FALSE;
  1319. popup->storedUrl = Plugin_DuplicateResString(navigateUrl);
  1320. return TRUE;
  1321. }
  1322. HWND hHost = GetDlgItem(hwnd, IDC_BROWSER);
  1323. if (NULL == hHost) return FALSE;
  1324. LPWSTR pszDescription = NULL;
  1325. BSTR url = NULL;
  1326. if (IS_INTRESOURCE(navigateUrl))
  1327. {
  1328. switch((INT_PTR)navigateUrl)
  1329. {
  1330. case NAVIGATE_BLANK:
  1331. BrowserPopup_SetStatusText(hwnd, NULL);
  1332. url = SysAllocString(L"about:blank");
  1333. break;
  1334. case NAVIGATE_HOME:
  1335. if (0 == (NBCS_NOSERVICECOMMANDS & windowStyle) && NULL != popup->service)
  1336. {
  1337. WCHAR szBuffer[8192] = {0};
  1338. if (SUCCEEDED(popup->service->GetUrl(szBuffer, ARRAYSIZE(szBuffer))))
  1339. {
  1340. BrowserPopup_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_HOME_DESCRIPTION));
  1341. url = SysAllocString(szBuffer);
  1342. }
  1343. if (SUCCEEDED(popup->service->GetName(szBuffer, ARRAYSIZE(szBuffer))))
  1344. pszDescription = Plugin_CopyString(szBuffer);
  1345. }
  1346. break;
  1347. case NAVIGATE_BACK:
  1348. BrowserPopup_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_BACK_DESCRIPTION));
  1349. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandBack, 0L);
  1350. case NAVIGATE_FORWARD:
  1351. BrowserPopup_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_FORWARD_DESCRIPTION));
  1352. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandForward, 0L);
  1353. case NAVIGATE_STOP:
  1354. BrowserPopup_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_STOP_DESCRIPTION));
  1355. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandStop, 0L);
  1356. case NAVIGATE_REFRESH:
  1357. BrowserPopup_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_REFRESH_DESCRIPTION));
  1358. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandRefresh, 0L);
  1359. case NAVIGATE_REFRESH_COMPLETELY:
  1360. BrowserPopup_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_REFRESH_DESCRIPTION));
  1361. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandRefreshCompletely, 0L);
  1362. }
  1363. }
  1364. else
  1365. {
  1366. BrowserPopup_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_NAVIGATING));
  1367. url = SysAllocString(navigateUrl);
  1368. }
  1369. if (NULL == url)
  1370. return FALSE;
  1371. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  1372. INT addressbarId = (NULL != hToolbar) ? Toolbar_FindItem(hToolbar, TOOLITEM_ADDRESSBAR) : ITEM_ERR;
  1373. if (ITEM_ERR != addressbarId)
  1374. {
  1375. Toolbar_SetItemString(hToolbar, MAKEINTRESOURCE(addressbarId), url);
  1376. Toolbar_SetItemDescription(hToolbar, MAKEINTRESOURCE(addressbarId), pszDescription);
  1377. }
  1378. if (!PostMessage(hHost, NBHM_NAVIGATE, 0, (LPARAM)url))
  1379. {
  1380. SysFreeString(url);
  1381. return FALSE;
  1382. }
  1383. Plugin_FreeString(pszDescription);
  1384. return TRUE;
  1385. }
  1386. static LRESULT BrowserPopup_OnWriteDocument(HWND hwnd, BSTR documentData, BOOL fScheduleBlocked)
  1387. {
  1388. BROWSERPOPUP *popup = GetPopup(hwnd);
  1389. if (NULL == popup) return FALSE;
  1390. SysFreeString(popup->storedData);
  1391. popup->storedData = NULL;
  1392. Plugin_FreeResString(popup->storedUrl);
  1393. popup->storedUrl = NULL;
  1394. if (0 == (NBCS_EX_NAVCOMPLETED & popup->extendedStyle))
  1395. {
  1396. if (FALSE == fScheduleBlocked)
  1397. return FALSE;
  1398. popup->storedData = documentData;
  1399. return TRUE;
  1400. }
  1401. HWND hHost = GetDlgItem(hwnd, IDC_BROWSER);
  1402. if (NULL == hHost) return FALSE;
  1403. return PostMessage(hHost, NBHM_WRITEDOCUMENT, 0, (LPARAM)documentData);
  1404. }
  1405. static void BrowserPopup_OnParentChanged(HWND hwnd)
  1406. {
  1407. HWND hRoot = GetAncestor(hwnd, GA_ROOT);
  1408. DWORD oldStyleEx, newStyleEx;
  1409. BROWSERPOPUP *popup = GetPopup(hwnd);
  1410. if (NULL == popup) return;
  1411. popup->flags &= ~BPF_LOCKRESIZE;
  1412. HWND hWinamp;
  1413. if (FAILED(Plugin_GetWinampWnd(&hWinamp)))
  1414. hWinamp = NULL;
  1415. oldStyleEx = GetWindowStyleEx(hwnd);
  1416. newStyleEx = oldStyleEx;
  1417. if (hRoot != hwnd)
  1418. {
  1419. HWND hDlgParent = (HWND)SENDWAIPC(hWinamp, IPC_GETDIALOGBOXPARENT, 0);
  1420. if (hRoot != hWinamp && hRoot != hDlgParent)
  1421. {
  1422. if (NULL != hDlgParent && hWinamp == (HWND)(LONG_PTR)GetWindowLongPtr(hRoot, GWLP_HWNDPARENT))
  1423. {
  1424. SetWindowLongPtr(hRoot, GWLP_HWNDPARENT, (LONGX86)(LONG_PTR)hDlgParent);
  1425. }
  1426. }
  1427. newStyleEx |= WS_EX_CONTROLPARENT;
  1428. }
  1429. else
  1430. {
  1431. newStyleEx &= ~WS_EX_CONTROLPARENT;
  1432. if (NULL != hWinamp && hWinamp != (HWND)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_HWNDPARENT))
  1433. SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONGX86)(LONG_PTR)hWinamp);
  1434. RECT rect;
  1435. if (BrowserPopup_PopRect(hwnd, &rect, FALSE))
  1436. {
  1437. BrowserPopup_ClientToFrame(hwnd, &rect);
  1438. BrowserPopup_SetFramePos(hwnd, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW);
  1439. }
  1440. }
  1441. if (newStyleEx != oldStyleEx)
  1442. SetWindowLongPtr(hwnd, GWL_EXSTYLE, newStyleEx);
  1443. BrowserPopup_RefreshTitle(hwnd);
  1444. SendMessage(hRoot, WM_UPDATEUISTATE, MAKEWPARAM(UIS_INITIALIZE, UISF_HIDEACCEL | UISF_HIDEFOCUS), 0L);
  1445. }
  1446. static void BrowserPopup_OnUpdateSkin(HWND hwnd, BOOL fRedraw)
  1447. {
  1448. BROWSERPOPUP *popup = GetPopup(hwnd);
  1449. if (NULL == popup) return;
  1450. DWORD windowStyle = GetWindowStyle(hwnd);
  1451. if (0 != (WS_VISIBLE & windowStyle))
  1452. SetWindowLongPtr(hwnd, GWL_STYLE, ~WS_VISIBLE & windowStyle);
  1453. ifc_skinnedbrowser *skinnedBrowser;
  1454. if (SUCCEEDED(Plugin_GetBrowserSkin(&skinnedBrowser)))
  1455. {
  1456. popup->rgbBack = skinnedBrowser->GetBackColor();
  1457. skinnedBrowser->Release();
  1458. }
  1459. else
  1460. popup->rgbBack = GetSysColor(COLOR_WINDOW);
  1461. HWND hControl;
  1462. if (NULL != (hControl = GetDlgItem(hwnd, IDC_BROWSER)))
  1463. PostMessage(hControl, NBHM_UPDATESKIN, 0, 0L);
  1464. if (NULL != (hControl = GetDlgItem(hwnd, IDC_STATUSBAR)))
  1465. Statusbar_UpdateSkin(hControl, FALSE);
  1466. if (NULL != (hControl = GetDlgItem(hwnd, IDC_TOOLBAR)))
  1467. Toolbar_UpdateSkin(hControl, FALSE);
  1468. if (NULL != (hControl = BrowserControl_GetOperationWidget(hwnd)))
  1469. Curtain_UpdateSkin(hControl, FALSE);
  1470. BrowserControl_UpdateLayout(hwnd, FALSE, TRUE, NULL, NULL);
  1471. if (0 != (WS_VISIBLE & windowStyle))
  1472. SetWindowLongPtr(hwnd, GWL_STYLE, windowStyle);
  1473. if (FALSE != fRedraw)
  1474. {
  1475. RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_FRAME);
  1476. }
  1477. }
  1478. static LRESULT BrowserPopup_OnSkinRefreshing(HWND hwnd)
  1479. {
  1480. BrwoserPopup_PushClientRect(hwnd, FALSE);
  1481. HWND hRoot = GetAncestor(hwnd, GA_ROOT);
  1482. if (hRoot != hwnd)
  1483. {
  1484. HWND hWinamp;
  1485. if (FAILED(Plugin_GetWinampWnd(&hWinamp)))
  1486. hWinamp = NULL;
  1487. HWND hDlgParent = (HWND)SENDWAIPC(hWinamp, IPC_GETDIALOGBOXPARENT, 0);
  1488. if (NULL != hDlgParent && hDlgParent == (HWND)(LONG_PTR)GetWindowLongPtr(hRoot, GWLP_HWNDPARENT))
  1489. {
  1490. SetWindowLongPtr(hRoot, GWLP_HWNDPARENT, (LONGX86)(LONG_PTR)hWinamp);
  1491. }
  1492. }
  1493. return 0;
  1494. }
  1495. static void BrowserPopup_OnSkinRefreshed(HWND hwnd)
  1496. {
  1497. BrowserPopup_PopRect(hwnd, NULL, FALSE);
  1498. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  1499. if (hwnd != hFrame)
  1500. {
  1501. UINT state = (IsWindowVisible(hwnd) && IsWindowEnabled(hwnd) && (hFrame == GetActiveWindow())) ? WA_ACTIVE : WA_INACTIVE;
  1502. SendMessage(hwnd, WM_ACTIVATE, state, 0L);
  1503. }
  1504. }
  1505. static LRESULT BrowserPopup_OnSetFramePos(HWND hwnd, WINDOWPOS *pwp)
  1506. {
  1507. if (NULL == pwp) return FALSE;
  1508. HWND hFrame;
  1509. ifc_window *wasabiWnd = (ifc_window*)SENDWAIPC(hwnd, IPC_SKINWINDOW_GETWASABIWND, 0);
  1510. if (NULL != wasabiWnd)
  1511. {
  1512. ifc_window *wasabiParent = wasabiWnd->getDesktopParent();
  1513. if (NULL == wasabiParent) wasabiParent = wasabiWnd;
  1514. hFrame = wasabiParent->gethWnd();
  1515. if (NULL == hFrame) return FALSE;
  1516. HWND hWinamp;
  1517. if (FAILED(Plugin_GetWinampWnd(&hWinamp)))
  1518. hWinamp = NULL;
  1519. HWND hDlgParent = (HWND)SENDWAIPC(hWinamp, IPC_GETDIALOGBOXPARENT, 0);
  1520. if (hDlgParent == hFrame)
  1521. return FALSE; // do not change size/pos if we are part of the sui
  1522. if (0 == (SWP_NOSIZE & pwp->flags))
  1523. {
  1524. RECT windowRect;
  1525. wasabiParent->getWindowRect(&windowRect);
  1526. if (pwp->cx != (windowRect.right - windowRect.left) || pwp->cy != (windowRect.bottom - windowRect.top))
  1527. {
  1528. if (0 == SendMessage(wasabiWnd->gethWnd(), OSWNDHOST_REQUEST_IDEAL_SIZE, pwp->cx, pwp->cy))
  1529. {
  1530. return FALSE; // hmm,
  1531. }
  1532. }
  1533. pwp->flags |= SWP_NOSIZE;
  1534. }
  1535. if (0 == (SWP_NOMOVE & pwp->flags))
  1536. {
  1537. RECT windowRect;
  1538. wasabiParent->getWindowRect(&windowRect);
  1539. wasabiParent->resize(pwp->x, pwp->y, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top);
  1540. pwp->flags |= SWP_NOMOVE;
  1541. }
  1542. }
  1543. else
  1544. {
  1545. hFrame = BrowserPopup_GetFrame(hwnd);
  1546. if (NULL == hFrame) return FALSE;
  1547. }
  1548. BOOL result = SetWindowPos(hFrame, pwp->hwndInsertAfter, pwp->x, pwp->y, pwp->cx, pwp->cy, pwp->flags);
  1549. BrwoserPopup_PushClientRect(hwnd, TRUE);
  1550. return result;
  1551. }
  1552. static void BrowserPopup_OnActivateFrame(HWND hwnd)
  1553. {
  1554. ifc_window *wasabiWnd = (ifc_window*)SENDWAIPC(hwnd, IPC_SKINWINDOW_GETWASABIWND, 0);
  1555. if (NULL != wasabiWnd)
  1556. {
  1557. wasabiWnd->activate();
  1558. }
  1559. else
  1560. {
  1561. HWND hFrame = BrowserPopup_GetFrame(hwnd);
  1562. if (NULL == hFrame) hFrame = hwnd;
  1563. BringWindowToTop(hFrame);
  1564. SetActiveWindow(hFrame);
  1565. }
  1566. }
  1567. static LRESULT BrowserPopup_OnGetService(HWND hwnd, ifc_omservice **serviceOut)
  1568. {
  1569. if (NULL == serviceOut) return FALSE;
  1570. BROWSERPOPUP *popup = GetPopup(hwnd);
  1571. if (NULL == popup || NULL == popup->service)
  1572. {
  1573. *serviceOut = NULL;
  1574. return FALSE;
  1575. }
  1576. *serviceOut = popup->service;
  1577. (*serviceOut)->AddRef();
  1578. return TRUE;
  1579. }
  1580. static LRESULT BrowserPopup_OnGetBrowserObject(HWND hwnd, obj_ombrowser **browserOut)
  1581. {
  1582. if (NULL == browserOut) return FALSE;
  1583. BROWSERPOPUP *popup = GetPopup(hwnd);
  1584. if (NULL == popup || NULL == popup->browserManager)
  1585. {
  1586. *browserOut = NULL;
  1587. return FALSE;
  1588. }
  1589. *browserOut = popup->browserManager;
  1590. (*browserOut)->AddRef();
  1591. return TRUE;
  1592. }
  1593. static LRESULT BrowserPopup_OnRefreshTitle(HWND hwnd)
  1594. {
  1595. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  1596. if (NULL == hBrowser || FALSE == PostMessage(hBrowser, NBHM_QUERYTITLE, 0, 0L))
  1597. BrowserPopup_UpdateTitle(hwnd, NULL);
  1598. return TRUE;
  1599. }
  1600. static LRESULT BrowserPopup_OnGetToolbar(HWND hwnd)
  1601. {
  1602. if (0 != (NBCS_NOTOOLBAR & GetWindowLongPtr(hwnd, GWL_STYLE)))
  1603. return 0;
  1604. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  1605. return (LRESULT)hToolbar;
  1606. }
  1607. static LRESULT BrowserPopup_OnGetStatusbar(HWND hwnd)
  1608. {
  1609. if (0 != (NBCS_NOSTATUSBAR & GetWindowLongPtr(hwnd, GWL_STYLE)))
  1610. return 0;
  1611. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  1612. return (LRESULT)hStatusbar;
  1613. }
  1614. static LRESULT BrowserPopup_OnGetHost(HWND hwnd)
  1615. {
  1616. return (LRESULT)GetDlgItem(hwnd, IDC_BROWSER);
  1617. }
  1618. static LRESULT BrowserPopup_OnNavigateStoredUrl(HWND hwnd)
  1619. {
  1620. BROWSERPOPUP *popup = GetPopup(hwnd);
  1621. if (NULL == popup || NULL == popup->storedUrl)
  1622. return FALSE;
  1623. LPWSTR url = popup->storedUrl;
  1624. popup->storedUrl = NULL;
  1625. BOOL result = BrowserPopup_Navigate(hwnd, url, TRUE);
  1626. Plugin_FreeResString(url);
  1627. return result;
  1628. }
  1629. static LRESULT BrowserPopup_OnSetExtendedStyle(HWND hwnd, UINT extMask, UINT extStyle)
  1630. {
  1631. BROWSERPOPUP *popup = GetPopup(hwnd);
  1632. if (NULL == popup) return 0;
  1633. UINT currentStyle = popup->extendedStyle;
  1634. popup->extendedStyle = (currentStyle & ~extMask) | (extStyle & extMask);
  1635. if ((NBCS_EX_SCRIPTMODE & currentStyle) != (NBCS_EX_SCRIPTMODE & popup->extendedStyle))
  1636. {
  1637. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  1638. if (NULL != hBrowser)
  1639. {
  1640. UINT browserStyle = GetWindowStyle(hBrowser);
  1641. if (0 != (NBCS_EX_SCRIPTMODE & popup->extendedStyle))
  1642. browserStyle |= NBHS_SCRIPTMODE;
  1643. else
  1644. browserStyle &= ~ NBHS_SCRIPTMODE;
  1645. SetWindowLongPtr(hBrowser, GWL_STYLE, browserStyle);
  1646. }
  1647. }
  1648. if ((NBCS_EX_FULLSCREEN & currentStyle) != (NBCS_EX_FULLSCREEN & popup->extendedStyle))
  1649. {
  1650. if (0 != (NBCS_EX_FULLSCREEN & popup->extendedStyle))
  1651. BrowserPopup_SwitchToFullscreen(hwnd);
  1652. else
  1653. BrowserPopup_Restore(hwnd);
  1654. }
  1655. return currentStyle;
  1656. }
  1657. static LRESULT BrowserPopup_OnGetExtendedStyle(HWND hwnd)
  1658. {
  1659. BROWSERPOPUP *popup = GetPopup(hwnd);
  1660. return (NULL != popup) ? popup->extendedStyle : 0;
  1661. }
  1662. static LRESULT CALLBACK BrowserPopup_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1663. {
  1664. switch(uMsg)
  1665. {
  1666. case WM_CREATE: return BrowserPopup_OnCreate(hwnd, (CREATESTRUCT*)lParam);
  1667. case WM_DESTROY: BrowserPopup_OnDestroy(hwnd); break;
  1668. case WM_ERASEBKGND: return 0;
  1669. case WM_PAINT: BrowserPopup_OnPaint(hwnd); return 0;
  1670. case WM_PRINTCLIENT: BrowserPopup_OnPrintClient(hwnd, (HDC)wParam, (UINT)lParam); return 0;
  1671. case WM_WINDOWPOSCHANGING: BrowserPopup_OnWindowPosChanging(hwnd, (WINDOWPOS*)lParam); return 0;
  1672. case WM_WINDOWPOSCHANGED: BrowserPopup_OnWindowPosChanged(hwnd, (WINDOWPOS*)lParam); return 0;
  1673. case WM_COMMAND: BrowserPopup_OnCommand(hwnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam); break;
  1674. case WM_APPCOMMAND: return BrowserPopup_OnAppCommand(hwnd, (HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam));
  1675. case WM_NOTIFY: return BrowserPopup_OnNotify(hwnd, (INT)wParam, (NMHDR*)lParam);
  1676. case WM_SETFOCUS: BrowserPopup_OnSetFocus(hwnd, (HWND)wParam); return 0;
  1677. case WM_ACTIVATE: BrowserPopup_OnActivate(hwnd, LOWORD(wParam), (HWND)lParam, HIWORD(wParam)); break;
  1678. case WM_STYLECHANGED: BrowserPopup_OnStyleChanged(hwnd, (UINT)wParam, (STYLESTRUCT*)lParam); break;
  1679. case WM_GETMINMAXINFO: BrowserPopup_OnGetMinMaxInfo(hwnd, (MINMAXINFO*)lParam); return 0;
  1680. case NBCM_GETTOOLBAR: return BrowserPopup_OnGetToolbar(hwnd);
  1681. case NBCM_GETSTATUSBAR: return BrowserPopup_OnGetStatusbar(hwnd);
  1682. case NBCM_GETHOST: return BrowserPopup_OnGetHost(hwnd);
  1683. case NBCM_GETSERVICE: return BrowserPopup_OnGetService(hwnd, (ifc_omservice**)lParam);
  1684. case NBCM_UPDATESKIN: BrowserPopup_OnUpdateSkin(hwnd, (BOOL)lParam); return 0;
  1685. case NBCM_NAVIGATE: return BrowserPopup_OnNavigate(hwnd, (LPCWSTR)lParam, (BOOL)wParam);
  1686. case NBCM_WRITEDOCUMENT: return BrowserPopup_OnWriteDocument(hwnd, (BSTR)lParam, (BOOL)wParam);
  1687. case NBCM_GETBROWSEROBJECT: return BrowserPopup_OnGetBrowserObject(hwnd, (obj_ombrowser**)lParam);
  1688. case NBCM_SHOWOPERATION: return BrowserControl_OnShowOperation(hwnd, (OPERATIONINFO*)lParam);
  1689. case NBCM_NAVSTOREDURL: return BrowserPopup_OnNavigateStoredUrl(hwnd);
  1690. case NBCM_BLOCK: BrowserControl_SetBlockedState(hwnd, (BOOL)lParam); return 0;
  1691. case NBCM_SETEXTSTYLE: return BrowserPopup_OnSetExtendedStyle(hwnd, (UINT)wParam, (UINT)lParam);
  1692. case NBCM_GETEXTSTYLE: return BrowserPopup_OnGetExtendedStyle(hwnd);
  1693. case NBPM_PARENTCHANGED: BrowserPopup_OnParentChanged(hwnd); return 0;
  1694. case NBPM_SKINREFRESHING: return BrowserPopup_OnSkinRefreshing(hwnd);
  1695. case NBPM_SKINREFRESHED: BrowserPopup_OnSkinRefreshed(hwnd); return 0;
  1696. case NBPM_SETFRAMEPOS: return BrowserPopup_OnSetFramePos(hwnd, (WINDOWPOS*)lParam);
  1697. case NBPM_ACTIVATEFRAME: BrowserPopup_OnActivateFrame(hwnd); return 0;
  1698. case NBPM_REFRESHTITLE: return BrowserPopup_OnRefreshTitle(hwnd);
  1699. }
  1700. if (FALSE != Plugin_IsDirectMouseWheelMessage(uMsg))
  1701. {
  1702. SendMessage(hwnd, WM_MOUSEWHEEL, wParam, lParam);
  1703. return TRUE;
  1704. }
  1705. return DefWindowProcW(hwnd, uMsg, wParam, lParam);
  1706. }