Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert this VB code to C#?

Tags:

c#

vb.net

I'm having trouble converting this piece of code (originally in VB) to C#. In particular, how does one apply a negative to an int.

Private Declare Function GetWindowLong Lib "user32" Alias _
  "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
dim lStyle as long

lStyle = GetWindowLong(Lhwnd, GWL_STYLE)
lStyle = lStyle And Not WS_MAXIMIZEBOX
like image 554
AngryHacker Avatar asked Feb 26 '23 15:02

AngryHacker


1 Answers

In particular, how does one apply a negative to an int.

I guess the line you are stuck on is the last one. The code seems to be clearing a bit. In C# you can do it like this:

lStyle &= ~WS_MAXIMIZEBOX
like image 129
Mark Byers Avatar answered Mar 08 '23 06:03

Mark Byers