[System. Security. suppressunmanagedcodesecurity] [Dllimport ("user32.dll", charset = charset. Auto)] Public static extern bool peekmessage (out message MSG, intptr hwnd, uint messagefiltermin, uint messagefiltermax, uint flags ); [Dllimport ("user32.dll", entrypoint = "sendmessagea")] Private Static extern int sendmessage (intptr hwnd, int wmsg, intptr wparam, string lparam ); [Dllimport ("user32.dll", charset = charset. Unicode)] Public static extern intptr postmessage (intptr hwnd, int wmsg, intptr wparam, intptr lparam ); Intptr hwnd; Private void windowloaded (Object sender, eventargs E) { Hwnd = new windowinterophelper (this). Handle; Hwndsource. fromhwnd (hwnd). addhook (New hwndsourcehook (wndproc )); } // Receives Windows messages Private intptr wndproc (intptr hwnd, int MSG, intptr wparam, intptr lparam, ref bool handled) { Int wm_user = 0x0400 + 111; If (MSG = wm_user) { // Decodetouch (wparam, lparam ); String dicom_file = marshal. ptrtostringansi (wparam ); Handled = true; F_opendicom (dicom_file ); } Return intptr. zero; } // Send a Windows messagePrivate void f_send_msg (string filepath) { Intptr hwnd_ifc; Int wm_user = 0x0400 + 111; Hwnd_ifc = hwnd; // find the form handle with the title frmpassive. Unicodeencoding encode = new unicodeencoding (); Char [] chars = encode. getchars (encode. getbytes (filepath )); Message MSG; MSG = message. Create (hwnd_ifc, wm_user, Marshal. stringtohglobalansi (filepath), new intptr (0 )); Postmessage (msg. hwnd, MSG. MSG, MSG. wparam, MSG. lparam ); } |