替换pic控件中的图片

    技术2022-05-11  46

    integer li_FileNum,ret,loops,i long filelen blob pic,b string txtname,named string defext = 'BMP' string filter = 'bitmap files(*.bmp),*.bmp,jpg files(*.jpg),*.jpg' //打开选择文件对话框 ret = GetFileOpenName('Open Picture Dialog',txtname,named,defext,filter) if ret = 1 then  //执行成功  filelen = FileLength(txtname)  //得到文件长度  li_FileNum = FileOpen(txtname,StreamMode!)  //流模式打开文件,并返回打开文件的句柄  if li_FileNum <> -1 then  //执行成功   // Determine how many times to call FileRead         IF filelen > 32765 THEN    IF Mod(filelen, 32765) = 0 THEN     loops = filelen/32765    ELSE     loops = (filelen/32765) + 1    END IF   ELSE    loops = 1   END IF   // Read the file into b   FOR i = 1 to loops    FileRead(li_FileNum, b)  //li_FileNum为文件句柄,由FileOpen()函数得到    pic += b   NEXT   // Closes the file opened by FileOpen()   FileClose(li_FileNum)   // 设置新图片   p_1.setpicture(pic)  end if end if

    最新回复(0)