dispInfo.item.mask = LVIF_TEXT;
dispInfo.item.iItem = wnd->editRow;
dispInfo.item.iSubItem = wnd->editCol;
dispInfo.item.pszText = newText;
dispInfo.item.cchTextMax = (int)strlen(newText);
SendMessage(wnd->hTable, WM_NOTIFY, (WPARAM)0, (LPARAM)&dispInfo);
int item_id = (int)SendMessage(hWnd, CB_GETITEMDATA,
SendMessage(hWnd, CB_GETCURSEL, 0, 0), 0);
char value[16];
wsprintf(value, "%d", item_id);
update_item (wnd, value);
free(newText);
DestroyWindow(hWnd);
break;
}
}
break;
}
case WM_KILLFOCUS:
{
HWND hParent = GetParent(hWnd);
LVWnd_t * wnd = (LVWnd_t*) GetWindowLong (hParent, GWL_USERDATA);
if (wnd == 0)
break;
ListView_SetItemState(hParent, wnd->editRow, LVIS_SELECTED, LVIS_SELECTED);
/* return focus to the parent */
SetFocus(hParent);
DestroyWindow(hWnd);
break;
}
}
return CallWindowProc(origComboWndProc, hWnd, mMsg, wParam, lParam);
}
Файл gui\gui_global.h :
#define WM_DRAW_ITEMS 40030
#define IDM_VIEW_RESULT 40031
extern HWND hMainWnd, hMDIClientWnd, hCombo, hListView;
extern HACCEL hAccel;
extern HWND hStudentsWnd, hStudentsListWnd;
extern HWND hGroupsWnd, hGroupsListWnd;
extern HWND hResultsWnd, hResultsListWnd;
extern HWND hLessonsWnd, hLessonsListWnd;
extern TCHAR app_name [];
extern TCHAR main_wnd_class [];
extern TCHAR table_wnd_class [];
extern TCHAR result_wnd_class [];
extern int hash;
extern OPENFILENAME ofn;
extern TCHAR filename[MAX_PATH];
#define columns 4
struct COLUMN
{
TCHAR * text;
DWORD length;
};
/* forward declaration */
int InitGUI();
void error_msg(const TCHAR * msg);
void add_combo_item(const HWND hWnd, const TCHAR * text, int data);
void sort_column(const HWND hWnd, const int column_id);
void save_result(TCHAR * name, HWND hWnd, int cols);
LRESULT CALLBACK AboutWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK SelectUserWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK LoginUserWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ChangePasswordWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK SearchWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK SQLWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ResultsWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK TableWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
Файл gui\table.h :
#pragma once
#define ASIZE(array) (sizeof(array)/sizeof(array[0]))
#define SET_PARAM(a,b,c) (((a)<<16) + ((b)<<8) + (c))
#define GET_PARAM(a,b,c,z) do {\
int rz = (z);\
a = (rz & 0xFF0000L)>>16;\
b = (rz & 0xFF00L)>>8;\
c = (rz & 0xFFL);\
}while (0)
enum COLUMN_TYPE
{
CT_NULL,
CT_CONST, /* can't edit from GUI */
CT_TEXT,
CT_COMBO, /* used reference to another table */
CT_COMBO_EX, /* вычисляемое поле */
CT_COMBO_BOOL /* да|нет */
};
struct column_t
{
char * name;
enum COLUMN_TYPE type;
int width;
int ref_tid, ref_cid;
};
struct LVWnd_t
{
char * name;
int cols, rows;
int editCol, editRow;
int tid; /* table ID */
HWND hTable, hLV;
};
extern int tables;
extern column_t * table[];
extern LVWnd_t * window[];
int get_row_id(LVWnd_t * wnd);
int get_focused_item(const HWND);
void add_listview_row(const HWND, const int, TCHAR **);
int create_mdi_listview(TCHAR * wnd_class, TCHAR * caption, HWND * parent, HWND * child, column_t * cols);
int create_result_listview(TCHAR * wnd_class, TCHAR * caption, HWND * parent, HWND * child, column_t * cols);
int create_mdi_table(LVWnd_t * wnd);
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.