Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Win32 API - Problems with SENDMESSAGE

Win32 API - Problems with SENDMESSAGE

Scheduled Pinned Locked Moved C#
helpjsonquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Seraphin
    wrote on last edited by
    #1

    Hello, I have a problem with this code. Signature error, but why? using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Windows.Forms; namespace EnumerateSingle { public struct EditStream { public long dwCookie; public long dwError; public Delegate pfnCallback; } class RichEditC { public const long WM_USER = 0x400; public const long EM_STREAMIN = (WM_USER + 73); public const long EM_STREAMOUT = (WM_USER + 74); public const long SF_TEXT = 0x1 ; public const long SF_RTF = 0x2; public const long SF_RTFNOOBJS = 0x3; public const long SF_TEXTIZED = 0x4; public const long SF_UNICODE = 0x10; public const long SF_USECODEPAGE = 0x20; public const long SF_NCRFORNONASCII = 0x40; public delegate long RTFCallback(long dwCookie, long pbBuff, long cb, long pcb); public string buffText; [DllImport("User32.dll")] public static extern long SendMessage(long hWnd, long wMsg, long wParam, ref EditStream lParam); [DllImport("User32.dll")] public static extern void CopyMemory(object Destination, object source, long length); public static long EditStreamCallback(long dwCookie, long pbBuff, long cb, long pcb) { StringBuilder buff = new StringBuilder((int)cb); switch(dwCookie) { case 999: { CopyMemory(buff, pbBuff, cb); pcb = cb; return 0; } default: { return -1; } } } } } And the Clientcode: private void button3_Click(object sender, EventArgs e) { RichEditC.RTFCallback myRtfCallback = new RichEditC.RTFCallback(RichEditC.EditStreamCallback); EditStream es = new EditStream(); es.dwCookie = 999; es.pfnCallback = myRtfCallback; //Error------------------------------------------------------------------------> RichEditC.SendMessage(0x80524, RichEditC.EM_STREAMOUT, RichEditC.SF_TEXT, ref es); } public long FARPROC(long pfn) { return pfn;

    R 1 Reply Last reply
    0
    • S Seraphin

      Hello, I have a problem with this code. Signature error, but why? using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Windows.Forms; namespace EnumerateSingle { public struct EditStream { public long dwCookie; public long dwError; public Delegate pfnCallback; } class RichEditC { public const long WM_USER = 0x400; public const long EM_STREAMIN = (WM_USER + 73); public const long EM_STREAMOUT = (WM_USER + 74); public const long SF_TEXT = 0x1 ; public const long SF_RTF = 0x2; public const long SF_RTFNOOBJS = 0x3; public const long SF_TEXTIZED = 0x4; public const long SF_UNICODE = 0x10; public const long SF_USECODEPAGE = 0x20; public const long SF_NCRFORNONASCII = 0x40; public delegate long RTFCallback(long dwCookie, long pbBuff, long cb, long pcb); public string buffText; [DllImport("User32.dll")] public static extern long SendMessage(long hWnd, long wMsg, long wParam, ref EditStream lParam); [DllImport("User32.dll")] public static extern void CopyMemory(object Destination, object source, long length); public static long EditStreamCallback(long dwCookie, long pbBuff, long cb, long pcb) { StringBuilder buff = new StringBuilder((int)cb); switch(dwCookie) { case 999: { CopyMemory(buff, pbBuff, cb); pcb = cb; return 0; } default: { return -1; } } } } } And the Clientcode: private void button3_Click(object sender, EventArgs e) { RichEditC.RTFCallback myRtfCallback = new RichEditC.RTFCallback(RichEditC.EditStreamCallback); EditStream es = new EditStream(); es.dwCookie = 999; es.pfnCallback = myRtfCallback; //Error------------------------------------------------------------------------> RichEditC.SendMessage(0x80524, RichEditC.EM_STREAMOUT, RichEditC.SF_TEXT, ref es); } public long FARPROC(long pfn) { return pfn;

      R Offline
      R Offline
      Rei Miyasaka
      wrote on last edited by
      #2

      Try tagging the struct with [StructLayout(LayoutKind.Sequential)] maybe?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups