Эксперт
Покинул форум
Сообщений всего: 1837
Дата рег-ции: Март 2017
Репутация: -2
|
Kibor , Вылетает код (Отобразить)CODE://-----------------------------------------------------------------------------------------------------------------------------------------------------
#define LBS_NOSEL 16384
#define WS_BORDER 8388608
#define WS_HSCROLL 1048576
#define WS_VSCROLL 2097152
#define WS_CHILD 1073741824
#define WS_VISIBLE 268435456
#define LBS_DISABLENOSCROLL 4096
#define LB_SETHORIZONTALEXTENT 404
#define LB_ADDSTRING 384
#define LB_GETCOUNT 395
#define LB_GETTEXT 393
#define LB_DELETESTRING 386
external(INT, "CreateWindow", "CreateWindowExA", "User32.dll" );
external(INT, "GetTextExtentPoint32", "GetTextExtentPoint32A", "Gdi32.dll" );
external(INT, "GetDC", "GetDC", "User32.dll" );
external(INT, "GetPrivateProfileString", "GetPrivateProfileStringA", "kernel32.dll");
external(INT, "WritePrivateProfileString", "WritePrivateProfileStringA", "kernel32.dll");
external(INT, "Strftime", "Strftime", pathfolder()+"Time.dll" );
external(INT, "SendMessage", "SendMessageA", "User32.dll" );
string date = "22.04.2019";
string path = "C:\Users\Home\AppData\Local\Temp\K2019Bot_Log.ini";
int Year, Month, DayOfWeek, Day, Hour, Minute, Second, Milliseconds;
int list, b1, hdc, max_length = 0;
char Time[100];
char Date[100];
char Text_Listbox1[255];
createdialog(0);
showdialog(0, "Диалог",100, 100, 300, 300, 1, 1);
//-----------------------------------------------------------------------------------------------------------------------------------------------------
loop()
{
getlocaltime(Year, Month, DayOfWeek, Day, Hour, Minute, Second, Milliseconds);
Strftime(address(#Time[0]), sizearray(Time), "%X", Hour, Minute, Second, Day, Month, Year);
Strftime(address(#Date[0]), sizearray(Date), "%d.%m.%y", Hour, Minute, Second, Day, Month, Year);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
function getmessage(0, WM_COMMAND)
{
if (message.lparam==b1)
{
int count;
add_list("["+format(#Time[0])+"] - Бот запущен.");
count = sendmessage(LB_GETCOUNT, 0, 0, formatiw(list));
if(count)sendmessage(LB_GETTEXT, count-1, address(#Text_Listbox1[0]), formatiw(list));
messagebox(format(#Text_Listbox1[0]));
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
function getmessage(0, WM_CREATE)
{
list = CreateWindow(0, "LISTBOX", "", LBS_NOSEL | WS_BORDER | WS_HSCROLL | WS_VSCROLL | LBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE, 10, 10, 200, 200, gethwnd(0), 0, 0, 0);
b1=CreateWindow(0, "BUTTON", "Запустить", WS_CHILD | WS_VISIBLE, 10, 220, 120, 30, gethwnd(0), 0, 0, 0);
hdc=GetDC(list);
ini_read();
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
function add_list(string s)
{
int SIZE[2];
new char c[size(s)+1];
strcpy(#c[0], s);
GetTextExtentPoint32(hdc, address(#c[0]), sizearray(c), address(#SIZE[0]));
if(max_length<SIZE[0])
{
max_length=SIZE[0];
sendmessage(LB_SETHORIZONTALEXTENT, SIZE[0], 0, formatiw(list));
}
sendmessage(LB_ADDSTRING, 0, address(#c[0]), formatiw(list));
delete c;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
function ini_read()
{
int length;
char key_ini[99999], value[999];
if(fopen(path, "rb"))
{
fclose();
//add_list("["+date+"]");
int x = GetPrivateProfileString (date, 0, 0, address (#key_ini[0]), sizearray(key_ini), path);
if(x)
{
length=0;
for(int i=0; length<=x; i++)
{
if(GetPrivateProfileString (date, format(#key_ini[length]), 0, address (#value[0]), sizearray(value), path)) // получить значение ключа
{
add_list(+"["+format(#key_ini[length])+"] - "+format(#value[0]));
}
length=length+size(#key_ini[length])+1;
}
}
else
{
messagebox("секция даты не найдена");
WritePrivateProfileString(date, "", "", path);
ini_read();
}
}
else
{
messagebox("файл не найден");
fopen(path, "w");
{
fclose();
}
ini_read();
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
|