Invalid argument (Converted from VB.Net)
-
i'm new in C#, i converted some code from my previous project and i have an error here. i've put arrows between the code, i believe AppBarSettings type is APPBARDATA, but why it's still error? :confused: TBAppBar class below,
public class TBAppBar
{
[DllImport("shell32", EntryPoint = "SHAppBarMessage", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int GetAppBarMessage(int dwMessage, ref APPBARDATA pData);
[DllImport("shell32", EntryPoint = "SHAppBarMessage", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int SetAppBarMessage(int dwMessage, ref APPBARDATA pData);//Get Message Sent By App Bar //Send Message To App BAr private struct APPBARDATA { //AppBar Structure public int cbSize; public int hwnd; public int uCallbackMessage; public int uEdge; public Rectangle rc; public int lParam; } //Get Current State private const Int32 ABM\_GETSTATE = 0x4; //Get TaskBar Position private const Int32 ABM\_GETTASKBARPOS = 0x5; //Apply Setting(s) private const Int32 ABM\_SETSTATE = 0xa; //Autohide private const Int32 ABS\_AUTOHIDE = 0x1; //Always on Top private const Int32 ABS\_ALWAYSONTOP = 0x2; private bool TBAppBAutoHide; private bool TBAppBarAlwaysOnTop; public TBAppBar() { this.GetState(); //Get Current State } private void GetState() { APPBARDATA AppBarSetting = new APPBARDATA(); //What Setting? AppBarSetting.cbSize = Marshal.SizeOf(AppBarSetting); //Initialise ---> Int32 AppBarState = GetAppBarMessage(ABM\_GETSTATE, AppBarSetting); <--- //Get Current State switch (AppBarState) { case 0: //Nothing Set TBAppBAutoHide = false; TBAppBarAlwaysOnTop = false; break; case ABS\_ALWAYSONTOP: //Always On Top
-
i'm new in C#, i converted some code from my previous project and i have an error here. i've put arrows between the code, i believe AppBarSettings type is APPBARDATA, but why it's still error? :confused: TBAppBar class below,
public class TBAppBar
{
[DllImport("shell32", EntryPoint = "SHAppBarMessage", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int GetAppBarMessage(int dwMessage, ref APPBARDATA pData);
[DllImport("shell32", EntryPoint = "SHAppBarMessage", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int SetAppBarMessage(int dwMessage, ref APPBARDATA pData);//Get Message Sent By App Bar //Send Message To App BAr private struct APPBARDATA { //AppBar Structure public int cbSize; public int hwnd; public int uCallbackMessage; public int uEdge; public Rectangle rc; public int lParam; } //Get Current State private const Int32 ABM\_GETSTATE = 0x4; //Get TaskBar Position private const Int32 ABM\_GETTASKBARPOS = 0x5; //Apply Setting(s) private const Int32 ABM\_SETSTATE = 0xa; //Autohide private const Int32 ABS\_AUTOHIDE = 0x1; //Always on Top private const Int32 ABS\_ALWAYSONTOP = 0x2; private bool TBAppBAutoHide; private bool TBAppBarAlwaysOnTop; public TBAppBar() { this.GetState(); //Get Current State } private void GetState() { APPBARDATA AppBarSetting = new APPBARDATA(); //What Setting? AppBarSetting.cbSize = Marshal.SizeOf(AppBarSetting); //Initialise ---> Int32 AppBarState = GetAppBarMessage(ABM\_GETSTATE, AppBarSetting); <--- //Get Current State switch (AppBarState) { case 0: //Nothing Set TBAppBAutoHide = false; TBAppBarAlwaysOnTop = false; break; case ABS\_ALWAYSONTOP: //Always On Top
Midnight Ahri wrote:
error here.
Are we supposed to guess what the error is? Probably should be: Int32 AppBarState = GetAppBarMessage(ABM_GETSTATE, ref AppBarSetting);
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
-
Midnight Ahri wrote:
error here.
Are we supposed to guess what the error is? Probably should be: Int32 AppBarState = GetAppBarMessage(ABM_GETSTATE, ref AppBarSetting);
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
well, it works sweetly. i thought using Option Strict ON will make it easy to convert to C#. but even C# is more strict than VB.Net. thank you very much, i've got to learn more about C#. :)
-
Midnight Ahri wrote:
error here.
Are we supposed to guess what the error is? Probably should be: Int32 AppBarState = GetAppBarMessage(ABM_GETSTATE, ref AppBarSetting);
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
Good guess! :)
A guide to posting questions on CodeProject[^]
Dave Kreskowiak