Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6703937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:13:51+00:00 2026-05-26T07:13:51+00:00

I have the following function: [DllImport(user32.dll, CharSet=CharSet.Auto)] static extern int SendMessage(IntPtr hWnd, int wMsg,

  • 0

I have the following function:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, SPoint lParam);

It keeps complaining about Pinvoke stack imbalance when the following code executes:

SendMessage(EventRichTextBox.Handle, EM_GETSCROLLPOS, 0, OldScrollPoint);

What can cause that issue?

this is my SPoint

  private struct SPoint
    {
        public Int32 x;
        public Int32 y;
    }

and

SPoint OldScrollPoint = default(SPoint);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:13:51+00:00Added an answer on May 26, 2026 at 7:13 am

    Can’t say for sure, but one obvious possibility is that you are on a 64 bit machine and int is the wrong type for wParam. It needs to be a 64 bit value in a 64 bit process.

    We also have no idea how you have declared SPoint. You are meant to pass a pointer to a POINT struct. It doesn’t look as though you have done that.

    The correct signature is:

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(
        IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
    

    Your edit clarifies that SPoint is a struct. This then is clearly wrong. You could simply pass the SPoint as an out parameter. That would be the simplest solution.

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(
        IntPtr hWnd, int Msg, IntPtr wParam, out SPoint lParam);
    

    If you wanted a more general SendMessage signature then you should use IntPtr as I stated above and use Marshal.StructureToPtr.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following functions in my program: [DllImport(user32.dll, CharSet = CharSet.Auto)] static extern
I have the following declaration for SHChangeNotify : [DllImport(Shell32.dll)] public static extern void SHChangeNotify(HChangeNotifyEventID
I have the following function: //Function to get random number public static int RandomNumber(int
I have a static library. This library have the following function defined int WriteData(LPTSTR
I have the following function: CREATE FUNCTION fGetTransactionStatusLog ( @TransactionID int ) RETURNS varchar(8000)
I have the following function void initBoard(int * board[BOARD_ROWS][BOARD_COLS]){ int z = 0; for(
HI, I have a C++ function like the following: int ShowJob(const JobData& data); How
I am using Mono/C# on Linux and have the following C# code: [DllImport(libaiousb)] extern
I have a function in a DLL (the c header is): int my_c_function( const
I have a Delphi 7 dll that exports the following function: function StringTest(var StringOut

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.