browserView.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. #include "main.h"
  2. #include "./browserView.h"
  3. #include "./browserUiInternal.h"
  4. #include "./graphics.h"
  5. #include "./resource.h"
  6. #include "./browser.h"
  7. #include "./browserHost.h"
  8. #include "./browserPopup.h"
  9. #include "./toolbar.h"
  10. #include "./statusbar.h"
  11. #include "./curtain.h"
  12. #include "../winamp/wa_dlg.h"
  13. #include "../Plugins/General/gen_ml/colors.h"
  14. #include "./ifc_omservice.h"
  15. #include "./obj_ombrowser.h"
  16. #include "./ifc_wasabihelper.h"
  17. #include "./ifc_skinhelper.h"
  18. #include "./ifc_skinnedbrowser.h"
  19. #include "./ifc_omserviceeventmngr.h"
  20. #include "./ifc_omserviceevent.h"
  21. #include "./ifc_ombrowserwndmngr.h"
  22. #include "./ifc_ombrowsereventmngr.h"
  23. #include "./ifc_omconfig.h"
  24. #include "./ifc_omtoolbarconfig.h"
  25. #include "./ifc_omstatusbarconfig.h"
  26. #include "./browserUiHook.h"
  27. #include <shlwapi.h>
  28. #include <strsafe.h>
  29. typedef struct __BROWSERVIEWCREATEPARAM
  30. {
  31. obj_ombrowser *browserManager;
  32. ifc_omservice *service;
  33. LPCWSTR redirectUrl;
  34. } BROWSERVIEWCREATEPARAM;
  35. typedef struct __BROWSERVIEW
  36. {
  37. UINT extendedStyle;
  38. obj_ombrowser *browserManager;
  39. ifc_omservice *service;
  40. LPWSTR storedUrl;
  41. BSTR storedData;
  42. HRGN updateRegion;
  43. POINT regionOffset;
  44. COLORREF rgbBack;
  45. BrowserUiHook *browserHook;
  46. } BROWSERVIEW;
  47. #define IDC_BROWSER 0x1000
  48. #define IDC_TOOLBAR 0x1001
  49. #define IDC_STATUSBAR 0x1002
  50. static BOOL BrowserView_RegisterClass(HINSTANCE hInstance);
  51. static LRESULT CALLBACK BrowserView_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  52. #define GetView(__hwnd) ((BROWSERVIEW*)(LONG_PTR)(LONGX86)GetWindowLongPtr((__hwnd), 0))
  53. HWND BrowserView_Create(obj_ombrowser *browserManager, ifc_omservice *service, HWND hParent, LPCWSTR redirectUrl, UINT style)
  54. {
  55. HINSTANCE hInstance = Plugin_GetInstance();
  56. if (!BrowserView_RegisterClass(hInstance) ||
  57. !Toolbar_RegisterClass(hInstance) ||
  58. !Statusbar_RegisterClass(hInstance))
  59. {
  60. return NULL;
  61. }
  62. BROWSERVIEWCREATEPARAM createParam;
  63. ZeroMemory(&createParam, sizeof(BROWSERVIEWCREATEPARAM));
  64. createParam.browserManager = browserManager;
  65. createParam.service = service;
  66. createParam.redirectUrl = redirectUrl;
  67. HWND hwnd = CreateWindowEx(WS_EX_NOPARENTNOTIFY | WS_EX_CONTROLPARENT,
  68. NWC_OMBROWSERVIEW, NULL,
  69. WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | style,
  70. 0, 0, 0, 0, hParent, NULL, hInstance, &createParam);
  71. return hwnd;
  72. }
  73. static void BrowserView_Paint(HWND hwnd, HDC hdc, const RECT *prcPaint, BOOL fErase)
  74. {
  75. BROWSERVIEW *view = GetView(hwnd);
  76. if (NULL == view) return;
  77. SetBkColor(hdc, view->rgbBack);
  78. ExtTextOut(hdc, 0, 0, ETO_OPAQUE, prcPaint, NULL, 0, NULL);
  79. }
  80. static BOOL BrowserView_PreformNavigation(HWND hwnd)
  81. {
  82. BROWSERVIEW *view = GetView(hwnd);
  83. if (NULL == view) return FALSE;
  84. if (NULL != view->storedUrl)
  85. {
  86. LPWSTR url = view->storedUrl;
  87. view->storedUrl = NULL;
  88. BrowserView_Navigate(hwnd, url, TRUE);
  89. Plugin_FreeResString(url);
  90. }
  91. else
  92. {
  93. BrowserView_NavigateHome(hwnd, TRUE);
  94. }
  95. return TRUE;
  96. }
  97. static HWND BrowserView_CreateToolbar(HWND hwnd)
  98. {
  99. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  100. if (NULL != hToolbar) return hToolbar;
  101. BROWSERVIEW *view = GetView(hwnd);
  102. if (NULL == view) return NULL;
  103. UINT fStyle = GetWindowStyle(hwnd);
  104. UINT toolbarStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBS_LOCKUPDATE;
  105. if (0 == (NBCS_NOTOOLBAR & fStyle))
  106. toolbarStyle |= WS_VISIBLE;
  107. ifc_omtoolbarconfig *toolbarConfig;
  108. if (NULL != view->browserManager && SUCCEEDED(view->browserManager->GetConfig(&IFC_OmToolbarConfig, (void**)&toolbarConfig)))
  109. {
  110. if (S_OK == toolbarConfig->GetBottomDockEnabled())
  111. toolbarStyle |= TBS_BOTTOMDOCK;
  112. if (S_OK == toolbarConfig->GetAutoHideEnabled())
  113. toolbarStyle |= TBS_AUTOHIDE;
  114. if (S_OK == toolbarConfig->GetTabStopEnabled())
  115. toolbarStyle |= TBS_TABSTOP;
  116. if (S_OK == toolbarConfig->GetForceAddressbarEnabled())
  117. toolbarStyle |= TBS_FORCEADDRESS;
  118. if (S_OK == toolbarConfig->GetFancyAddressbarEnabled())
  119. toolbarStyle |= TBS_FANCYADDRESS;
  120. toolbarConfig->Release();
  121. }
  122. HINSTANCE hInstance = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
  123. hToolbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY,
  124. NWC_ONLINEMEDIATOOLBAR, NULL, toolbarStyle,
  125. 0, 0, 0, 0, hwnd, (HMENU)IDC_TOOLBAR, hInstance, NULL);
  126. if (NULL == hToolbar)
  127. return NULL;
  128. UINT populateStyle = TBPF_NORMAL | TBPF_READONLYADDRESS;
  129. if (0 != (NBCS_NOSERVICECOMMANDS & fStyle))
  130. populateStyle |= TBPF_NOSERVICECOMMANDS;
  131. Toolbar_AutoPopulate(hToolbar, view->service, populateStyle);
  132. toolbarStyle = GetWindowStyle(hToolbar);
  133. if (0 != (TBS_LOCKUPDATE & toolbarStyle))
  134. Toolbar_LockUpdate(hToolbar, FALSE);
  135. return hToolbar;
  136. }
  137. static HWND BrowserView_CreateStatusbar(HWND hwnd)
  138. {
  139. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  140. if (NULL != hStatusbar) return hStatusbar;
  141. BROWSERVIEW *view = GetView(hwnd);
  142. if (NULL == view) return NULL;
  143. UINT fStyle = GetWindowStyle(hwnd);
  144. UINT statusbarStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED;
  145. if (0 == (NBCS_NOSTATUSBAR & fStyle))
  146. {
  147. ifc_omstatusbarconfig *statusbarConfig;
  148. if (NULL != view->browserManager && SUCCEEDED(view->browserManager->GetConfig(&IFC_OmStatusbarConfig, (void**)&statusbarConfig)))
  149. {
  150. if (S_OK == statusbarConfig->GetEnabled())
  151. statusbarStyle &= ~WS_DISABLED;
  152. statusbarConfig->Release();
  153. }
  154. }
  155. HINSTANCE hInstance = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
  156. hStatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY,
  157. NWC_ONLINEMEDIASTATUSBAR, NULL, statusbarStyle,
  158. 0, 0, 0, 0, hwnd, (HMENU)IDC_STATUSBAR, hInstance, NULL);
  159. return hStatusbar;
  160. }
  161. static LRESULT BrowserView_ShowHistory(HWND hwnd, BOOL fButtonPressd)
  162. {
  163. HWND hBrowser = GetDlgItem(hwnd, IDC_BROWSER);
  164. if (NULL == hBrowser) return FALSE;
  165. UINT flags = TPM_LEFTALIGN;
  166. POINT pt = {0, 0};
  167. BOOL fUseHost = TRUE;;
  168. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  169. DWORD toolbarStyle = (NULL != hToolbar) ? GetWindowStyle(hToolbar) : 0;
  170. if (NULL != hToolbar && 0 != (WS_VISIBLE & toolbarStyle))
  171. {
  172. fUseHost = FALSE;
  173. RECT toolbarRect;
  174. GetWindowRect(hToolbar, &toolbarRect);
  175. pt.x = toolbarRect.left + 2;
  176. if (0 != (TBS_BOTTOMDOCK & toolbarStyle))
  177. {
  178. pt.y = toolbarRect.top + 1;
  179. flags |= TPM_VERNEGANIMATION | TPM_BOTTOMALIGN;
  180. }
  181. else
  182. {
  183. pt.y = toolbarRect.bottom - 1;
  184. flags |= TPM_VERPOSANIMATION | TPM_TOPALIGN;
  185. }
  186. }
  187. if (FALSE != fUseHost)
  188. {
  189. RECT windowRect;
  190. GetClientRect(hwnd, &windowRect);
  191. pt.x = windowRect.left;
  192. pt.y = windowRect.top;
  193. MapWindowPoints(hwnd, HWND_DESKTOP, &pt, 1);
  194. flags |= TPM_VERPOSANIMATION | TPM_TOPALIGN;
  195. }
  196. if (NULL != hToolbar && 0 != (TBS_AUTOHIDE & toolbarStyle))
  197. SetWindowLongPtr(hToolbar, GWL_STYLE, toolbarStyle & ~TBS_AUTOHIDE);
  198. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  199. DWORD statusStyle = (NULL != hStatusbar) ? GetWindowStyle(hStatusbar) : 0;
  200. if (NULL != hStatusbar && 0 == (WS_DISABLED & statusStyle))
  201. SetWindowLongPtr(hStatusbar, GWL_STYLE, WS_DISABLED | statusStyle);
  202. LRESULT result = SendMessage(hBrowser, NBHM_SHOWHISTORYPOPUP, (WPARAM)flags, MAKELPARAM(pt.x, pt.y));
  203. if (NULL != hToolbar && 0 != (TBS_AUTOHIDE & toolbarStyle))
  204. {
  205. SetWindowLongPtr(hToolbar, GWL_STYLE, toolbarStyle);
  206. TRACKMOUSEEVENT tm;
  207. tm.cbSize = sizeof(TRACKMOUSEEVENT);
  208. tm.dwFlags = TME_LEAVE;
  209. tm.hwndTrack = hToolbar;
  210. TrackMouseEvent(&tm);
  211. }
  212. if (NULL != hStatusbar && 0 == (WS_DISABLED & statusStyle))
  213. SetWindowLongPtr(hStatusbar, GWL_STYLE, statusStyle);
  214. return result;
  215. }
  216. static BOOL BrowserView_SetStatusText(HWND hwnd, LPCWSTR pszText)
  217. {
  218. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  219. if (NULL == hStatusbar) return FALSE;
  220. Statusbar_Update(hStatusbar, pszText);
  221. return TRUE;
  222. }
  223. static BOOL BrowserView_SetStatusTextRes(HWND hwnd, LPCWSTR pszText)
  224. {
  225. if (NULL != pszText && IS_INTRESOURCE(pszText))
  226. {
  227. WCHAR szBuffer[512] = {0};
  228. pszText = Plugin_LoadString((INT)(INT_PTR)pszText, szBuffer, ARRAYSIZE(szBuffer));
  229. }
  230. return BrowserView_SetStatusText(hwnd, pszText);
  231. }
  232. static void BrowserView_RegisterUiHook(HWND hwnd)
  233. {
  234. BROWSERVIEW *view = GetView(hwnd);
  235. if (NULL == view || NULL != view->browserHook) return;
  236. if (FAILED(BrowserUiHook::CreateInstance(hwnd, FALSE, &view->browserHook)))
  237. return;
  238. view->browserHook->Register(view->browserManager, view->service);
  239. }
  240. static LRESULT BrowserView_OnCreate(HWND hwnd, CREATESTRUCT *pcs)
  241. {
  242. BROWSERVIEWCREATEPARAM *createParam = (BROWSERVIEWCREATEPARAM*)pcs->lpCreateParams;
  243. BROWSERVIEW *view = (BROWSERVIEW*)calloc(1, sizeof(BROWSERVIEW));
  244. if (NULL != view)
  245. {
  246. SetLastError(ERROR_SUCCESS);
  247. if (!SetWindowLongPtr(hwnd, 0, (LONGX86)(LONG_PTR)view) && ERROR_SUCCESS != GetLastError())
  248. {
  249. free(view);
  250. view = NULL;
  251. }
  252. }
  253. if (NULL == view)
  254. {
  255. DestroyWindow(hwnd);
  256. return -1;
  257. }
  258. if (NULL != createParam)
  259. {
  260. view->browserManager = createParam->browserManager;
  261. if (NULL != view->browserManager)
  262. view->browserManager->AddRef();
  263. view->service = createParam->service;
  264. if (NULL != view->service)
  265. view->service->AddRef();
  266. if (NULL != createParam->redirectUrl)
  267. view->storedUrl = Plugin_DuplicateResString(createParam->redirectUrl);
  268. }
  269. BrowserView_RegisterUiHook(hwnd);
  270. BrowserView_CreateToolbar(hwnd);
  271. BrowserView_CreateStatusbar(hwnd);
  272. UINT hostStyle = 0;
  273. if (0 != (NBCS_DISABLECONTEXTMENU & pcs->style)) hostStyle |= NBHS_DISABLECONTEXTMENU;
  274. if (0 != (NBCS_DIALOGMODE & pcs->style)) hostStyle |= NBHS_DIALOGMODE;
  275. if (0 != (NBCS_DISABLEHOSTCSS & pcs->style))
  276. hostStyle |= NBHS_DISABLEHOSTCSS;
  277. HACCEL hAccel = BrowserControl_GetAccelTable(ACCELTABLE_VIEW);
  278. HWND hHost = BrowserHost_CreateWindow(view->browserManager, hwnd, hostStyle, 0, 0, 0, 0, IDC_BROWSER, hAccel);
  279. HWND hControl;
  280. if (NULL != (hControl = GetDlgItem(hwnd, IDC_TOOLBAR)))
  281. {
  282. Toolbar_SetBrowserHost(hControl, hHost);
  283. }
  284. if (NULL != (hControl = GetDlgItem(hwnd, IDC_STATUSBAR)))
  285. {
  286. Statusbar_SetBrowserHost(hControl, hHost);
  287. Statusbar_SetActive(hControl, (0 == (WS_DISABLED & GetWindowLongPtr(hControl, GWL_STYLE))));
  288. }
  289. if (NULL != hAccel)
  290. {
  291. ifc_wasabihelper *wasabiHelper;
  292. if (SUCCEEDED(Plugin_GetWasabiHelper(&wasabiHelper)))
  293. {
  294. api_application *app;
  295. if (SUCCEEDED(wasabiHelper->GetApplicationApi(&app)))
  296. {
  297. app->app_addAccelerators(hwnd, &hAccel, 1, TRANSLATE_MODE_CHILD);
  298. app->Release();
  299. }
  300. wasabiHelper->Release();
  301. }
  302. }
  303. if(NULL != view->browserManager)
  304. {
  305. ifc_ombrowserwndmngr *windowManager;
  306. if (SUCCEEDED(view->browserManager->QueryInterface(IFC_OmBrowserWindowManager, (void**)&windowManager)))
  307. {
  308. windowManager->RegisterWindow(hwnd, &WTID_BrowserView);
  309. windowManager->Release();
  310. }
  311. ifc_ombrowsereventmngr *eventManager;
  312. if (SUCCEEDED(view->browserManager->QueryInterface(IFC_OmBrowserEventManager, (void**)&eventManager)))
  313. {
  314. eventManager->Signal_WindowCreate(hwnd, &WTID_BrowserView);
  315. eventManager->Release();
  316. }
  317. }
  318. return 0;
  319. }
  320. static void BrowserView_OnDestroy(HWND hwnd)
  321. {
  322. BROWSERVIEW *view = GetView(hwnd);
  323. SetWindowLongPtr(hwnd, 0, 0L);
  324. HWND hHost = GetDlgItem(hwnd, IDC_BROWSER);
  325. if (NULL != hHost)
  326. {
  327. DWORD hostStyle = GetWindowStyle(hHost);
  328. if (0 != (WS_VISIBLE & hostStyle))
  329. SetWindowLongPtr(hHost, GWL_STYLE, hostStyle & ~WS_VISIBLE);
  330. HWND hWinamp;
  331. if (SUCCEEDED(Plugin_GetWinampWnd(&hWinamp)))
  332. {
  333. SetWindowLongPtr(hHost, GWLP_HWNDPARENT, (LONGX86)(LONG_PTR)hWinamp);
  334. }
  335. if (NULL == view->browserManager ||
  336. S_OK == view->browserManager->IsFinishing() ||
  337. 0 == PostMessage(hHost, NBHM_DESTROY, 0, 0L))
  338. {
  339. DWORD_PTR result;
  340. SendMessageTimeout(hHost, NBHM_DESTROY, TRUE, 0L, SMTO_NOTIMEOUTIFNOTHUNG | SMTO_BLOCK, 500, &result);
  341. }
  342. }
  343. else
  344. {
  345. aTRACE_LINE("browser control not created");
  346. }
  347. if (NULL != view)
  348. {
  349. view->extendedStyle &= ~(NBCS_EX_BROWSERREADY | NBCS_EX_NAVCOMPLETED );
  350. view->extendedStyle |= NBCS_EX_BLOCKNAVIGATION;
  351. if (NULL != view->browserHook)
  352. {
  353. view->browserHook->Unregister(view->browserManager, view->service);
  354. view->browserHook->Release();
  355. }
  356. if (NULL != view->service)
  357. {
  358. view->service->Release();
  359. view->service = NULL;
  360. }
  361. Plugin_FreeResString(view->storedUrl);
  362. view->storedUrl = NULL;
  363. SysFreeString(view->storedData);
  364. view->storedData = NULL;
  365. if (NULL != view->browserManager)
  366. {
  367. ifc_ombrowserwndmngr *windowManager;
  368. if (SUCCEEDED(view->browserManager->QueryInterface(IFC_OmBrowserWindowManager, (void**)&windowManager)))
  369. {
  370. windowManager->UnregisterWindow(hwnd);
  371. windowManager->Release();
  372. }
  373. ifc_ombrowsereventmngr *eventManager;
  374. if (SUCCEEDED(view->browserManager->QueryInterface(IFC_OmBrowserEventManager, (void**)&eventManager)))
  375. {
  376. eventManager->Signal_WindowClose(hwnd, &WTID_BrowserPopup);
  377. eventManager->Release();
  378. }
  379. view->browserManager->Release();
  380. view->browserManager = NULL;
  381. }
  382. free(view);
  383. }
  384. ifc_wasabihelper *wasabiHelper;
  385. if (SUCCEEDED(Plugin_GetWasabiHelper(&wasabiHelper)))
  386. {
  387. api_application *app;
  388. if (SUCCEEDED(wasabiHelper->GetApplicationApi(&app)))
  389. {
  390. app->app_removeAccelerators(hwnd);
  391. app->Release();
  392. }
  393. wasabiHelper->Release();
  394. }
  395. }
  396. static void BrowserView_OnPaint(HWND hwnd)
  397. {
  398. PAINTSTRUCT ps;
  399. if (BeginPaint(hwnd, &ps))
  400. {
  401. if (ps.rcPaint.left != ps.rcPaint.right)
  402. BrowserView_Paint(hwnd, ps.hdc, &ps.rcPaint, ps.fErase);
  403. EndPaint(hwnd, &ps);
  404. }
  405. }
  406. static void BrowserView_OnPrintClient(HWND hwnd, HDC hdc, UINT options)
  407. {
  408. RECT clientRect;
  409. if (GetClientRect(hwnd, &clientRect))
  410. BrowserView_Paint(hwnd, hdc, &clientRect, 0 != (PRF_ERASEBKGND & options));
  411. }
  412. static void BrowserView_OnWindowPosChanged(HWND hwnd, WINDOWPOS *pwp)
  413. {
  414. if (SWP_NOSIZE == ((SWP_NOSIZE | SWP_FRAMECHANGED) & pwp->flags))
  415. return;
  416. BROWSERVIEW *view = GetView(hwnd);
  417. if (NULL != view)
  418. {
  419. BrowserControl_UpdateLayout(hwnd, 0 == (SWP_NOREDRAW & pwp->flags),
  420. 0 != (SWP_FRAMECHANGED & pwp->flags), view->updateRegion, &view->regionOffset);
  421. }
  422. }
  423. static void BrowserView_OnCommand(HWND hwnd, INT commandId, INT eventId, HWND hControl)
  424. {
  425. switch(commandId)
  426. {
  427. case IDC_TOOLBAR: BrowserControl_ProcessToolbarCommand(hwnd, eventId); break;
  428. case IDC_STATUSBAR: BrowserControl_ProcessStatusbarCommand(hwnd, eventId); break;
  429. default: BrowserControl_ProcessCommonCommand(hwnd, commandId); break;
  430. }
  431. }
  432. static void BrowserView_OnUpdateSkin(HWND hwnd)
  433. {
  434. BROWSERVIEW *view = GetView(hwnd);
  435. if (NULL == view) return;
  436. ifc_skinnedbrowser *skinnedBrowser;
  437. if (SUCCEEDED(Plugin_GetBrowserSkin(&skinnedBrowser)))
  438. {
  439. view->rgbBack = skinnedBrowser->GetBackColor();
  440. skinnedBrowser->Release();
  441. }
  442. else
  443. view->rgbBack = GetSysColor(COLOR_WINDOW);
  444. HWND hControl;
  445. if (NULL != (hControl = GetDlgItem(hwnd, IDC_BROWSER)))
  446. PostMessage(hControl, NBHM_UPDATESKIN, 0, 0L);
  447. if (NULL != (hControl = BrowserControl_GetOperationWidget(hwnd)))
  448. Curtain_UpdateSkin(hControl, FALSE);
  449. if (NULL != (hControl = GetDlgItem(hwnd, IDC_STATUSBAR)))
  450. Statusbar_UpdateSkin(hControl, FALSE);
  451. if (NULL != (hControl = GetDlgItem(hwnd, IDC_TOOLBAR)))
  452. Toolbar_UpdateSkin(hControl, FALSE);
  453. BrowserControl_UpdateLayout(hwnd, TRUE, TRUE, NULL, NULL);
  454. }
  455. static void BrowserView_OnBrowserReady(HWND hwnd)
  456. {
  457. ReplyMessage(0);
  458. BROWSERVIEW *view = GetView(hwnd);
  459. if (NULL == view) return;
  460. view->extendedStyle |= NBCS_EX_BROWSERREADY;
  461. BrowserControl_UpdateLayout(hwnd, FALSE, FALSE, NULL, NULL);
  462. BrowserView_PreformNavigation(hwnd);
  463. HWND hToolbar = BrowserControl_GetToolbar(hwnd);
  464. if (NULL != hToolbar)
  465. Toolbar_EnableItem(hToolbar, TOOLITEM_ADDRESSBAR, TRUE);
  466. }
  467. static void BrowserView_OnDocumentReady(HWND hwnd)
  468. {
  469. BROWSERVIEW *view = GetView(hwnd);
  470. if (NULL == view) return;
  471. if (0 == (NBCS_EX_NAVCOMPLETED & view->extendedStyle))
  472. {
  473. view->extendedStyle |= NBCS_EX_NAVCOMPLETED;
  474. if (NULL != view->storedData)
  475. {
  476. BSTR documentData = view->storedData;
  477. view->storedData = NULL;
  478. if (FALSE == BrowserView_WriteDocument(hwnd, documentData, FALSE))
  479. SysFreeString(documentData);
  480. }
  481. HWND hHost = GetDlgItem(hwnd, IDC_BROWSER);
  482. if (NULL != hHost &&
  483. 0 == (WS_VISIBLE & GetWindowStyle(hHost)))
  484. {
  485. ShowWindowAsync(hHost, SW_SHOWNA);
  486. }
  487. }
  488. }
  489. static void BrowserView_OnBrowserActive(HWND hwnd, BOOL fActive)
  490. {
  491. ReplyMessage(0);
  492. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  493. if (NULL != hToolbar)
  494. {
  495. Toolbar_EnableItem(hToolbar, TOOLITEM_DOWNLOADPROGRESS, fActive);
  496. }
  497. HWND hStatusbar = GetDlgItem(hwnd, IDC_STATUSBAR);
  498. if (NULL != hStatusbar )
  499. {
  500. if (FALSE != fActive && (0 != (WS_DISABLED & GetWindowLongPtr(hStatusbar, GWL_STYLE))))
  501. fActive = FALSE;
  502. Statusbar_SetActive(hStatusbar, fActive);
  503. }
  504. }
  505. static void BrowserView_OnCommandStateChange(HWND hwnd, UINT commandId, BOOL fEnable)
  506. {
  507. ReplyMessage(0);
  508. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  509. if (NULL != hToolbar)
  510. {
  511. switch(commandId)
  512. {
  513. case Browser::commandBack:
  514. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_BACK, fEnable);
  515. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_HISTORY, (FALSE != fEnable) ?
  516. TRUE :
  517. (0 == Toolbar_GetItemStyle(hToolbar, TOOLITEM_BUTTON_FORWARD, TBIS_DISABLED)));
  518. break;
  519. case Browser::commandForward:
  520. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_FORWARD, fEnable);
  521. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_HISTORY, (FALSE != fEnable) ?
  522. TRUE :
  523. (0 == Toolbar_GetItemStyle(hToolbar, TOOLITEM_BUTTON_BACK, TBIS_DISABLED)));
  524. break;
  525. case Browser::commandStop: Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_STOP, fEnable); break;
  526. case Browser::commandRefresh:
  527. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_REFRESH, fEnable);
  528. Toolbar_EnableItem(hToolbar, TOOLITEM_BUTTON_HOME, fEnable);
  529. break;
  530. }
  531. }
  532. }
  533. static void BrowserView_OnStatusChange(HWND hwnd, LPCWSTR pszText)
  534. {
  535. WCHAR szBuffer[512] = {0};
  536. if (NULL == pszText || L'\0' == *pszText)
  537. szBuffer[0] = L'\0';
  538. else
  539. StringCchCopy(szBuffer, ARRAYSIZE(szBuffer), pszText);
  540. ReplyMessage(0);
  541. BrowserView_SetStatusText(hwnd, szBuffer);
  542. }
  543. static void BrowserView_OnSecureIconChange(HWND hwnd, UINT iconId)
  544. {
  545. ReplyMessage(0);
  546. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  547. if (NULL != hToolbar)
  548. {
  549. INT itemId = Toolbar_FindItem(hToolbar, TOOLITEM_BUTTON_SECURECONNECTION);
  550. if (ITEM_ERR != itemId)
  551. {
  552. WCHAR szBuffer[256] = {0};
  553. if(FAILED(FormatEncryptionString(iconId, szBuffer, ARRAYSIZE(szBuffer))))
  554. szBuffer[0] = L'\0';
  555. Toolbar_ShowItem(hToolbar, MAKEINTRESOURCE(itemId), (secureLockIconUnsecure != iconId));
  556. Toolbar_SetItemDescription(hToolbar, MAKEINTRESOURCE(itemId), szBuffer);
  557. }
  558. }
  559. }
  560. static BOOL BrowserView_OnGetOmService(HWND hwnd, void **serviceInstance)
  561. {
  562. if (NULL == serviceInstance)
  563. return FALSE;
  564. *serviceInstance = NULL;
  565. BROWSERVIEW *view = GetView(hwnd);
  566. if (NULL == view || NULL == view->service) return FALSE;
  567. *serviceInstance = view->service;
  568. view->service->AddRef();
  569. return TRUE;
  570. }
  571. static LRESULT BrowserView_OnCreatePopup(HWND hwnd, DISPATCHAPC callback, ULONG_PTR param)
  572. {
  573. ReplyMessage(TRUE);
  574. HWND hPopup = NULL;
  575. UINT windowStyle = GetWindowStyle(hwnd);
  576. if (0 == (NBCS_BLOCKPOPUP & windowStyle))
  577. {
  578. BROWSERVIEW *view = GetView(hwnd);
  579. if (NULL != view)
  580. {
  581. RECT windowRect;
  582. GetWindowRect(hwnd, &windowRect);
  583. UINT popupStyle = NBCS_NOSERVICECOMMANDS | NBCS_DISABLEHOSTCSS;
  584. popupStyle |= (NBCS_POPUPOWNER & GetWindowStyle(hwnd));
  585. HWND hOwner = NULL;
  586. if (0 != (NBCS_POPUPOWNER & popupStyle))
  587. hOwner = hwnd;
  588. hPopup = BrowserPopup_Create(view->browserManager, view->service, popupStyle,
  589. windowRect.left + 12, windowRect.top + 12, 640, 480, hOwner, callback, param);
  590. }
  591. }
  592. if (NULL == hPopup)
  593. {
  594. if (NULL != callback)
  595. callback(NULL, param);
  596. return FALSE;
  597. }
  598. BrowserControl_SetExtendedStyle(hPopup, NBCS_EX_SCRIPTMODE, NBCS_EX_SCRIPTMODE);
  599. BrowserPopup_UpdateSkin(hPopup, FALSE);
  600. return TRUE;
  601. }
  602. static void BrowserView_OnAllowFocusChange(HWND hwnd, BOOL *fAllow)
  603. {
  604. *fAllow = FALSE;
  605. }
  606. static void BrowserView_OnNavigateComplete(HWND hwnd, IDispatch *pDispath, VARIANT *URL, BOOL fTopFrame)
  607. {
  608. if (FALSE == fTopFrame)
  609. return;
  610. LPWSTR pszUrl = NULL;
  611. if (NULL != URL && VT_BSTR == URL->vt && NULL != URL->bstrVal)
  612. pszUrl = Plugin_CopyString(URL->bstrVal);
  613. ReplyMessage(0);
  614. if (NULL != pszUrl)
  615. {
  616. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  617. if (NULL != hToolbar)
  618. {
  619. INT itemId = Toolbar_FindItem(hToolbar, TOOLITEM_ADDRESSBAR);
  620. if (ITEM_ERR != itemId)
  621. Toolbar_SetItemString(hToolbar, MAKEINTRESOURCE(itemId), pszUrl);
  622. }
  623. Plugin_FreeString(pszUrl);
  624. }
  625. }
  626. static void BrowserView_OnTitleChange(HWND hwnd, LPCWSTR pszText)
  627. {
  628. WCHAR szBuffer[256] = {0};
  629. if (NULL == pszText || L'\0' == *pszText) szBuffer[0] = L'\0';
  630. else StringCchCopy(szBuffer, ARRAYSIZE(szBuffer), pszText);
  631. ReplyMessage(0);
  632. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  633. if (NULL != hToolbar)
  634. {
  635. INT itemId = Toolbar_FindItem(hToolbar, TOOLITEM_ADDRESSBAR);
  636. if (ITEM_ERR != itemId)
  637. Toolbar_SetItemDescription(hToolbar, MAKEINTRESOURCE(itemId), szBuffer);
  638. }
  639. }
  640. static void BrowserView_OnBrowserClosing(HWND hwnd, BOOL isChild, BOOL *fCancel)
  641. {
  642. *fCancel = TRUE;
  643. ReplyMessage(0);
  644. }
  645. static LRESULT BrowserView_OnBrowserNotify(HWND hwnd, NMHDR *pnmh)
  646. {
  647. switch(pnmh->code)
  648. {
  649. case NBHN_READY:
  650. BrowserView_OnBrowserReady(hwnd);
  651. break;
  652. case NBHN_DOCUMENTREADY:
  653. BrowserView_OnDocumentReady(hwnd);
  654. break;
  655. case NBHN_BROWSERACTIVE:
  656. BrowserView_OnBrowserActive(hwnd, ((BHNACTIVE*)pnmh)->fActive);
  657. break;
  658. case NBHN_COMMANDSTATECHANGE:
  659. BrowserView_OnCommandStateChange(hwnd, ((BHNCMDSTATE*)pnmh)->commandId, ((BHNCMDSTATE*)pnmh)->fEnabled);
  660. break;
  661. case NBHN_STATUSCHANGE:
  662. BrowserView_OnStatusChange(hwnd, ((BHNTEXTCHANGE*)pnmh)->pszText);
  663. break;
  664. case NBHN_SECUREICONCHANGE:
  665. BrowserView_OnSecureIconChange(hwnd, ((BHNSECUREICON*)pnmh)->iconId);
  666. break;
  667. case NBHN_GETOMSERVICE:
  668. return BrowserView_OnGetOmService(hwnd, &((BHNSERVICE*)pnmh)->instance);
  669. case NBHN_CREATEPOPUP:
  670. return BrowserView_OnCreatePopup(hwnd, ((BHNCREATEPOPUP*)pnmh)->callback, ((BHNCREATEPOPUP*)pnmh)->param);
  671. case NBHN_FOCUSCHANGE:
  672. BrowserView_OnAllowFocusChange(hwnd, &((BHNFOCUSCHANGE*)pnmh)->fAllow);
  673. break;
  674. case NBHN_NAVIGATECOMPLETE:
  675. BrowserView_OnNavigateComplete(hwnd, ((BHNNAVCOMPLETE*)pnmh)->pDispatch, ((BHNNAVCOMPLETE*)pnmh)->URL, ((BHNNAVCOMPLETE*)pnmh)->fTopFrame);
  676. break;
  677. case NBHN_TITLECHANGE:
  678. BrowserView_OnTitleChange(hwnd, ((BHNTEXTCHANGE*)pnmh)->pszText);
  679. break;
  680. case NBHN_CLOSING:
  681. BrowserView_OnBrowserClosing(hwnd, ((BHNCLOSING*)pnmh)->isChild, &((BHNCLOSING*)pnmh)->cancel);
  682. break;
  683. }
  684. return 0;
  685. }
  686. static LRESULT BrowserView_OnNotify(HWND hwnd, INT controlId, NMHDR *pnmh)
  687. {
  688. switch(controlId)
  689. {
  690. case IDC_BROWSER:
  691. return BrowserView_OnBrowserNotify(hwnd, pnmh);
  692. }
  693. return 0;
  694. }
  695. static LRESULT BrowserView_OnNavigate(HWND hwnd, LPCWSTR navigateUrl, BOOL fScheduleBlocked)
  696. {
  697. BROWSERVIEW *view = GetView(hwnd);
  698. if (NULL == view) return FALSE;
  699. UINT windowStyle = GetWindowStyle(hwnd);
  700. if (NULL != view->browserHook)
  701. view->browserHook->CheckBlockedState(view->service);
  702. Plugin_FreeResString(view->storedUrl);
  703. view->storedUrl = NULL;
  704. if (NBCS_EX_BROWSERREADY != ((NBCS_EX_BROWSERREADY | NBCS_EX_BLOCKNAVIGATION) & view->extendedStyle))
  705. {
  706. if (FALSE == fScheduleBlocked)
  707. return FALSE;
  708. view->storedUrl = Plugin_DuplicateResString(navigateUrl);
  709. return TRUE;
  710. }
  711. HWND hHost = GetDlgItem(hwnd, IDC_BROWSER);
  712. if (NULL == hHost) return FALSE;
  713. LPWSTR pszDescription = NULL;
  714. BSTR url = NULL;
  715. if (IS_INTRESOURCE(navigateUrl))
  716. {
  717. switch((INT_PTR)navigateUrl)
  718. {
  719. case NAVIGATE_BLANK:
  720. BrowserView_SetStatusText(hwnd, NULL);
  721. url = SysAllocString(L"about:blank");
  722. break;
  723. case NAVIGATE_HOME:
  724. if (0 == (NBCS_NOSERVICECOMMANDS & windowStyle) && NULL != view->service)
  725. {
  726. WCHAR szBuffer[8192] = {0};
  727. if (SUCCEEDED(view->service->GetUrl(szBuffer, ARRAYSIZE(szBuffer))))
  728. {
  729. BrowserView_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_HOME_DESCRIPTION));
  730. url = SysAllocString(szBuffer);
  731. }
  732. if (SUCCEEDED(view->service->GetName(szBuffer, ARRAYSIZE(szBuffer))))
  733. pszDescription = Plugin_CopyString(szBuffer);
  734. }
  735. break;
  736. case NAVIGATE_BACK:
  737. BrowserView_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_BACK_DESCRIPTION));
  738. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandBack, 0L);
  739. case NAVIGATE_FORWARD:
  740. BrowserView_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_FORWARD_DESCRIPTION));
  741. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandForward, 0L);
  742. case NAVIGATE_STOP:
  743. BrowserView_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_STOP_DESCRIPTION));
  744. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandStop, 0L);
  745. case NAVIGATE_REFRESH:
  746. BrowserView_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_REFRESH_DESCRIPTION));
  747. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandRefresh, 0L);
  748. case NAVIGATE_REFRESH_COMPLETELY:
  749. BrowserView_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_REFRESH_DESCRIPTION));
  750. return PostMessage(hHost, NBHM_CONTAINERCOMMAND, (WPARAM)Browser::commandRefreshCompletely, 0L);
  751. }
  752. }
  753. else
  754. {
  755. BrowserView_SetStatusTextRes(hwnd, MAKEINTRESOURCE(IDS_NAVIGATING));
  756. url = SysAllocString(navigateUrl);
  757. }
  758. if (NULL == url)
  759. return FALSE;
  760. HWND hToolbar = GetDlgItem(hwnd, IDC_TOOLBAR);
  761. INT addressbarId = (NULL != hToolbar) ? Toolbar_FindItem(hToolbar, TOOLITEM_ADDRESSBAR) : ITEM_ERR;
  762. if (ITEM_ERR != addressbarId)
  763. {
  764. Toolbar_SetItemString(hToolbar, MAKEINTRESOURCE(addressbarId), url);
  765. Toolbar_SetItemDescription(hToolbar, MAKEINTRESOURCE(addressbarId), pszDescription);
  766. }
  767. if (!PostMessage(hHost, NBHM_NAVIGATE, 0, (LPARAM)url))
  768. {
  769. SysFreeString(url);
  770. return FALSE;
  771. }
  772. Plugin_FreeString(pszDescription);
  773. return TRUE;
  774. }
  775. static LRESULT BrowserView_OnWriteDocument(HWND hwnd, BSTR documentData, BOOL fScheduleBlocked)
  776. {
  777. BROWSERVIEW *view = GetView(hwnd);
  778. if (NULL == view) return FALSE;
  779. SysFreeString(view->storedData);
  780. view->storedData = NULL;
  781. Plugin_FreeResString(view->storedUrl);
  782. view->storedUrl = NULL;
  783. if (0 == (NBCS_EX_NAVCOMPLETED & view->extendedStyle))
  784. {
  785. if (FALSE == fScheduleBlocked)
  786. return FALSE;
  787. view->storedData = documentData;
  788. return TRUE;
  789. }
  790. HWND hHost = GetDlgItem(hwnd, IDC_BROWSER);
  791. if (NULL == hHost) return FALSE;
  792. return PostMessage(hHost, NBHM_WRITEDOCUMENT, 0, (LPARAM)documentData);
  793. }
  794. static void BrowserView_OnSetUpdateRegion(HWND hwnd, HRGN updateRegion, POINTS regionOffset)
  795. {
  796. BROWSERVIEW *view = GetView(hwnd);
  797. if (NULL == view) return;
  798. view->updateRegion = updateRegion;
  799. view->regionOffset.x = regionOffset.x;
  800. view->regionOffset.y = regionOffset.y;
  801. }
  802. static LRESULT BrowserView_OnGetService(HWND hwnd, ifc_omservice **serviceOut)
  803. {
  804. if (NULL == serviceOut) return FALSE;
  805. BROWSERVIEW *view = GetView(hwnd);
  806. if (NULL == view || NULL == view->service)
  807. {
  808. *serviceOut = NULL;
  809. return FALSE;
  810. }
  811. *serviceOut = view->service;
  812. (*serviceOut)->AddRef();
  813. return TRUE;
  814. }
  815. static LRESULT BrowserView_OnGetBrowserObject(HWND hwnd, obj_ombrowser **browserOut)
  816. {
  817. if (NULL == browserOut) return FALSE;
  818. BROWSERVIEW *view = GetView(hwnd);
  819. if (NULL == view || NULL == view->browserManager)
  820. {
  821. *browserOut = NULL;
  822. return FALSE;
  823. }
  824. *browserOut = view->browserManager;
  825. (*browserOut)->AddRef();
  826. return TRUE;
  827. }
  828. static LRESULT BrowserView_OnGetToolbar(HWND hwnd)
  829. {
  830. if (0 != (NBCS_NOTOOLBAR & GetWindowStyle(hwnd)))
  831. return 0;
  832. return (LRESULT)GetDlgItem(hwnd, IDC_TOOLBAR);
  833. }
  834. static LRESULT BrowserView_OnGetStatusbar(HWND hwnd)
  835. {
  836. if (0 != (NBCS_NOSTATUSBAR & GetWindowStyle(hwnd)))
  837. return 0;
  838. return (LRESULT)GetDlgItem(hwnd, IDC_STATUSBAR);
  839. }
  840. static LRESULT BrowserView_OnGetHost(HWND hwnd)
  841. {
  842. return (LRESULT)GetDlgItem(hwnd, IDC_BROWSER);
  843. }
  844. static LRESULT BrowserView_OnAppCommand(HWND hwnd, HWND hTarget, INT commandId, INT deviceId, INT keys)
  845. {
  846. return BrowserControl_ProcessAppCommand(hwnd, commandId);
  847. }
  848. static LRESULT BrowserView_OnNavigateStoredUrl(HWND hwnd)
  849. {
  850. BROWSERVIEW *view = GetView(hwnd);
  851. if (NULL == view || NULL == view->storedUrl)
  852. return FALSE;
  853. LPWSTR url = view->storedUrl;
  854. view->storedUrl = NULL;
  855. BOOL result = BrowserView_Navigate(hwnd, url, TRUE);
  856. Plugin_FreeResString(url);
  857. return result;
  858. }
  859. static LRESULT BrowserView_OnSetExtendedStyle(HWND hwnd, UINT extMask, UINT extStyle)
  860. {
  861. BROWSERVIEW *view = GetView(hwnd);
  862. if (NULL == view) return 0;
  863. UINT currentStyle = view->extendedStyle;
  864. view->extendedStyle = (currentStyle & ~extMask) | (extStyle & extMask);
  865. return currentStyle;
  866. }
  867. static LRESULT BrowserView_OnGetExtendedStyle(HWND hwnd)
  868. {
  869. BROWSERVIEW *view = GetView(hwnd);
  870. return (NULL != view) ? view->extendedStyle : 0;
  871. }
  872. static LRESULT CALLBACK BrowserView_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  873. {
  874. switch (uMsg)
  875. {
  876. case WM_CREATE: return BrowserView_OnCreate(hwnd, (CREATESTRUCT*)lParam);
  877. case WM_DESTROY: BrowserView_OnDestroy(hwnd); break;
  878. case WM_ERASEBKGND: return 0;
  879. case WM_PAINT: BrowserView_OnPaint(hwnd); return 0;
  880. case WM_PRINTCLIENT: BrowserView_OnPrintClient(hwnd, (HDC)wParam, (UINT)lParam); return 0;
  881. case WM_WINDOWPOSCHANGED: BrowserView_OnWindowPosChanged(hwnd, (WINDOWPOS*)lParam); return 0;
  882. case WM_COMMAND: BrowserView_OnCommand(hwnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam); break;
  883. case WM_NOTIFY: return BrowserView_OnNotify(hwnd, (INT)wParam, (NMHDR*)lParam);
  884. case WM_APPCOMMAND: return BrowserView_OnAppCommand(hwnd, (HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam));
  885. case NBCM_GETTOOLBAR: return BrowserView_OnGetToolbar(hwnd);
  886. case NBCM_GETSTATUSBAR: return BrowserView_OnGetStatusbar(hwnd);
  887. case NBCM_GETHOST: return BrowserView_OnGetHost(hwnd);
  888. case NBCM_UPDATESKIN: BrowserView_OnUpdateSkin(hwnd); return 0;
  889. case NBCM_GETSERVICE: return BrowserView_OnGetService(hwnd, (ifc_omservice**)lParam);
  890. case NBCM_NAVIGATE: return BrowserView_OnNavigate(hwnd, (LPCWSTR)lParam, (BOOL)wParam);
  891. case NBCM_WRITEDOCUMENT: return BrowserView_OnWriteDocument(hwnd, (BSTR)lParam, (BOOL)wParam);
  892. case NBCM_GETBROWSEROBJECT: return BrowserView_OnGetBrowserObject(hwnd, (obj_ombrowser**)lParam);
  893. case NBCM_SHOWOPERATION: return BrowserControl_OnShowOperation(hwnd, (OPERATIONINFO*)lParam);
  894. case NBCM_NAVSTOREDURL: return BrowserView_OnNavigateStoredUrl(hwnd);
  895. case NBCM_BLOCK: BrowserControl_SetBlockedState(hwnd, (BOOL)lParam); return 0;
  896. case NBCM_SETEXTSTYLE: return BrowserView_OnSetExtendedStyle(hwnd, (UINT)wParam, (UINT)lParam);
  897. case NBCM_GETEXTSTYLE: return BrowserView_OnGetExtendedStyle(hwnd);
  898. // gen_ml flickerless drawing
  899. case WM_USER + 0x200: return 1;
  900. case WM_USER + 0x201: BrowserView_OnSetUpdateRegion(hwnd, (HRGN)lParam, MAKEPOINTS(wParam)); return 0;
  901. }
  902. if (FALSE != Plugin_IsDirectMouseWheelMessage(uMsg))
  903. {
  904. SendMessage(hwnd, WM_MOUSEWHEEL, wParam, lParam);
  905. return TRUE;
  906. }
  907. return DefWindowProcW(hwnd, uMsg, wParam, lParam);
  908. }
  909. static BOOL BrowserView_RegisterClass(HINSTANCE hInstance)
  910. {
  911. WNDCLASS wc;
  912. if (GetClassInfo(hInstance, NWC_OMBROWSERVIEW, &wc)) return TRUE;
  913. ZeroMemory(&wc, sizeof(WNDCLASS));
  914. wc.hInstance = hInstance;
  915. wc.lpszClassName = NWC_OMBROWSERVIEW;
  916. wc.lpfnWndProc = BrowserView_WindowProc;
  917. wc.style = CS_DBLCLKS;
  918. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  919. wc.hbrBackground = NULL;
  920. wc.cbWndExtra = sizeof(BROWSERVIEW*);
  921. return ( 0 != RegisterClassW(&wc));
  922. }