База данных пилотов Формулы 1

Реферат - Компьютеры, программирование

Другие рефераты по предмету Компьютеры, программирование

t;,NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,40,150,25,hwnd,NULL,hInstance,NULL);

 

edit_tituls = CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,70,150,25,hwnd,NULL,hInstance,NULL);

edit_wons = CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,100,150,25,hwnd,NULL,hInstance,NULL);

edit_pouls = CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,130,150,25,hwnd,NULL,hInstance,NULL);

edit_blaps = CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,160,150,25,hwnd,NULL,hInstance,NULL);

edit_races = CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,190,150,25,hwnd,NULL,hInstance,NULL);

edit_frace = CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,220,150,25,hwnd,NULL,hInstance,NULL);

edit_find = CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,320,230,150,25,hwnd,NULL,hInstance,NULL);

 

 

/* Вносим текст */

text_1 = CreateWindow("static","Famely",WS_CHILD|WS_VISIBLE,5,15,50,15,hwnd,NULL,hInstance,NULL);

text_2 = CreateWindow("static","Name",WS_CHILD|WS_VISIBLE,5,45,50,15,hwnd,NULL,hInstance,NULL);

text_3 = CreateWindow("static","Tituls",WS_CHILD|WS_VISIBLE,5,75,50,15,hwnd,NULL,hInstance,NULL);

text_4 = CreateWindow("static","Wons",WS_CHILD|WS_VISIBLE,5,105,50,15,hwnd,NULL,hInstance,NULL);

text_5 = CreateWindow("static","Pouls",WS_CHILD|WS_VISIBLE,5,135,50,15,hwnd,NULL,hInstance,NULL);

text_6 = CreateWindow("static","Best laps",WS_CHILD|WS_VISIBLE,5,165,65,15,hwnd,NULL,hInstance,NULL);

text_7 = CreateWindow("static","Races",WS_CHILD|WS_VISIBLE,5,195,50,15,hwnd,NULL,hInstance,NULL);

text_8 = CreateWindow("static","First race",WS_CHILD|WS_VISIBLE,5,225,65,15,hwnd,NULL,hInstance,NULL);

text_9 = CreateWindow("static","Sort result:",WS_CHILD|WS_VISIBLE,250,5,75,15,hwnd,NULL,hInstance,NULL);

text_10 = CreateWindow("static","Find result:",WS_CHILD|WS_VISIBLE,370,5,75,15,hwnd,NULL,hInstance,NULL);

text_11 = CreateWindow("static","Search:",WS_CHILD|WS_VISIBLE,260,235,60,15,hwnd,NULL,hInstance,NULL);

text_number = CreateWindow("static","0",WS_CHILD|WS_VISIBLE,230,270,15,15,hwnd,NULL,hInstance,NULL);

 

// отображаем и обновляем окно

ShowWindow(hwnd, nCmdShow);

UpdateWindow(hwnd);

 

menu = LoadMenu(hInstance, MAKEINTRESOURCE(ID_MENU));

SetMenu(hwnd, menu);

 

//цикл обработки сообщений

while(GetMessage(&msg, NULL, 0, 0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

 

return 0;

};

 

 

int i=0;

// оконная функция

LRESULT CALLBACK WindowFunc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)

