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

  • SEARCH
  • Home
  • 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 7552045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:39:34+00:00 2026-05-30T10:39:34+00:00

my test: Public Class Form1 Public Const WM_SYSCOMMAND As Int32 = &H112 Public Const

  • 0

my test:

Public Class Form1

   Public Const WM_SYSCOMMAND As Int32 = &H112
   Public Const MF_BYPOSITION As Int32 = &H400
   Public Const MYMENU1 As Int32 = 1000
   Public Const MYMENU2 As Int32 = 1001

   Dim hSysMenu As Long


   Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
   Public Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" _
       (ByVal hMenu As IntPtr, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As String) As Boolean

   Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
      MyBase.WndProc(m)
      If (m.Msg = WM_SYSCOMMAND) Then
         Select Case m.WParam.ToInt32
            Case MYMENU1
               MsgBox("1")
            Case MYMENU2
               MsgBox("2")
         End Select
      End If
   End Sub

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      hSysMenu = GetSystemMenu(Me.Handle, False)
      InsertMenu(hSysMenu, 5, MF_BYPOSITION, MYMENU1, "My Menu 1")
      InsertMenu(hSysMenu, 6, MF_BYPOSITION, MYMENU2, "My Menu 2")

   End Sub
End Class

and i get an error:

PInvokeStackImbalance was detected
Message: A call to PInvoke function ‘WindowsApplication1!WindowsApplication1.Form1::GetSystemMenu’ has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

  • 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-30T10:39:36+00:00Added an answer on May 30, 2026 at 10:39 am

    Replace Long with Integer in your declarations.

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

Sidebar

Related Questions

Consider this source: public partial class FormTest : Form { private Test test {
public class Test { public static void main(String[] args) { } } class Outer
Check out this test: [TestFixture] public class Quick_test { [Test] public void Test() {
I have the following code: public class Test { public static void Main() {
I have following code public class TEST { public static void main(String arg[]){ try
Take a look at this code: public class Test { public static void main(String...
I have an entity and its mapping: public class Test { public virtual int
If I have an inner class, like this: public class Test { public class
If I make an empty test class: public class Foo { } And I
Lets say i have this usercontrol public class test : UserControl { public int

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.