Ещё ошибки появились, не верно считывает данные из ini
И при закрытии скрипта он должен сохранять новые значения в скролах но вместо этого Кибор вылетает с ошибкой. Что не так?
Код (Отобразить)
CODE:
#define WS_BORDER 8388608
#define WS_CHILD 1073741824
#define WS_VISIBLE 268435456
external(INT, "CreateWindow", "CreateWindowExA", "User32.dll" );
external(INT, "SetScrollRange", "SetScrollRange", "User32.dll" );
external(INT, "SetScrollPos", "SetScrollPos", "User32.dll" );
external(INT, "SetWindowText", "SetWindowTextA", "User32.dll" );
external (INT, "GetPrivateProfileString", "GetPrivateProfileStringA", "kernel32.dll");
external (INT, "WritePrivateProfileString", "WritePrivateProfileStringA", "kernel32.dll");
char str[255];
string path=pathfolder()+"setting.ini";
int i;
int b1, b2, s1[3], hText[3], hwnd;
createdialog(0);
showdialog(0, "Диалог",100, 100, 240, 290, 4, 1);
int count_scroll=3;
int min[3]={0, 0, 0}
int max[3]={200, 200, 200}
int pos[3];
for(i=0; i<count_scroll; i++)
{
SetScrollRange(s1[i],2,min[i],max[i],1);
SetScrollPos(s1[i],2,pos[i],1);
}
if(fopen(path, "r")!=0)
{
fclose();
GetPrivateProfileString ("Default", "Edit0", 0, address (#str[0]), 255, path); //pos[0]
pos[0]=formatsn(format (#str[0]));
GetPrivateProfileString ("Default", "Edit1", 0, address (#str[0]), 255, path); //pos[1]
pos[1]=formatsn(format (#str[1]));
GetPrivateProfileString ("Default", "Edit2", 0, address (#str[0]), 255, path); //pos[2]
pos[2]=formatsn(format (#str[2]));
}
dalnost();
loop()sleep(1);
function dalnost()
{
SetWindowText(hText[0], format(pos[0]));
SetWindowText(hText[1], format(pos[1]));
SetWindowText(hText[2], format(pos[2]));
}
function getmessage(0, WM_HSCROLL)
{
for(i=0; i<count_scroll; i++)
{
if (message.lparam==s1[i])
{
if (message.wparam==1 || message.wparam==3)//SB_LINERIGHT
{
pos[i]=pos[i]+10;
if (pos[i]>max[i])pos[i]=max[i];
SetScrollPos(s1[i],2,pos[i],1);
dalnost();
return;
}
if (message.wparam==0 || message.wparam==2)//SB_LINELEFT
{
pos[i]=pos[i]-10;
if (pos[i]<min[i])pos[i]=min[i];
SetScrollPos(s1[i],2,pos[i],1);
dalnost();
return;
}
///////////
if (loword(message.wparam)==5)
{
pos[i]=pos[i]-(pos[i]-hiword(message.wparam));
if (pos[i]>max[i])pos[i]=max[i];
if (pos[i]<min[i])pos[i]=min[i];
SetScrollPos(s1[i],2,pos[i],1);
dalnost();
}
}
}
}
function getmessage(0, WM_CREATE)
{
hwnd = gethwnd(0);
s1[0]=CreateWindow(0, "scrollbar", 0, WS_CHILD | WS_VISIBLE, 10, 50, 200, 20, hwnd, 0, 0, 0);
hText[0] = CreateWindow(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 10, 80, 100, 15, hwnd, 0, 0, 0);
s1[1]=CreateWindow(0, "scrollbar", 0, WS_CHILD | WS_VISIBLE, 10, 120, 200, 20, hwnd, 0, 0, 0);
hText[1] = CreateWindow(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 30, 150, 100, 15, hwnd, 0, 0, 0);
s1[2]=CreateWindow(0, "scrollbar", 0, WS_CHILD | WS_VISIBLE, 10, 200, 200, 20, hwnd, 0, 0, 0);
hText[2] = CreateWindow(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 30, 220, 100, 15, hwnd, 0, 0, 0);
}
function getmessage(0, WM_CLOSE)
{
WritePrivateProfileString ("Default", "Edit0", pos[0], path);
WritePrivateProfileString ("Default", "Edit1", pos[1], path);
WritePrivateProfileString ("Default", "Edit2", pos[2], path);
}
#define WS_BORDER 8388608
#define WS_CHILD 1073741824
#define WS_VISIBLE 268435456
external(INT, "CreateWindow", "CreateWindowExA", "User32.dll" );
external(INT, "SetScrollRange", "SetScrollRange", "User32.dll" );
external(INT, "SetScrollPos", "SetScrollPos", "User32.dll" );
external(INT, "SetWindowText", "SetWindowTextA", "User32.dll" );
external (INT, "GetPrivateProfileString", "GetPrivateProfileStringA", "kernel32.dll");
external (INT, "WritePrivateProfileString", "WritePrivateProfileStringA", "kernel32.dll");
char str[255];
string path=pathfolder()+"setting.ini";
int i;
int b1, b2, s1[3], hText[3], hwnd;
createdialog(0);
showdialog(0, "Диалог",100, 100, 240, 290, 4, 1);
int count_scroll=3;
int min[3]={0, 0, 0}
int max[3]={200, 200, 200}
int pos[3];
for(i=0; i<count_scroll; i++)
{
SetScrollRange(s1[i],2,min[i],max[i],1);
SetScrollPos(s1[i],2,pos[i],1);
}
if(fopen(path, "r")!=0)
{
fclose();
GetPrivateProfileString ("Default", "Edit0", 0, address (#str[0]), 255, path); //pos[0]
pos[0]=formatsn(format (#str[0]));
GetPrivateProfileString ("Default", "Edit1", 0, address (#str[0]), 255, path); //pos[1]
pos[1]=formatsn(format (#str[1]));
GetPrivateProfileString ("Default", "Edit2", 0, address (#str[0]), 255, path); //pos[2]
pos[2]=formatsn(format (#str[2]));
}
dalnost();
loop()sleep(1);
function dalnost()
{
SetWindowText(hText[0], format(pos[0]));
SetWindowText(hText[1], format(pos[1]));
SetWindowText(hText[2], format(pos[2]));
}
function getmessage(0, WM_HSCROLL)
{
for(i=0; i<count_scroll; i++)
{
if (message.lparam==s1[i])
{
if (message.wparam==1 || message.wparam==3)//SB_LINERIGHT
{
pos[i]=pos[i]+10;
if (pos[i]>max[i])pos[i]=max[i];
SetScrollPos(s1[i],2,pos[i],1);
dalnost();
return;
}
if (message.wparam==0 || message.wparam==2)//SB_LINELEFT
{
pos[i]=pos[i]-10;
if (pos[i]<min[i])pos[i]=min[i];
SetScrollPos(s1[i],2,pos[i],1);
dalnost();
return;
}
///////////
if (loword(message.wparam)==5)
{
pos[i]=pos[i]-(pos[i]-hiword(message.wparam));
if (pos[i]>max[i])pos[i]=max[i];
if (pos[i]<min[i])pos[i]=min[i];
SetScrollPos(s1[i],2,pos[i],1);
dalnost();
}
}
}
}
function getmessage(0, WM_CREATE)
{
hwnd = gethwnd(0);
s1[0]=CreateWindow(0, "scrollbar", 0, WS_CHILD | WS_VISIBLE, 10, 50, 200, 20, hwnd, 0, 0, 0);
hText[0] = CreateWindow(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 10, 80, 100, 15, hwnd, 0, 0, 0);
s1[1]=CreateWindow(0, "scrollbar", 0, WS_CHILD | WS_VISIBLE, 10, 120, 200, 20, hwnd, 0, 0, 0);
hText[1] = CreateWindow(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 30, 150, 100, 15, hwnd, 0, 0, 0);
s1[2]=CreateWindow(0, "scrollbar", 0, WS_CHILD | WS_VISIBLE, 10, 200, 200, 20, hwnd, 0, 0, 0);
hText[2] = CreateWindow(0, "STATIC", "", WS_CHILD | WS_VISIBLE, 30, 220, 100, 15, hwnd, 0, 0, 0);
}
function getmessage(0, WM_CLOSE)
{
WritePrivateProfileString ("Default", "Edit0", pos[0], path);
WritePrivateProfileString ("Default", "Edit1", pos[1], path);
WritePrivateProfileString ("Default", "Edit2", pos[2], path);
}