view_errorinfo.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #include "main.h"
  2. #include "api__ml_local.h"
  3. #include "..\..\General\gen_ml/config.h"
  4. #include "resource.h"
  5. #include "..\..\General\gen_ml/ml_ipc_0313.h"
  6. static HRGN g_rgnUpdate = NULL;
  7. static int offsetX = 0, offsetY = 0;
  8. static void LayoutWindows(HWND hwnd, BOOL fRedraw)
  9. {
  10. RECT rc, rg;
  11. HRGN rgn;
  12. GetClientRect(hwnd, &rc);
  13. SetRect(&rg, 0, 0, 0, 0);
  14. rc.top += 2;
  15. rc.right -=2;
  16. if (rc.bottom <= rc.top || rc.right <= rc.left) return;
  17. rgn = NULL;
  18. HWND temp = GetDlgItem(hwnd, IDC_DB_ERROR);
  19. GetWindowRect(temp, &rg);
  20. SetWindowPos(temp, NULL, WASABI_API_APP->getScaleX(20), WASABI_API_APP->getScaleY(20),
  21. rc.right - rc.left - WASABI_API_APP->getScaleX(40),
  22. rc.bottom - rc.top - WASABI_API_APP->getScaleY(45),
  23. SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOREDRAW);
  24. temp = GetDlgItem(hwnd, IDC_RESET_DB_ON_ERROR);
  25. GetWindowRect(temp, &rg);
  26. SetWindowPos(temp, NULL, ((rc.right - rc.left) - (rg.right - rg.left)) / 2,
  27. rc.bottom - (rg.bottom - rg.top),
  28. rg.right - rg.left, rg.bottom - rg.top,
  29. SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOREDRAW);
  30. InvalidateRect(hwnd, NULL, TRUE);
  31. if (fRedraw)
  32. {
  33. UpdateWindow(hwnd);
  34. }
  35. if (g_rgnUpdate)
  36. {
  37. GetUpdateRgn(hwnd, g_rgnUpdate, FALSE);
  38. if (rgn)
  39. {
  40. OffsetRgn(rgn, rc.left, rc.top);
  41. CombineRgn(g_rgnUpdate, g_rgnUpdate, rgn, RGN_OR);
  42. }
  43. }
  44. ValidateRgn(hwnd, NULL);
  45. if (rgn) DeleteObject(rgn);
  46. }
  47. INT_PTR CALLBACK view_errorinfoDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  48. {
  49. BOOL a=dialogSkinner.Handle(hwndDlg,uMsg,wParam,lParam); if (a) return a;
  50. switch(uMsg)
  51. {
  52. case WM_INITDIALOG:
  53. {
  54. SetWindowText(GetDlgItem(hwndDlg, IDC_DB_ERROR),(LPCWSTR)WASABI_API_LOADRESFROMFILEW(L"TEXT", MAKEINTRESOURCE((nde_error ? IDR_NDE_ERROR : IDR_DB_ERROR)), 0));
  55. if (nde_error)
  56. DestroyWindow(GetDlgItem(hwndDlg, IDC_RESET_DB_ON_ERROR));
  57. MLSKINWINDOW m = {0};
  58. m.skinType = SKINNEDWND_TYPE_DIALOG;
  59. m.hwndToSkin = hwndDlg;
  60. m.style = SWS_USESKINFONT | SWS_USESKINCOLORS | SWS_USESKINCURSORS;
  61. MLSkinWindow(plugin.hwndLibraryParent, &m);
  62. }
  63. return TRUE;
  64. case WM_COMMAND:
  65. if(LOWORD(wParam) == IDC_RESET_DB_ON_ERROR)
  66. {
  67. nukeLibrary(hwndDlg);
  68. }
  69. break;
  70. case WM_WINDOWPOSCHANGED:
  71. if ((SWP_NOSIZE | SWP_NOMOVE) != ((SWP_NOSIZE | SWP_NOMOVE) & ((WINDOWPOS*)lParam)->flags) ||
  72. (SWP_FRAMECHANGED & ((WINDOWPOS*)lParam)->flags))
  73. {
  74. LayoutWindows(hwndDlg, !(SWP_NOREDRAW & ((WINDOWPOS*)lParam)->flags));
  75. }
  76. return 0;
  77. case WM_USER+66:
  78. if (wParam == -1)
  79. {
  80. LayoutWindows(hwndDlg, TRUE);
  81. }
  82. return TRUE;
  83. case WM_USER + 0x200:
  84. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 1); // yes, we support no - redraw resize
  85. return TRUE;
  86. case WM_USER + 0x201:
  87. offsetX = (short)LOWORD(wParam);
  88. offsetY = (short)HIWORD(wParam);
  89. g_rgnUpdate = (HRGN)lParam;
  90. return TRUE;
  91. case WM_PAINT:
  92. {
  93. dialogSkinner.Draw(hwndDlg, 0, 0);
  94. }
  95. return 0;
  96. case WM_ERASEBKGND:
  97. return 1; //handled by WADlg_DrawChildWindowBorders in WM_PAINT
  98. }
  99. return FALSE;
  100. }