Разработка информационно-поисковой системы, страница 15

                        SendMessage(hMainWnd, WM_COMMAND, IDM_VIEW_RESULT,0);

                        /* удаление всех элементов в списке */

                        SendMessage(hResultsListWnd, LVM_DELETEALLITEMS,0,0);

                        /* выполнение SQL-команды */

                        callback_param_t param = {MODE_LISTVIEW, NULL, hResultsListWnd};

                        exec_sql_cmd(cmd, &param);

                        EndDialog(hWnd, LOWORD(wParam));

                        return TRUE;

                  }

                  case IDCANCEL:

                        EndDialog(hWnd, LOWORD(wParam));

                        break;

                  case IDC_CHECK_1:

                        check[0] = !check[0];

                        break;

                  case IDC_CHECK_2:

                        check[1] = !check[1];

                        break;

                  case IDC_CHECK_3:

                        check[2] = !check[2];

                        break;

                  case IDC_CHECK_4:

                        check[3] = !check[3];

                        break;

                  case IDC_CHECK_5:

                        check[4] = !check[4];

                        break;

            }

      }

      return FALSE;

}

Файл gui\sql_cmd_wnd.c :

#include "..\CORE\main.h"

/* Обработчик сообщений окна "Execute SQL command" */

LRESULT CALLBACK SQLWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

{

      static HWND hEdit;

      switch (message)

      {

      case WM_INITDIALOG:

            hEdit = GetDlgItem (hWnd, IDC_EDIT_SQL_CMD);

            return TRUE;

      case WM_COMMAND:

            if (LOWORD(wParam) == IDOK)

            {

                  char cmd[256];

                  /* получение команды */

                  GetWindowText (hEdit, (LPSTR)cmd, sizeof(cmd));

                  /* выполнение SQL-комманды */

                  callback_param_t param = {MODE_LISTVIEW | MODE_DEBUG, NULL, hListView};

                  exec_sql_cmd (cmd, &param);

            }    

            else

            if (LOWORD(wParam) == IDCANCEL)

                  EndDialog(hWnd, LOWORD(wParam));

            return TRUE;

      }

      return FALSE;

}

Файл gui\users_wnd.c :

/* Обработчик сообщений окна "Выбор пользователя" */

LRESULT CALLBACK SelectUserWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

{

      int wmId = LOWORD(wParam);

      switch (message)

      {

      case WM_INITDIALOG:

            // выбор гостя как пользователя, выбраного по умолчанию

            selected_user = 2;

            lstrcpy(user_name,"Guest");

            SendDlgItemMessage(hWnd, IDC_RADIO1, BM_SETCHECK, BST_CHECKED, 0);

            return TRUE;

      case WM_COMMAND:

            switch (wmId)

            {

                  // выбран "Гость"

                  case IDC_RADIO1:

                        selected_user = 2;

                        lstrcpy(user_name,"Guest");

                break;

                  // выбран "Пользователь"

                  case IDC_RADIO2:

                        selected_user = 1;

                        lstrcpy(user_name,"User");

                        break;

                  // выбран "Администратор"

                  case IDC_RADIO3:

                        selected_user = 0;

                        lstrcpy(user_name,"Admin");

                        break;

            }

            if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)

            {

                  EndDialog(hWnd, LOWORD(wParam));

                  return TRUE;

            }

      }

      return FALSE;

}

Файл gui\table.c :

#include "..\CORE\main.h"

TCHAR table_wnd_class [] = "table_wnd_class";

LRESULT CALLBACK TableWndProc(HWND, UINT, WPARAM, LPARAM);

LRESULT CALLBACK LVWndProc(HWND, UINT, WPARAM, LPARAM);

LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM);

LRESULT CALLBACK ComboWndProc(HWND, UINT, WPARAM, LPARAM);

WNDPROC origLVWndProc = NULL;