vb.net - Sending PictureBox Contents to MsPaint -


how go sending contents of picturebox edited in paint? i've thought of saving temporarily sending temp address loaded, i'd think cause minor saving issues.

unfortunately i'm providing answer in c# @ time. luckily, syntax , not content have change.

assuming picturebox control, take contents (as bitmap) , put on clipboard. can paste mspaint you'd sendmessage or sendkeys if make foreground, etc.

bitmap bmp = new bitmap(picturebox1.image); clipboard.setdata(system.windows.forms.dataformats.bitmap, bmp); 

a poor example, optional opening of mspaint , waiting appear, using sendkeys paste.

    [dllimport("user32.dll", setlasterror = true)]     public static extern intptr findwindowex(intptr parenthandle, intptr childafter, string classname, string windowtitle);      [dllimport("user32.dll")]     private static extern intptr getforegroundwindow();      [dllimport("user32.dll")]     [return: marshalas(unmanagedtype.bool)]     static extern bool setforegroundwindow(intptr hwnd);       private static void testsendpicturetomspaint()     {         bitmap bmp = new bitmap(picturebox1.image);         clipboard.setdata(system.windows.forms.dataformats.bitmap, bmp);          //optional#1 - open mspaint         //var proc = process.start("mspaint");          intptr mspaint = intptr.zero;         //while (mspaint == intptr.zero) //optional#1 - if opening mspaint yourself, wait appear         mspaint = findwindowex(intptr.zero, new intptr(0), "mspaintapp", null);          setforegroundwindow(mspaint); //optional#2 - if not opening mspaint          intptr currforeground = intptr.zero;         while (currforeground != mspaint)         {             thread.sleep(250); //sleep before exit loop , send             currforeground = getforegroundwindow();         }         sendkeys.sendwait("^v");     } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -