$include "windowssdk.inc" WINDOW wFrom,wTo OPENWINDOW wTo,0,100,700,600,@MINBOX|@MAXBOX,0,"From Window",&main OPENWINDOW wFrom,750,100,700,600,@MINBOX|@MAXBOX,0,"To Window",&main2 SETWINDOWCOLOR wTo,RGB(240,240,240) FRONTPEN wTo,RGB(0,0,240) BACKPEN wTo,RGB(240,240,240) MOVE wTo,50,50 SETFONT wTo,"Verdana",30,700,@SFITALIC PRINT wTo,"Copy from wTo to wFrom" SETLINESTYLE wTo,@LSSOLID,3 rect wTo,80,180,240,70 rect wTo,80,380,240,70 CIRCLE wTo,520,300,100,RGB(255,0,0),RGB(50,200,50) CONTROL wTo,@BUTTON,"Click me first",100,200,200,25,0,1 CONTROL wTo,@BUTTON,"Save Window as JPG",100,400,200,25,0,2 WAITUNTIL ISWINDOWCLOSED(wFrom) CLOSEWINDOW wFrom CLOSEWINDOW wTo END SUB main(),INT SELECT @MESSAGE CASE @IDCLOSEWINDOW CLOSEWINDOW wFrom CASE @IDCONTROL SELECT @CONTROLID CASE 1 CopyWindow(wFrom,wTo) CASE 2 WSTRING path path=L"test.jpg" SaveWindowToJpg(wFrom,path) ENDSELECT ENDSELECT RETURN 0 ENDSUB sub CopyWindow(WINDOW wTo,WINDOW wFrom) HDC hdcTo = GETHDC(wTo) HDC hdcFrom = GETHDC(wFrom) int cx = GetSystemMetrics(SM_CXSCREEN) int cy = GetSystemMetrics(SM_CYSCREEN) BitBlt(hdcTo,0,0,cx,cy,hdcFrom,0,0,SRCCOPY) RELEASEHDC(wTo,hdcTo,TRUE) RELEASEHDC(wFrom,hdcFrom,FALSE) endsub sub SaveWindowToJpg(WINDOW w,wstring path) declare MyEncoderParameters_jpeg declare MyGdiplusStartupInput declare MyImageEncoderJpeg HINSTANCE hgdiplus = LoadLibrary("gdiplus.dll") if (hgdiplus) declare GDIPSTARTUP(int token byref, pointer in, pointer out),int declare GDIPSHUTDOWN(int token),int declare GDIPFROMBITMAP(int hbm, int hpal, pointer ppv),int declare GDIPSAVETOFILE(pointer image, pointer filename, pointer clsidEncoder, pointer encoderParams),int declare GDIPDISPOSE(pointer pImage),int UINT fnGdiplusStartup = GetProcAddress(hgdiplus, "GdiplusStartup") UINT fnGdiplusShutdown = GetProcAddress(hgdiplus, "GdiplusShutdown") UINT fnGdipCreateBitmapFromHBITMAP = GetProcAddress(hgdiplus, "GdipCreateBitmapFromHBITMAP") UINT fnGdipSaveImageToFile = GetProcAddress(hgdiplus, "GdipSaveImageToFile") UINT fnGdipDisposeImage = GetProcAddress(hgdiplus, "GdipDisposeImage") if (fnGdiplusStartup & fnGdiplusShutdown & fnGdipCreateBitmapFromHBITMAP & fnGdipSaveImageToFile & fnGdipDisposeImage) int token if (! !fnGdiplusStartup(token, &MyGdiplusStartupInput, 0)) WINRECT rc HDC hdc = GETHDC(w) HDC cdc = CreateCompatibleDC(hdc) GetClientRect(w.hWnd, &rc) HBITMAP hbm = SelectObject(cdc, CreateCompatibleBitmap(hdc, rc.right, rc.bottom)) BitBlt(cdc,0,0,rc.right, rc.bottom,hdc,0,0,SRCCOPY) hbm = SelectObject(cdc, hbm) RELEASEHDC(w,hdc,FALSE) DeleteDC(cdc) pointer image if (! !fnGdipCreateBitmapFromHBITMAP(hbm, 0, &image)) !fnGdipSaveImageToFile(image, path, &MyImageEncoderJpeg, &MyEncoderParameters_jpeg) !fnGdipDisposeImage(image) endif DeleteObject(hbm) !fnGdiplusShutdown(token) endif endif FreeLibrary(hgdiplus) endif endsub _asm segment .data align 4 MyImageEncoderJpeg: dd 0x557CF401 dw 0x1A04, 0x11D3 db 0x9A, 0x73, 0x0, 0x0, 0xF8, 0x1E, 0xF3, 0x2E MyGdiplusStartupInput: dd 1,0,0,0 g_jpgquality: dd 90 ; jpg quality value, 0-100 MyEncoderParameters_jpeg: dd 2 dd 0x1d5be4b5 dw 0xfa4a,0x452d db 0x9c,0xdd,0x5d,0xb3,0x51,0x05,0xe7,0xeb dd 1 dd 4 dd g_jpgquality dd 0x292266fc dw 0xac40,0x47bf db 0x8c,0xfc,0xa8,0x5b,0x89,0xa6,0x55,0xde dd 0 dd 4 dd 0 segment .text _endasm SUB main2(),INT SELECT @MESSAGE CASE @IDCLOSEWINDOW CLOSEWINDOW wFrom ENDSELECT RETURN 0 ENDSUB