S
szyc927
Unregistered / Unconfirmed
GUEST, unregistred user!
本人对vc知之甚少,可是偏偏要转一堆c代码。转得我头晕眼花,郁闷吐血,还请各位古道热肠的大虾,救兄弟一把!200分奉上!
c代码
void CNativeDlg::OnButtonOpenfile()
{
CString str;
POSITION pos;
DWORD count_total=0,count_select=0 ;
CString head, tail ;
CString head_name, tail_name ;
int hour1,hour2,minute1,minute2 ;
//char szFilter[] = "ALL Support Files(*.STR;*.TM4;*.ASF)/0*.STR;*.TM4;*.ASF/0STR Files (*.STR)/0*.STR/0TM4 Files(*.TM4)/0*.TM4/0ASF Files(*.ASF)/0*.ASF/0All Files (*.*)/0*.*/0/0";
char szFilter[] = "All Files (*.*)|*.*||";
const char * aaa[1440];
int i;
CFileDialog m_OpenDlg(TRUE,NULL,NULL,
OFN_ALLOWMULTISELECT | OFN_EXPLORER ,
szFilter,this);
if(m_OpenDlg.DoModal() == IDOK)
{
//i = 0;
m_strList.RemoveAll ();
pos = m_OpenDlg.GetStartPosition();
while (pos)
{
str = m_OpenDlg.GetNextPathName(pos);
m_strList.AddTail(str);
}
}
else
{
return ;
}
count_select = m_strList.GetCount() ;
if(count_select>0)
{
head = m_strList.GetHead() ;
head_name = head.Right(9) ;
IsMyFile(head_name,hour1,minute1) ;
tail = m_strList.GetTail() ;
tail_name = tail.Right(9)
IsMyFile(tail_name,hour2,minute2) ;
int t1 = hour1*60 + minute1 ;
int t2 = hour2*60 + minute2 ;
if(t1>t2)
{
m_strList.RemoveHead() ;
m_strList.AddTail(head);
}
}
for(i=0;i<m_strList.GetCount();i++)
{
pos = m_strList.FindIndex(i);
str = m_strList.GetAt(pos);
//aaa = (LPCTSTR )m_strList.GetTail ();
aaa = (LPCTSTR )str ;
}
// aa(aaa,i);
int ret;
ret = PB_OpenFileEx(PLAYBACK_NUM,aaa,i,m_EndTime);
if(ret == 0)
{
str.Format ("%02d:%02d:%02d",m_EndTime/3600,(m_EndTime/60)%60,m_EndTime%60);
GetDlgItem(IDC_STATIC_END_TIME)->SetWindowText(str);
PB_RegisterMessage(PLAYBACK_NUM,GetSafeHwnd(),WM_PLAYNOTIFY);
m_Slider.SetRange(0,m_EndTime);
m_Slider.SetPos (0);
PB_SetLoop(PLAYBACK_NUM,( m_Btn_Loop.GetCheck () == 1 ? TRUE : FALSE));
}
OnButtonPlay() ;
GetDlgItem(IDC_BUTTON_PLAY)->EnableWindow(TRUE) ;
}
我转的部分delphi代码,请大虾指正,并帮我完成!先谢了!
procedure TForm1.BitBtn1Click(Sender: TObject);
var
str:string;
count_total,count_selectWORD;
head,tail:string;
head_name, tail_name:String;
hour1,hour2,minute1,minute2:integer;
aaachar;
i:integer;
m_strList:Tstringlist;
t1,t2:integer;
ret:integer;
const
WM_PLAYNOTIFY=WM_USER + 300;
PLAYBACK_NUM=10;
begin
m_strList:=Tstringlist.Create;
getmem(aaa,1440);
count_total:=0;
count_select:=0;
if m_OpenDlg.Execute then
begin
m_strList.Clear;
// pos = m_OpenDlg.GetStartPosition();
// while (pos)
// {
// str = m_OpenDlg.GetNextPathName(pos);
// m_strList.AddTail(str);
// }
//这段c应该怎么转?
end;
count_select:=m_strList.Count();
if(count_select>0) then
begin
//head = m_strList.GetHead() ;
//head_name = head.Right(9) ;
IsMyFile(head_name,hour1,minute1) ;//自定义函数
//tail = m_strList.GetTail() ;
//tail_name = tail.Right(9) ;
IsMyFile(tail_name,hour2,minute2) ;
t1: = hour1*60 + minute1 ;
t2: = hour2*60 + minute2 ;
if(t1>t2) then
begin
//m_strList.RemoveHead() ;
//m_strList.AddTail(head);
//以上凡被注释的都是c语句,应如何转换
end;
end;
for i:=0 to m_strList.Count-1 do
begin
//pos = m_strList.FindIndex(i);
//str = m_strList.GetAt(pos);
//aaa = (LPCTSTR )str ;
//以上凡被注释的都是c语句,应如何转换
end;
ret: = PB_OpenFileEx(PLAYBACK_NUM,aaa,i,m_EndTime);
//重要语句,函数定义:int PB_OpenFileEx(USHORT nPort,LPCTSTR strlist[],int filenum,DWORD &nTimeLength);
if(ret=0) then
begin
//str.Format ("%02d:%02d:%02d",m_EndTime/3600,(m_EndTime/60)%60,m_EndTime%60);
//GetDlgItem(IDC_STATIC_END_TIME)->SetWindowText(str);
//PB_RegisterMessage(PLAYBACK_NUM,GetSafeHwnd(),WM_PLAYNOTIFY);
//WM_PLAYNOTIFY为自定义消息
//函数定义:int PB_RegisterMessage(USHORT nPort,HWND hWnd,UINT MessageID)
//m_Slider.SetRange(0,m_EndTime);
//m_Slider定义为CSliderCtrl,不知道delphi如何对应
//m_Slider.SetPos (0);
//PB_SetLoop(PLAYBACK_NUM,( m_Btn_Loop.GetCheck () == 1 ? TRUE : FALSE));
//函数定义:int PB_SetLoop(USHORT nPort,bool bIsLoop)
end;
//OnButtonPlay() ;
//GetDlgItem(IDC_BUTTON_PLAY)->EnableWindow(TRUE) ;
//以上凡被注释的都是c语句,应如何转换
end;
c代码
void CNativeDlg::OnButtonOpenfile()
{
CString str;
POSITION pos;
DWORD count_total=0,count_select=0 ;
CString head, tail ;
CString head_name, tail_name ;
int hour1,hour2,minute1,minute2 ;
//char szFilter[] = "ALL Support Files(*.STR;*.TM4;*.ASF)/0*.STR;*.TM4;*.ASF/0STR Files (*.STR)/0*.STR/0TM4 Files(*.TM4)/0*.TM4/0ASF Files(*.ASF)/0*.ASF/0All Files (*.*)/0*.*/0/0";
char szFilter[] = "All Files (*.*)|*.*||";
const char * aaa[1440];
int i;
CFileDialog m_OpenDlg(TRUE,NULL,NULL,
OFN_ALLOWMULTISELECT | OFN_EXPLORER ,
szFilter,this);
if(m_OpenDlg.DoModal() == IDOK)
{
//i = 0;
m_strList.RemoveAll ();
pos = m_OpenDlg.GetStartPosition();
while (pos)
{
str = m_OpenDlg.GetNextPathName(pos);
m_strList.AddTail(str);
}
}
else
{
return ;
}
count_select = m_strList.GetCount() ;
if(count_select>0)
{
head = m_strList.GetHead() ;
head_name = head.Right(9) ;
IsMyFile(head_name,hour1,minute1) ;
tail = m_strList.GetTail() ;
tail_name = tail.Right(9)
IsMyFile(tail_name,hour2,minute2) ;
int t1 = hour1*60 + minute1 ;
int t2 = hour2*60 + minute2 ;
if(t1>t2)
{
m_strList.RemoveHead() ;
m_strList.AddTail(head);
}
}
for(i=0;i<m_strList.GetCount();i++)
{
pos = m_strList.FindIndex(i);
str = m_strList.GetAt(pos);
//aaa = (LPCTSTR )m_strList.GetTail ();
aaa = (LPCTSTR )str ;
}
// aa(aaa,i);
int ret;
ret = PB_OpenFileEx(PLAYBACK_NUM,aaa,i,m_EndTime);
if(ret == 0)
{
str.Format ("%02d:%02d:%02d",m_EndTime/3600,(m_EndTime/60)%60,m_EndTime%60);
GetDlgItem(IDC_STATIC_END_TIME)->SetWindowText(str);
PB_RegisterMessage(PLAYBACK_NUM,GetSafeHwnd(),WM_PLAYNOTIFY);
m_Slider.SetRange(0,m_EndTime);
m_Slider.SetPos (0);
PB_SetLoop(PLAYBACK_NUM,( m_Btn_Loop.GetCheck () == 1 ? TRUE : FALSE));
}
OnButtonPlay() ;
GetDlgItem(IDC_BUTTON_PLAY)->EnableWindow(TRUE) ;
}
我转的部分delphi代码,请大虾指正,并帮我完成!先谢了!
procedure TForm1.BitBtn1Click(Sender: TObject);
var
str:string;
count_total,count_selectWORD;
head,tail:string;
head_name, tail_name:String;
hour1,hour2,minute1,minute2:integer;
aaachar;
i:integer;
m_strList:Tstringlist;
t1,t2:integer;
ret:integer;
const
WM_PLAYNOTIFY=WM_USER + 300;
PLAYBACK_NUM=10;
begin
m_strList:=Tstringlist.Create;
getmem(aaa,1440);
count_total:=0;
count_select:=0;
if m_OpenDlg.Execute then
begin
m_strList.Clear;
// pos = m_OpenDlg.GetStartPosition();
// while (pos)
// {
// str = m_OpenDlg.GetNextPathName(pos);
// m_strList.AddTail(str);
// }
//这段c应该怎么转?
end;
count_select:=m_strList.Count();
if(count_select>0) then
begin
//head = m_strList.GetHead() ;
//head_name = head.Right(9) ;
IsMyFile(head_name,hour1,minute1) ;//自定义函数
//tail = m_strList.GetTail() ;
//tail_name = tail.Right(9) ;
IsMyFile(tail_name,hour2,minute2) ;
t1: = hour1*60 + minute1 ;
t2: = hour2*60 + minute2 ;
if(t1>t2) then
begin
//m_strList.RemoveHead() ;
//m_strList.AddTail(head);
//以上凡被注释的都是c语句,应如何转换
end;
end;
for i:=0 to m_strList.Count-1 do
begin
//pos = m_strList.FindIndex(i);
//str = m_strList.GetAt(pos);
//aaa = (LPCTSTR )str ;
//以上凡被注释的都是c语句,应如何转换
end;
ret: = PB_OpenFileEx(PLAYBACK_NUM,aaa,i,m_EndTime);
//重要语句,函数定义:int PB_OpenFileEx(USHORT nPort,LPCTSTR strlist[],int filenum,DWORD &nTimeLength);
if(ret=0) then
begin
//str.Format ("%02d:%02d:%02d",m_EndTime/3600,(m_EndTime/60)%60,m_EndTime%60);
//GetDlgItem(IDC_STATIC_END_TIME)->SetWindowText(str);
//PB_RegisterMessage(PLAYBACK_NUM,GetSafeHwnd(),WM_PLAYNOTIFY);
//WM_PLAYNOTIFY为自定义消息
//函数定义:int PB_RegisterMessage(USHORT nPort,HWND hWnd,UINT MessageID)
//m_Slider.SetRange(0,m_EndTime);
//m_Slider定义为CSliderCtrl,不知道delphi如何对应
//m_Slider.SetPos (0);
//PB_SetLoop(PLAYBACK_NUM,( m_Btn_Loop.GetCheck () == 1 ? TRUE : FALSE));
//函数定义:int PB_SetLoop(USHORT nPort,bool bIsLoop)
end;
//OnButtonPlay() ;
//GetDlgItem(IDC_BUTTON_PLAY)->EnableWindow(TRUE) ;
//以上凡被注释的都是c语句,应如何转换
end;