ui.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // ui.cpp : Defines the entry point for the application.
  2. //
  3. #include <windows.h>
  4. #include "resource.h"
  5. HINSTANCE g_hInstance;
  6. HWND m_curwnd;
  7. LPTSTR windows[] = {
  8. MAKEINTRESOURCE(IDD_LICENSE),
  9. MAKEINTRESOURCE(IDD_SELCOM),
  10. MAKEINTRESOURCE(IDD_DIR),
  11. MAKEINTRESOURCE(IDD_INSTFILES),
  12. MAKEINTRESOURCE(IDD_UNINST)
  13. };
  14. BOOL CALLBACK GenericProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
  15. static LOGBRUSH b = {BS_SOLID, RGB(255,0,0), 0};
  16. static HBRUSH red;
  17. if (!red)
  18. red = CreateBrushIndirect(&b);
  19. switch (uMsg) {
  20. case WM_CTLCOLORSTATIC:
  21. return (int)red;
  22. }
  23. return 0;
  24. }
  25. BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
  26. static int i = -1;
  27. switch (uMsg) {
  28. case WM_INITDIALOG:
  29. ShowWindow(GetDlgItem(hwndDlg, IDC_CHILDRECT), SW_SHOW);
  30. ShowWindow(hwndDlg, SW_SHOW);
  31. break;
  32. case WM_COMMAND:
  33. switch (LOWORD(wParam)) {
  34. case IDOK:
  35. case IDC_BACK:
  36. i+=(LOWORD(wParam)==IDOK)?1:-1;
  37. if (i < 0) {
  38. i++;
  39. break;
  40. }
  41. if (i >= (int)sizeof(windows)/sizeof(char*)) {
  42. i--;
  43. break;
  44. }
  45. if (m_curwnd) DestroyWindow(m_curwnd);
  46. m_curwnd=CreateDialog(g_hInstance,windows[i],hwndDlg,GenericProc);
  47. if (m_curwnd)
  48. {
  49. RECT r;
  50. GetWindowRect(GetDlgItem(hwndDlg,IDC_CHILDRECT),&r);
  51. ScreenToClient(hwndDlg,(LPPOINT)&r);
  52. SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
  53. ShowWindow(m_curwnd,SW_SHOWNA);
  54. }
  55. break;
  56. default:
  57. EndDialog(hwndDlg, 0);
  58. PostQuitMessage(0);
  59. break;
  60. }
  61. break;
  62. }
  63. return 0;
  64. }
  65. int APIENTRY WinMain(HINSTANCE hInstance,
  66. HINSTANCE hPrevInstance,
  67. LPSTR lpCmdLine,
  68. int nCmdShow)
  69. {
  70. g_hInstance = GetModuleHandle(0);
  71. DialogBox(
  72. g_hInstance,
  73. MAKEINTRESOURCE(IDD_INST),
  74. 0,
  75. DialogProc
  76. );
  77. ExitProcess(0);
  78. return 0;
  79. }