1
0

view_container.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. #include "main.h"
  2. #include "./resource.h"
  3. #include "../nu/DialogSkinner.h"
  4. #include "../nu/AutoWideFn.h"
  5. #include "./commandbar.h"
  6. #include "./settings.h"
  7. #include "../nu/trace.h"
  8. //#include <primosdk.h>
  9. #include <windowsx.h>
  10. #include <strsafe.h>
  11. #define MINIINFO_HEIGHT 100
  12. #define IDC_CHILDVIEW 0x1000
  13. #define IDC_MINIINFO 0x1001
  14. #define IDC_COMMAND_BAR 0x1002
  15. #define WINDOWS_SPACING 3
  16. #define CONTAINER_PROPW L"CONTAINER"
  17. typedef struct _CONTAINER
  18. {
  19. CHAR cLetter;
  20. INT typeChild;
  21. BOOL bInfoVisible;
  22. HANDLE hLastQuery;
  23. } CONTAINER;
  24. static UINT msgNotify = 0;
  25. #define GetContainer(__hwnd) ((CONTAINER*)GetPropW(__hwnd, CONTAINER_PROPW))
  26. static INT_PTR WINAPI DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  27. // public function
  28. typedef struct _CONTAINER_PARAM
  29. {
  30. CHAR cLetter;
  31. BOOL bQueryInfo;
  32. }CONTAINER_PARAM;
  33. HWND CreateContainerWindow(HWND hwndParent, CHAR cLetter, BOOL bQueryInfo)
  34. {
  35. CONTAINER_PARAM param;
  36. param.cLetter = cLetter;
  37. param.bQueryInfo = bQueryInfo;
  38. return WASABI_API_CREATEDIALOGPARAMW(IDD_VIEW_CONTAINER, hwndParent, DlgProc, (LPARAM)&param);
  39. }
  40. static void ViewContainer_LayoutChildren(HWND hdlg, BOOL bRedraw)
  41. {
  42. RECT rc;
  43. HWND hctrl;
  44. HDWP hdwp;
  45. DWORD flags;
  46. CONTAINER *pc = GetContainer(hdlg);
  47. if (!pc) return;
  48. if (!GetClientRect(hdlg, &rc)) return;
  49. rc.right -= 2;
  50. flags = SWP_NOACTIVATE | ((bRedraw) ? 0 : SWP_NOREDRAW);
  51. hdwp = BeginDeferWindowPos(3);
  52. if (!hdwp) return;
  53. if (NULL != (hctrl = GetDlgItem(hdlg, IDC_COMMAND_BAR)))
  54. {
  55. INT height = CommandBar_GetBestHeight(hctrl);
  56. hdwp = DeferWindowPos(hdwp, hctrl, HWND_BOTTOM, rc.left, rc.bottom - (height), rc.right - rc.left, height, flags);
  57. rc.bottom -= (height + WINDOWS_SPACING);
  58. }
  59. if (NULL != (hctrl = GetDlgItem(hdlg, IDC_MINIINFO)) && pc->bInfoVisible)
  60. {
  61. INT height = MINIINFO_HEIGHT;
  62. hdwp = DeferWindowPos(hdwp, hctrl, HWND_TOP, rc.left, rc.bottom - height, rc.right - rc.left, height, flags);
  63. rc.bottom -= (height + WINDOWS_SPACING);
  64. }
  65. if (NULL != (hctrl = GetDlgItem(hdlg, IDC_CHILDVIEW)))
  66. {
  67. hdwp = DeferWindowPos(hdwp, hctrl, HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, flags);
  68. }
  69. EndDeferWindowPos(hdwp);
  70. }
  71. static void CreateChild(HWND hParent, INT typeId, LPARAM param, BOOL fCreateAlways = TRUE)
  72. {
  73. DM_NOTIFY_PARAM hdr;
  74. CONTAINER *pc = GetContainer(hParent);
  75. if (!pc) return;
  76. HWND hChild = GetDlgItem(hParent, IDC_CHILDVIEW);
  77. if (hChild)
  78. {
  79. if (pc->typeChild == typeId && !fCreateAlways) return;
  80. DestroyWindow(hChild);
  81. }
  82. hChild = NULL;
  83. pc->typeChild = 0;
  84. switch(typeId)
  85. {
  86. case IDD_VIEW_INFO:
  87. hChild = CreateInfoWindow(hParent, (CHAR)(0xFF & param));
  88. break;
  89. case IDD_VIEW_WAIT:
  90. hChild = CreateWaitWindow(hParent, (CHAR)(0xFF & param));
  91. break;
  92. case IDD_VIEW_CDROM:
  93. if (param <= 0xFF)
  94. {
  95. ZeroMemory(&hdr, sizeof(DM_NOTIFY_PARAM));
  96. hdr.cLetter = (CHAR)(0xFF & (INT)param);
  97. hdr.opCode = DMOP_GENERAL;
  98. param = (INT_PTR)&hdr;
  99. }
  100. hChild = CreateCDViewWindow(hParent, (DM_NOTIFY_PARAM*)param);
  101. break;
  102. case IDD_VIEW_CDROM_EX2:
  103. hChild = CreateCDRipWindow(hParent, (CHAR)(0xFF & param));
  104. break;
  105. case IDD_VIEW_CDROM_DATA:
  106. hChild = CreateCdDataViewWindow(hParent, (CHAR)(0xFF & param));
  107. break;
  108. }
  109. TRACE_FMT(L"Creating cd view (%d)\n", typeId);
  110. if (hChild)
  111. {
  112. pc->typeChild = typeId;
  113. SetWindowLongPtrW(hChild, GWLP_ID, IDC_CHILDVIEW);
  114. ViewContainer_LayoutChildren(hParent, TRUE);
  115. ShowWindow(hChild, SW_SHOWNA);
  116. }
  117. }
  118. static HWND CreateMiniInfoWindow(HWND hwndParent)
  119. {
  120. RECT rw;
  121. HWND hwnd;
  122. WEBINFOCREATE wic;
  123. GetWindowRect(hwndParent, &rw);
  124. wic.hwndParent = hwndParent;
  125. wic.uMsgQuery = WM_QUERYFILEINFO;
  126. wic.ctrlId = IDC_MINIINFO;
  127. wic.cx = rw.right - rw.left - 3;
  128. wic.cy = MINIINFO_HEIGHT;
  129. wic.x = 0;
  130. wic.y = (rw.bottom - rw.top) - MINIINFO_HEIGHT - 1;
  131. hwnd = (HWND)SENDMLIPC(plugin.hwndLibraryParent, ML_IPC_CREATEWEBINFO, (WPARAM)&wic);
  132. if (hwnd)
  133. {
  134. SetWindowLongPtrW(hwnd, GWL_EXSTYLE, GetWindowLongPtrW(hwnd, GWL_EXSTYLE) | WS_EX_CLIENTEDGE);
  135. MLSkinWindow2(plugin.hwndLibraryParent, hwnd, SKINNEDWND_TYPE_WINDOW, SWS_USESKINCOLORS);
  136. }
  137. return hwnd;
  138. }
  139. static void CALLBACK FreeAsyncParam(DM_NOTIFY_PARAM *phdr)
  140. {
  141. DM_MCI_PARAM *pmci;
  142. switch(phdr->opCode)
  143. {
  144. case DMOP_MCIINFO:
  145. pmci = (DM_MCI_PARAM*)phdr;
  146. if (pmci->pTracks) free(pmci->pTracks);
  147. break;
  148. case DMOP_IMAPIINFO:
  149. break;
  150. }
  151. free(phdr);
  152. }
  153. static void QueryDriveRecordable(HWND hwnd, CHAR cLetter)
  154. {
  155. CONTAINER *pc = GetContainer(hwnd);
  156. if (!pc) return;
  157. DWORD dwType;
  158. dwType = DriveManager_GetDriveType(cLetter);
  159. if (0 == (DRIVE_CAP_UNKNOWN & dwType))
  160. {
  161. CreateChild(hwnd, ((DRIVE_CAP_R | DRIVE_CAP_RW) & dwType) ? IDD_VIEW_CDROM_BURN : IDD_VIEW_CDROM, (LPARAM)cLetter);
  162. return;
  163. }
  164. else
  165. {
  166. DM_UNITINFO_PARAM *pui;
  167. pui = (DM_UNITINFO_PARAM*)calloc(1, sizeof(DM_UNITINFO_PARAM));
  168. if (pui)
  169. {
  170. pui->header.callback = (INT_PTR)hwnd;
  171. pui->header.uMsg = msgNotify;
  172. pui->header.cLetter = cLetter;
  173. pui->header.fnFree = FreeAsyncParam;
  174. pc->hLastQuery = pui;
  175. if (!DriveManager_GetUnitInfo(pui)) CreateChild(hwnd, IDD_VIEW_CDROM, (LPARAM)cLetter);
  176. }
  177. }
  178. }
  179. static void QueryDiscInfo(HWND hwnd, CHAR cLetter)
  180. {
  181. DM_MCI_PARAM *pmci;
  182. CHAR cMode;
  183. CONTAINER *pc = GetContainer(hwnd);
  184. if (!pc) return;
  185. cMode = DriveManager_GetDriveMode(cLetter);
  186. switch(cMode)
  187. {
  188. case DM_MODE_RIPPING:
  189. if (cdrip_isextracting(cLetter)) CreateChild(hwnd, IDD_VIEW_CDROM_EX2, cLetter);
  190. else CreateChild(hwnd, IDD_VIEW_INFO, cLetter);
  191. return;
  192. case DM_MODE_COPYING:
  193. if (IDD_VIEW_CDROM_DATA == pc->typeChild) return;
  194. break;
  195. case DM_MODE_READY:
  196. if (IDD_VIEW_CDROM_DATA == pc->typeChild) return;
  197. break;
  198. }
  199. CreateChild(hwnd, IDD_VIEW_WAIT, cLetter);
  200. pmci = (DM_MCI_PARAM*)calloc(1, sizeof(DM_MCI_PARAM));
  201. if (pmci)
  202. {
  203. pmci->header.callback = (INT_PTR)hwnd;
  204. pmci->header.uMsg = msgNotify;
  205. pmci->header.cLetter = cLetter;
  206. pmci->header.fnFree = FreeAsyncParam;
  207. pmci->header.fFlags = DMF_READY | DMF_MEDIUMPRESENT | DMF_MODE | DMF_TRACKCOUNT | DMF_TRACKSINFO;
  208. pmci->nTracks = 256;
  209. pmci->pTracks = (DWORD*)calloc(pmci->nTracks, sizeof(DWORD));
  210. pc->hLastQuery = pmci;
  211. if (!DriveManager_GetMCIInfo(pmci))
  212. {
  213. pc->hLastQuery = NULL;
  214. // display error dialog
  215. }
  216. }
  217. }
  218. static void Medium_OnArrived(HWND hwnd, CHAR cLetter)
  219. {
  220. QueryDiscInfo(hwnd, cLetter);
  221. }
  222. static void Medium_OnRemoved(HWND hwnd, CHAR cLetter)
  223. {
  224. QueryDriveRecordable(hwnd, cLetter);
  225. }
  226. static void Drive_OnModeChanged(HWND hwnd, CHAR cLetter, CHAR cMode)
  227. {
  228. QueryDiscInfo(hwnd, cLetter);
  229. HWND hctrl = GetDlgItem(hwnd, IDC_CHILDVIEW);
  230. if (hctrl) SendMessage(hctrl, WM_COMMAND, MAKEWPARAM(ID_DRIVE_MODE_CHANGED, 0), (LPARAM)hwnd);
  231. }
  232. static void GetInfo_Completed(HWND hwnd, DM_NOTIFY_PARAM *phdr)
  233. {
  234. DM_MCI_PARAM *pmci;
  235. CONTAINER *pc = GetContainer(hwnd);
  236. if (!pc || phdr != pc->hLastQuery) return;
  237. switch(phdr->opCode)
  238. {
  239. case DMOP_MCIINFO:
  240. pmci = (DM_MCI_PARAM*)phdr;
  241. if (0 == phdr->result)
  242. {
  243. if (pmci->bMediumPresent && pmci->nTracks > 0)
  244. {
  245. int i;
  246. for (i = 0; i < pmci->nTracks; i++) if (0x80000000 & pmci->pTracks[i]) break;
  247. if (i == pmci->nTracks) CreateChild(hwnd, IDD_VIEW_CDROM_DATA, (LPARAM)phdr->cLetter);
  248. else CreateChild(hwnd, IDD_VIEW_CDROM, (LPARAM)phdr);
  249. }
  250. else QueryDriveRecordable(hwnd, phdr->cLetter);
  251. }
  252. else {/*go to error view*/ }
  253. break;
  254. case DMOP_UNITINFO:
  255. CreateChild(hwnd, ( 0 == phdr->result && Drive_IsRecorderType(((DM_UNITINFO_PARAM*)phdr)->dwType)) ? IDD_VIEW_CDROM_BURN : IDD_VIEW_CDROM, (LPARAM)phdr->cLetter);
  256. break;
  257. }
  258. }
  259. static BOOL ViewContainer_OnGetMiniInfoEnabled(HWND hdlg)
  260. {
  261. return g_config->ReadInt(TEXT("useminiinfo2"), 0);
  262. }
  263. static INT_PTR Window_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  264. {
  265. CONTAINER_PARAM *param = (CONTAINER_PARAM*)lParam;
  266. CONTAINER *pc = (CONTAINER*)calloc(1, sizeof(CONTAINER));
  267. if (pc)
  268. {
  269. pc->cLetter = param->cLetter;
  270. SetPropW(hwnd, CONTAINER_PROPW, pc);
  271. }
  272. MLSkinWindow2(plugin.hwndLibraryParent, hwnd, SKINNEDWND_TYPE_DIALOG, SWS_USESKINFONT | SWS_USESKINCOLORS | SWS_USESKINCURSORS);
  273. BOOL bVal = FALSE;
  274. if (S_OK == Settings_GetBool(C_GLOBAL, GF_SHOWINFO, &bVal) && bVal)
  275. SendMessageW(hwnd, WM_COMMAND, MAKEWPARAM(IDC_BTN_SHOWINFO, BN_CLICKED), (LPARAM)NULL);
  276. if (!msgNotify) msgNotify = RegisterWindowMessageW(L"cdrom_notify_msg");
  277. Plugin_RegisterListener(hwnd, msgNotify, pc->cLetter);
  278. if (param->bQueryInfo) QueryDiscInfo(hwnd, pc->cLetter);
  279. if (WASABI_API_APP)
  280. {
  281. HACCEL hAccel = WASABI_API_LOADACCELERATORSW(IDR_ACCELERATOR_VIEW);
  282. if (hAccel) WASABI_API_APP->app_addAccelerators(hwnd, &hAccel, 1, TRANSLATE_MODE_CHILD);
  283. WASABI_API_APP->ActiveDialog_Register(hwnd);
  284. }
  285. return 0;
  286. }
  287. static void Window_OnDestroy(HWND hdlg)
  288. {
  289. Plugin_UnregisterListener(hdlg);
  290. if (WASABI_API_APP) WASABI_API_APP->app_removeAccelerators(hdlg);
  291. HWND hctrl = GetDlgItem(hdlg, IDC_MINIINFO);
  292. if (hctrl && IsWindow(hctrl)) SENDMLIPC(hctrl, ML_IPC_WEBINFO_RELEASE, 0);
  293. CONTAINER *pc = GetContainer(hdlg);
  294. if (pc)
  295. {
  296. Settings_SetBool(C_GLOBAL, GF_SHOWINFO, pc->bInfoVisible);
  297. RemovePropW(hdlg, CONTAINER_PROPW);
  298. free(pc);
  299. }
  300. }
  301. static void Window_OnDisplayChange(HWND hdlg, INT dpi, INT resX, INT resY)
  302. {
  303. SendDlgItemMessageW(hdlg, IDC_CHILDVIEW, WM_DISPLAYCHANGE, dpi, MAKELPARAM(resX, resY));
  304. SendDlgItemMessageW(hdlg, IDC_MINIINFO, WM_DISPLAYCHANGE, dpi, MAKELPARAM(resX, resY));
  305. SendDlgItemMessageW(hdlg, IDC_COMMAND_BAR, WM_DISPLAYCHANGE, dpi, MAKELPARAM(resX, resY));
  306. }
  307. static void ViewContainer_OnWindowPosChanged(HWND hdlg, WINDOWPOS *pwp)
  308. {
  309. RECT rc, rw;
  310. HWND hctrl;
  311. HDWP hdwp;
  312. DWORD flags;
  313. CONTAINER *pc = GetContainer(hdlg);
  314. if (!pc) return;
  315. if (SWP_FRAMECHANGED & pwp->flags)
  316. {
  317. ViewContainer_LayoutChildren(hdlg, (SWP_NOREDRAW & pwp->flags));
  318. return;
  319. }
  320. if (0 != (SWP_NOSIZE & pwp->flags)) return;
  321. if (!GetClientRect(hdlg, &rc)) return;
  322. rc.right -= 2;
  323. flags = SWP_NOACTIVATE | SWP_NOZORDER | ((SWP_NOREDRAW | SWP_NOCOPYBITS) & pwp->flags);
  324. hdwp = BeginDeferWindowPos(3);
  325. if (NULL != (hctrl = GetDlgItem(hdlg, IDC_COMMAND_BAR)) && GetWindowRect(hctrl, &rw))
  326. {
  327. hdwp = DeferWindowPos(hdwp, hctrl, HWND_BOTTOM, rc.left, rc.bottom - (rw.bottom - rw.top), rc.right - rc.left, (rw.bottom - rw.top), flags);
  328. rc.bottom -= (rw.bottom - rw.top + WINDOWS_SPACING);
  329. }
  330. if (pc->bInfoVisible && NULL != (hctrl = GetDlgItem(hdlg, IDC_MINIINFO)) && GetWindowRect(hctrl, &rw))
  331. {
  332. hdwp = DeferWindowPos(hdwp, hctrl, HWND_BOTTOM, rc.left, rc.bottom - (rw.bottom - rw.top), rc.right - rc.left, (rw.bottom - rw.top), flags);
  333. rc.bottom -= (rw.bottom - rw.top + WINDOWS_SPACING);
  334. }
  335. if (NULL != (hctrl = GetDlgItem(hdlg, IDC_CHILDVIEW)))
  336. {
  337. hdwp = DeferWindowPos(hdwp, hctrl, HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, flags | SWP_NOMOVE);
  338. }
  339. EndDeferWindowPos(hdwp);
  340. }
  341. static void ViewContainer_ShowMiniInfo(HWND hdlg, BOOL bShow)
  342. {
  343. CONTAINER *pc = GetContainer(hdlg);
  344. if (!pc) return;
  345. pc->bInfoVisible = FALSE;
  346. HWND hInfo = GetDlgItem(hdlg, IDC_MINIINFO);
  347. if (bShow && !hInfo) hInfo = CreateMiniInfoWindow(hdlg);
  348. if (hInfo)
  349. {
  350. if (bShow)
  351. {
  352. pc->bInfoVisible = TRUE;
  353. ViewContainer_LayoutChildren(hdlg, TRUE);
  354. ShowWindow(hInfo, SW_SHOWNA);
  355. UpdateWindow(hInfo);
  356. }
  357. else
  358. {
  359. ShowWindow(hInfo, SW_HIDE);
  360. ViewContainer_LayoutChildren(hdlg, TRUE);
  361. }
  362. }
  363. HWND hctrl = GetDlgItem(hdlg, IDC_CHILDVIEW);
  364. if (hctrl && NULL != (hctrl = GetDlgItem(hctrl, IDC_BTN_SHOWINFO)))
  365. SetWindowTextW(hctrl, WASABI_API_LNGSTRINGW((bShow) ? IDS_HIDE_INFO : IDS_SHOW_INFO));
  366. }
  367. static void Window_OnCommand(HWND hdlg, INT eventId, INT ctrlId, HWND hctrl)
  368. {
  369. CONTAINER *pc = GetContainer(hdlg);
  370. if (!pc) return;
  371. switch(ctrlId)
  372. {
  373. case IDC_BTN_SHOWINFO:
  374. switch(eventId)
  375. {
  376. case BN_CLICKED:
  377. ViewContainer_ShowMiniInfo(hdlg, !pc->bInfoVisible);
  378. break;
  379. case BN_EX_GETTEXT:
  380. {
  381. if (IsWindow(hctrl))
  382. {
  383. // to ensure we're able to remove this for all views, we check this here
  384. if (!ViewContainer_OnGetMiniInfoEnabled(hdlg))
  385. DestroyWindow(hctrl);
  386. else
  387. SetWindowTextW(hctrl, WASABI_API_LNGSTRINGW((pc->bInfoVisible) ? IDS_HIDE_INFO : IDS_SHOW_INFO));
  388. }
  389. break;
  390. }
  391. }
  392. break;
  393. case ID_MINIINFO_SHOW: ViewContainer_ShowMiniInfo(hdlg, !pc->bInfoVisible); break;
  394. case ID_EJECT_DISC: DriveManager_Eject(pc->cLetter, DM_EJECT_CHANGE); break;
  395. case ID_COPY_SELECTION: SendDlgItemMessageW(hdlg, IDC_CHILDVIEW, WM_COMMAND, MAKEWPARAM(ctrlId, eventId), (LPARAM)hctrl); break;
  396. }
  397. }
  398. static void Window_OnFileTagUpdated(HWND hdlg, WORD wCode, INT_PTR param)
  399. {
  400. HWND hChild = GetDlgItem(hdlg, IDC_CHILDVIEW);
  401. if (hChild && IsWindow(hChild))
  402. {
  403. SendMessageW(hChild, WM_TAGUPDATED, 0,
  404. (LPARAM)((IPC_FILE_TAG_MAY_HAVE_UPDATED == wCode) ? AutoWideFn((LPCSTR)param) : (LPCWSTR)param));
  405. }
  406. }
  407. static void Window_OnPluginNotify(HWND hdlg, WORD wCode, INT_PTR param)
  408. {
  409. switch(wCode)
  410. {
  411. case DMW_MEDIUMARRIVED: Medium_OnArrived(hdlg, (CHAR)param); break;
  412. case DMW_MEDIUMREMOVED: Medium_OnRemoved(hdlg, (CHAR)param); break;
  413. case DMW_OPCOMPLETED: GetInfo_Completed(hdlg, (DM_NOTIFY_PARAM*)param); break;
  414. case DMW_MODECHANGED: Drive_OnModeChanged(hdlg, (CHAR)LOWORD(param), (CHAR)(LOWORD(param) >> 8)); break;
  415. case IPC_FILE_TAG_MAY_HAVE_UPDATED:
  416. case IPC_FILE_TAG_MAY_HAVE_UPDATEDW: Window_OnFileTagUpdated(hdlg, wCode, param); break;
  417. }
  418. }
  419. static INT_PTR Window_OnSendFileInfo(HWND hdlg, LPCWSTR pszFileName, UINT fFlags)
  420. {
  421. WEBINFOSHOW wis;
  422. HWND hInfo = GetDlgItem(hdlg, IDC_MINIINFO);
  423. if (!hInfo) return 0;
  424. wis.pszFileName = pszFileName;;
  425. wis.fFlags = fFlags;
  426. return (INT_PTR)SENDMLIPC(hInfo, ML_IPC_WEBINFO_SHOWINFO, (WPARAM)&wis);
  427. }
  428. static void Window_OnQueryFileInfo(HWND hdlg)
  429. {
  430. HWND hChild = GetDlgItem(hdlg, IDC_CHILDVIEW);
  431. if(!hChild || !PostMessageW(hChild, WM_QUERYFILEINFO, 0, 0L)) Window_OnSendFileInfo(hdlg, L"", WISF_FORCE);
  432. }
  433. INT_PTR CALLBACK CommandBar_DialogProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  434. static HWND ViewContainer_OnCreateCommandBar(HWND hdlg, CMDBARCREATESTRUCT *pcbcs)
  435. {
  436. if (!pcbcs || !pcbcs->fnDialogProc) return NULL;
  437. HWND hwndBar = WASABI_API_CREATEDIALOGPARAMW(pcbcs->resourceId, hdlg, CommandBar_DialogProc, (LPARAM)pcbcs);
  438. if (hwndBar)
  439. {
  440. SetWindowLongPtrW(hwndBar, GWLP_ID, IDC_COMMAND_BAR);
  441. ViewContainer_LayoutChildren(hdlg, TRUE);
  442. ShowWindow(hwndBar, SW_SHOWNA);
  443. }
  444. return hwndBar;
  445. }
  446. static BOOL ViewContainer_OnDestroyCommandBar(HWND hdlg)
  447. {
  448. HWND hwndBar = GetDlgItem(hdlg, IDC_COMMAND_BAR);
  449. if (!hwndBar) return FALSE;
  450. DestroyWindow(hwndBar);
  451. ViewContainer_LayoutChildren(hdlg, TRUE);
  452. return TRUE;
  453. }
  454. static BOOL ViewContainer_OnGetMiniInfoVisible(HWND hdlg)
  455. {
  456. HWND hctrl = GetDlgItem(hdlg, IDC_MINIINFO);
  457. return (hctrl && IsWindowVisible(hctrl));
  458. }
  459. static BOOL ViewContainer_OnExtractDisc(HWND hdlg, WPARAM wParam, LPARAM lParam)
  460. {
  461. HWND hChild = GetDlgItem(hdlg, IDC_CHILDVIEW);
  462. return (hChild) ? (BOOL)SendMessageW(hChild, WM_EXTRACTDISC, wParam, lParam) : FALSE;
  463. }
  464. static INT_PTR WINAPI DlgProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  465. {
  466. switch(uMsg)
  467. {
  468. case WM_INITDIALOG: return (INT_PTR)Window_OnInitDialog(hdlg, (HWND)wParam, lParam);
  469. case WM_DESTROY: Window_OnDestroy(hdlg); break;
  470. case WM_DISPLAYCHANGE: Window_OnDisplayChange(hdlg, (INT)wParam, LOWORD(lParam), HIWORD(lParam)); break;
  471. case WM_WINDOWPOSCHANGED: ViewContainer_OnWindowPosChanged(hdlg, (WINDOWPOS*)lParam); return TRUE;
  472. case WM_COMMAND: Window_OnCommand(hdlg, HIWORD(wParam), LOWORD(wParam), (HWND)lParam); break;
  473. case WM_QUERYFILEINFO: Window_OnQueryFileInfo(hdlg); return 1;
  474. case WM_SHOWFILEINFO: MSGRESULT(hdlg, Window_OnSendFileInfo(hdlg, (LPCWSTR)lParam, (UINT)wParam));
  475. case WM_EXTRACTDISC: MSGRESULT(hdlg, ViewContainer_OnExtractDisc(hdlg, wParam, lParam));
  476. case VCM_CREATECOMMANDBAR: MSGRESULT(hdlg, ViewContainer_OnCreateCommandBar(hdlg, (CMDBARCREATESTRUCT*)lParam));
  477. case VCM_DESTROYCOMMANDBAR: MSGRESULT(hdlg, ViewContainer_OnDestroyCommandBar(hdlg));
  478. case VCM_GETCOMMANDBAR: MSGRESULT(hdlg, GetDlgItem(hdlg, IDC_COMMAND_BAR));
  479. case VCM_GETMININFOENABLED: MSGRESULT(hdlg, ViewContainer_OnGetMiniInfoEnabled(hdlg));
  480. case VCM_GETMININFOVISIBLE: MSGRESULT(hdlg, ViewContainer_OnGetMiniInfoVisible(hdlg));
  481. case WM_USER + 0x200: MSGRESULT(hdlg, TRUE);
  482. }
  483. if (msgNotify == uMsg) Window_OnPluginNotify(hdlg, (WORD)wParam, (INT_PTR)lParam);
  484. return 0;
  485. }