{

switch(iMsg)

{

case WM_DESTROY:

PostQuitMessage(0);

break;

 

case WM_COMMAND:

{

if(((HWND)lParam == button_last) && (HIWORD(wParam) == BN_CLICKED))

{

if(number>1)

{

number--;

// Сохраняем элемент

char text[50];

GetWindowText(edit_blaps,text,20);

app.racers[number].blaps = atoi((const char *)text);

GetWindowText(edit_famely,text,20);

app.racers[number].famely = (string) text;

GetWindowText(edit_frace,text,20);

app.racers[number].frace = (string) text;

GetWindowText(edit_name,text,20);

app.racers[number].name = (string) text;

GetWindowText(edit_pouls,text,20);

app.racers[number].pouls = atoi((const char *)text);

GetWindowText(edit_races,text,20);

app.racers[number].races = atoi((const char *)text);

GetWindowText(edit_tituls,text,20);

app.racers[number].tituls = atoi((const char *)text);

GetWindowText(edit_wons,text,20);

app.racers[number].wons = atoi((const char *)text);

 

// Записываем новый

SetWindowText(edit_famely, (char*)app.racers[number-1].famely.c_str());

SetWindowText(edit_name, (char*)app.racers[number-1].name.c_str());

itoa(app.racers[number-1].tituls,text,10);

SetWindowText(edit_tituls, text);

itoa(app.racers[number-1].wons,text,10);

SetWindowText(edit_wons, text);

itoa(app.racers[number-1].pouls,text,10);

SetWindowText(edit_pouls, text);

itoa(app.racers[number-1].blaps,text,10);

SetWindowText(edit_blaps, text);

itoa(app.racers[number-1].races,text,10);

SetWindowText(edit_races, text);

SetWindowText(edit_frace,app.racers[number-1].frace.c_str());

itoa(number,text,10);

SetWindowText(text_number,text);

 

};

};

 

// Кнопка далее

if(((HWND)lParam == button_next) && (HIWORD(wParam) == BN_CLICKED))

{

if(number<app.racers.size())

{

number--;

// Сохраняем элемент

char text[50];

GetWindowText(edit_blaps,text,20);

app.racers[number].blaps = atoi((const char *)text);

GetWindowText(edit_famely,text,20);

app.racers[number].famely = (string) text;

GetWindowText(edit_frace,text,20);

app.racers[number].frace = (string) text;

GetWindowText(edit_name,text,20);

app.racers[number].name = (string) text;

GetWindowText(edit_pouls,text,20);

app.racers[number].pouls = atoi((const char *)text);

GetWindowText(edit_races,text,20);

app.racers[number].races = atoi((const char *)text);

GetWindowText(edit_tituls,text,20);

app.racers[number].tituls = atoi((const char *)text);

GetWindowText(edit_wons,text,20);

app.racers[number].wons = atoi((const char *)text);

 

// Записываем новый

number++;

SetWindowText(edit_famely, char*)app.racers[number].famely.c_str());

SetWindowText(edit_name, (char*)app.racers[number].name.c_str());

itoa(app.racers[number].tituls,text,10);

SetWindowText(edit_tituls, text);

itoa(app.racers[number].wons,text,10);

SetWindowText(edit_wons, text);

itoa(app.racers[number].pouls,text,10);

SetWindowText(edit_pouls, text);

itoa(app.racers[number].blaps,text,10);

SetWindowText(edit_blaps, text);

itoa(app.racers[number].races,text,10);

SetWindowText(edit_races, text);

SetWindowText(edit_frace,app.racers[number].

frace.c_str());

number++;

itoa(number,text,10);

SetWindowText(text_number,text);

 

};

};

 

switch(wParam)

{

case IDM_FILENEW:

app.db_close();

app.db_add_item();

number=0;

SetWindowText(edit_famely, (char*)app.racers[number].famely.c_str());

SetWindowText(edit_name, (char*)app.racers[number].name.c_str());

char text[50];

itoa(app.racers[number].tituls,text,10);

SetWindowText(edit_tituls, text);

itoa(app.racers[number].wons,text,10);SetWindowText(edit_wons, text);

itoa(app.racers[number].pouls,text,10);

SetWindowText(edit_pouls, text);

itoa(app.racers[number].blaps,text,10);

SetWindowText(edit_blaps, text);

itoa(app.racers[number].races,text,10);

SetWindowText(edit_races, text);

SetWindowText(edit_frace,app.racers[number]

.frace.c_str());

number++;

itoa(number,text,10);

SetWindowText(text_number,text);

 

return 0;

 

case IDM_FILEOPEN: // Открываем фаил базы данных

number=1;

app.db_close(); // Хакрываем базу данных

 

OPENFILENAME ofn;

char szFile[260];

// Initialize OPENFILENAME

ZeroMemory(&ofn, sizeof(ofn));

ofn.lStructSize = sizeof(ofn);

ofn.hwndOwner = hwnd;

ofn.lpstrFile = szFile;

ofn.lpstrFile[0] = \0;

ofn.nMaxFile = sizeof(szFile);

ofn.lpstrFilter = "Schnaider Yuri data base\0*.bd\0";

ofn.nFilterIndex = 1;

ofn.lpstrFileTitle = NULL;

ofn.nMaxFileTitle = 0;

ofn.lpstrInitialDir = NULL;

ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

 

if (GetOpenFileName(&ofn)==TRUE) // Reading

{

if(app.db_load( (const char *) ofn.lpstrFile))

{

SetWindowText(edit_famely, (char*)app.racers[0].famely.c_str());

SetWindowText(edit_name, (char*)app.racers[0].name.c_str());

char text[10];

itoa(app.racers[0].tituls,text,10);

SetWindowText(edit_tituls, text);

itoa(app.racers[0].wons,text,10);

SetWindowText(edit_wons, text);

itoa(app.racers[0].pouls