473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB6 to dotnet question

I am trying to get a toggle button effect (not just a color change) to
converted from VB6 to dotnet

it works find in vb6 but not in the conversion how come?

Vb6 code

form1 with conmmandbutton1
'Then it's a simple matter of toggling the button in its Click event
procedure. The following code changes the button's caption as well:
Private Sub Command1_Click()
Static Downstate As Long
Downstate = Not Downstate
If Downstate Then
Command1.Caption = "Option On"
Command1.BackColor = &HFF&
Command2.SetFocus
Else
Command1.Caption = "Option Off"
Command1.BackColor = &HFF00&
Command2.SetFocus
End If
Call SendMessageBynum(Command1.hwnd, BM_SETSTATE, Downstate, 0)
End Sub
module1
Public Const BM_SETSTATE = &HF3
Declare Function SendMessageBynum _
Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

dotnet code
form1 with conmmandbutton1
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form

'Then it's a simple matter of toggling the button in its Click
event procedure. The following code changes the button's caption as
well:
Private Sub Command1_Click(ByVal eventSender As System.Object,
ByVal eventArgs As System.EventArgs) Handles Command1.Click
Static Downstate As Integer
Downstate = Not Downstate
If Downstate Then
Command1.Text = "Option On"
Command1.BackColor =
System.Drawing.ColorTranslator.FromOle(&HFF)
Command2.Focus()
Else
Command1.Text = "Option Off"
Command1.BackColor =
System.Drawing.ColorTranslator.FromOle(&HFF00)
Command2.Focus()
End If
Call SendMessageBynum(Command1.Handle.ToInt32,
BM_SETSTATE, Downstate, 0)
End Sub
End Class
Option Strict Off
Option Explicit On
Module Module1
Public Const BM_SETSTATE As Short = &HF3s
Declare Function SendMessageBynum Lib "user32" Alias
"SendMessageA"(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByVal lParam As Integer) As Integer
End Module

Dec 4 '05 #1
5 2803
>Declare Function SendMessageBynum _
Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long


This Declare statement isn't correct for VB.NET. Long should be
replaced by Integer (or IntPtr where it represents handles and
pointers).
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 4 '05 #2
Thanks for your response. If you look at the original posting I had
already done (i posted both the VB^ and dotnet code) so I must be
doing something else wrong. I appreciate any advice you could give.

Thanks
On Sun, 04 Dec 2005 15:04:34 +0100, Mattias Sjögren
<ma********************@mvps.org> wrote:
Declare Function SendMessageBynum _
Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long


This Declare statement isn't correct for VB.NET. Long should be
replaced by Integer (or IntPtr where it represents handles and
pointers).
Mattias

I am trying to get a toggle button effect (not just a color change) to
converted from VB6 to dotnet

it works find in vb6 but not in the conversion how come?

Vb6 code

form1 with conmmandbutton1
'Then it's a simple matter of toggling the button in its Click event
procedure. The following code changes the button's caption as well:
Private Sub Command1_Click()
Static Downstate As Long
Downstate = Not Downstate
If Downstate Then
Command1.Caption = "Option On"
Command1.BackColor = &HFF&
Command2.SetFocus
Else
Command1.Caption = "Option Off"
Command1.BackColor = &HFF00&
Command2.SetFocus
End If
Call SendMessageBynum(Command1.hwnd, BM_SETSTATE, Downstate, 0)
End Sub
module1
Public Const BM_SETSTATE = &HF3
Declare Function SendMessageBynum _
Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

dotnet code
form1 with conmmandbutton1
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form

'Then it's a simple matter of toggling the button in its Click
event procedure. The following code changes the button's caption as
well:
Private Sub Command1_Click(ByVal eventSender As System.Object,
ByVal eventArgs As System.EventArgs) Handles Command1.Click
Static Downstate As Integer
Downstate = Not Downstate
If Downstate Then
Command1.Text = "Option On"
Command1.BackColor =
System.Drawing.ColorTranslator.FromOle(&HFF)
Command2.Focus()
Else
Command1.Text = "Option Off"
Command1.BackColor =
System.Drawing.ColorTranslator.FromOle(&HFF00)
Command2.Focus()
End If
Call SendMessageBynum(Command1.Handle.ToInt32,
BM_SETSTATE, Downstate, 0)
End Sub
End Class
Option Strict Off
Option Explicit On
Module Module1
Public Const BM_SETSTATE As Short = &HF3s
Declare Function SendMessageBynum Lib "user32" Alias
"SendMessageA"(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByVal lParam As Integer) As Integer
End Module

Dec 4 '05 #3
On 04/12/2005 Wa***@aol.com wrote:
I am trying to get a toggle button effect (not just a color change) to
converted from VB6 to dotnet


What about using a CheckBox with its Appearance set to 'Button'? You
wouldn't need the API then. The new Toolstrip Buttons have a 'Pressed'
(or it may be 'Pushed') style so that might be an option?

--
Jeff Gaines
Dec 4 '05 #4
I had already thought about what you said but using this method allows
me to change the "state" of the button without actully triggerring an
event (ie the _click event) while using the checkbox means any change
in state will trigger events and require adding public variables to
block an event from occuring

I am not as familiar with the Toolstrip button but I suspect it too
will triger an event when it state is changed.

On Sun, 04 Dec 2005 10:09:50 -0800, "Jeff Gaines"
<wh*********@newsgroups.nospam> wrote:
On 04/12/2005 Wa***@aol.com wrote:
I am trying to get a toggle button effect (not just a color change) to
converted from VB6 to dotnet


What about using a CheckBox with its Appearance set to 'Button'? You
wouldn't need the API then. The new Toolstrip Buttons have a 'Pressed'
(or it may be 'Pushed') style so that might be an option?


Dec 6 '05 #5
Thanks for your response. If you look at the original posting I had
already done (i posted both the VB^ and dotnet code) so I must be
doing something else wrong.


My appologies, I guess I didn't scroll down all the way.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 7 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Keith R | last post by:
I have VB6, and eventually plan to upgrade to dotnet. I will soon start writing an application that will be mostly local (client?) but will interface with a server a few times, to authenticate...
1
by: Alex | last post by:
Dear colleagues I am going to deploy dotnet framework in our company. For this I need to do a risk assessment of dotnet framework. Thus I have following question: Is there an available risk...
13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
2
by: Peter Hemmingsen | last post by:
Hi, I have a dotnet object (implemented in mc++ and used in c#) which have a property called "Info". The Info property is also a dotnet object (implemented in mc++). In the constructor of the...
29
by: amos | last post by:
Hi I'm experiencing a real nasty thing about dotnet. I've made a big application in dotnet and I would like to use ILAYERS for netscape 4. You CAN NOT USE Layers and Form buttons in...
6
by: Paxton | last post by:
Anyone played with DotNet 2.0 or the Visual Web Developer 2005 Express Edition yet? any thoughts? /P.
5
by: James S | last post by:
Hi, With DotNet having been around for a while, are there any good resources that detail what the uptake of the framework has been for Windows Application development? For example is DotNet...
9
by: Jim | last post by:
With .net having been around for a while now, does anyone know what the uptake of major software houses is in using .net for Windows Application development? e.g. have the likes of Adobe, MS,...
1
by: Jim Carlock | last post by:
My first question here involves understanding what files are used where in regards to a dotnet application. For instance, I see a bunch of .config files. One I opened up looks like it represents...
14
by: Frank | last post by:
I see that ImageFormat includes exif. But I can't find out if I've System.Drawing.Image.FromStream or something like it can read and/or write that format.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.