1. Read the image file locally and determine if the format is compliant. FilenameFilter filter = [' Image Files ', ' *.bmp;*.jpg;*.gif;*.jpeg ']; Bindata bindata = new Bindata (); Str extention, path, nameoffile; Container Imagecontainer; Imagefilepathname = Winapi::getopenfilename (Element.hwnd (), filter, ' ', ' @SYS53008 ', ', '); if (Imagefilepathname && winapi::fileexists (imagefilepathname)) { [Path, Nameoffile, extention] = Filenamesplit (imagefilepathname); if (extention = = '. jpg ') { Bindata.loadfile (Imagefilepathname); Imagecontainer = Bindata.getdata (); } Else { Throw error ("@SYS89176"); } } 2. Save the pictures in AX to a local folder STR path; FilenameFilter filter = [' Image Files ', ' *.jpg ']; Companyimage Companyimage; Image Image; DialogBox DialogBox; ; Path = Winapi::getsavefilename (0,filter, ', ', ', ', ' filename ', 0); if (path) { Image = new Image (); Image.setdata (Companyimage.image); if (winapi::fileexists (path)) { DialogBox = new DialogBox (dialogboxtype::yesnobox,strfmt ("@HPH243", Path), ",", Dialogbutton::yes); if (Dialogbutton::yes = = Dialogbox.retval ()) Image.saveimage (path); } Else { Image.saveimage (path); } } 3. Picture zoom is displayed on the control. Image = new Image (); Image.setdata (Imagecontainer); W = image.width () *sel/100; h = image.height () *sel/100; Image.resize (W,h,interpolationmode::interpolationmodedefault); photo.image (image);//photo is bitmap control 4. cut the picture, the control window showing the picture cannot be obscured by other windows. Container rect; rect = Winapi::getwindowrect (This.hwnd ());// Gets the screen coordinates of the picture control int left,top; left = Conpeek (rect,1); top = Conpeek (rect,2); Image = new Image (); Image.capturescreen (left,top,width,height);// cut according to coordinates and size, this method can also be used for screen 5. export pictures to the specified folder for batch image export. STR path; Image Image; str filename = "test.jpg"; Image = new Image (); Image.setdata (Imagecontainer); Path = Winapi::browseforpath (Element.hwnd (), "); if (substr (path, strlen (path) -1,1)! = "\ \") path+= "\";// If you select a desktop, add \ path + = filename; Image.saveimage (path); Additional: gets the number of records selected by the user, taking empltable as an example: For (Emp=empltable_ds.getfirst (1) Empltable_ds.getfirst (1): Empltable_ds.cursor (); Emp;emp=empltable_ds.getnext ()) { Do something } |