Edit Menu Error please help!

  • Thread starter Thread starter Timothy Taylor
  • Start date Start date
T

Timothy Taylor

Hello,

I converter the Edit Menu C# project found at...
http://www.businessanyplace.net/?p=code

to be VB.NET CF code and after toying with it i got it down to one error
that happens on all the lines of code below.

The same error occurs on all the lines where it says "system.uint32" the
error is:

"Constants must be an intrinsic or enumerated type, not a class, structure,
or array type."

what does this mean?

What do i change it to be?

Thanks a lot,

-Tim

P.S. Do i have to change the "&H..." signs too to be something else? If so,
what?

' API declarations

Private Const WM_CUT As System.UInt32 = &H300 'ToDo: Unsigned Integers not
supported

Private Const WM_COPY As System.UInt32 = &H301 'ToDo: Unsigned Integers not
supported

Private Const WM_PASTE As System.UInt32 = &H302 'ToDo: Unsigned Integers not
supported

Private Const WM_CLEAR As System.UInt32 = &H303 'ToDo: Unsigned Integers not
supported

Private Const WM_UNDO As System.UInt32 = &H304 'ToDo: Unsigned Integers not
supported

Private Const EM_CANUNDO As System.UInt32 = &HC6 'ToDo: Unsigned Integers
not supported

Private Const CF_UNICODETEXT As System.UInt32 = 13 'ToDo: Unsigned Integers
not supported
 
I haven't tried it specifically but the problem probably stems from the fact
that VB.NET does not support unsigned types like uint32. I haven't looked
at the exact sample but in many cases you can just change the System.uint32
to System.Int32 or even just Integer for VB.NET. Problems would only arise
if you need to directly manipulate the code using unsigned capabilities
which is unlikely.

Jim Wilson, eMVP
http://www.jwhh.com
http://www.develop.com
 
I went through and translated the code for the SendMessage, GetFocus &
IsClipBoardFormatAvailable. In situations like this where you're not really
using the values but are just using the parameters as a pass-through between
..NETCF and Win32 you can use pretty much any 4-byte data type.

Private Const WM_CUT As Integer = &H300
Private Const WM_COPY As Integer = &H301
Private Const WM_PASTE As Integer = &H302
Private Const WM_CLEAR As Integer = &H303
Private Const WM_UNDO As Integer = &H304
Private Const EM_CANUNDO As Integer = &HC6
Private Const CF_UNICODETEXT As Integer = 13

<DllImport("coredll.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal wMsg As
Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function

<DllImport("coredll.dll")> _
Private Shared Function GetFocus() As IntPtr
End Function

<DllImport("Coredll.dll")> _
Private Shared Function IsClipboardFormatAvailable(ByVal uFormat As
Integer) As Boolean
End Function

Jim Wilson, eMVP
http://www.jwhh.com
http://www.develop.com
 
Could you send me the code so I can take a look for you, the original C#
project I've downloaded doesn't contant such code for system.uint32.

As for your other questions.
P.S. Do i have to change the "&H..." signs too to be something else? If so,
what? the '&" means

If you refer do hexidecimal in VB the corresponding syntax would be

int i;
i = 0x100;


Dim i As Integer
i = &H100


Thanks,

David
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
| From: "Timothy Taylor" <[email protected]>
| Subject: Edit Menu Error please help!
| Date: Tue, 12 Aug 2003 15:59:48 -0700
| Lines: 49
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#za#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: vsat-148-63-243-204.c004.g4.mrt.starband.net
148.63.243.204
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:30794
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hello,
|
| I converter the Edit Menu C# project found at...
| http://www.businessanyplace.net/?p=code
|
| to be VB.NET CF code and after toying with it i got it down to one error
| that happens on all the lines of code below.
|
| The same error occurs on all the lines where it says "system.uint32" the
| error is:
|
| "Constants must be an intrinsic or enumerated type, not a class,
structure,
| or array type."
|
| what does this mean?
|
| What do i change it to be?
|
| Thanks a lot,
|
| -Tim
|
| P.S. Do i have to change the "&H..." signs too to be something else? If
so,
| what?
|
| ' API declarations
|
| Private Const WM_CUT As System.UInt32 = &H300 'ToDo: Unsigned Integers not
| supported
|
| Private Const WM_COPY As System.UInt32 = &H301 'ToDo: Unsigned Integers
not
| supported
|
| Private Const WM_PASTE As System.UInt32 = &H302 'ToDo: Unsigned Integers
not
| supported
|
| Private Const WM_CLEAR As System.UInt32 = &H303 'ToDo: Unsigned Integers
not
| supported
|
| Private Const WM_UNDO As System.UInt32 = &H304 'ToDo: Unsigned Integers
not
| supported
|
| Private Const EM_CANUNDO As System.UInt32 = &HC6 'ToDo: Unsigned Integers
| not supported
|
| Private Const CF_UNICODETEXT As System.UInt32 = 13 'ToDo: Unsigned
Integers
| not supported
|
|
|
 
Here is the entire menuhelper class below. I got it to work for the
most part now by changing the uint32 to just int32 (thanks jim)

But now it errors out under the function "CanUndo" on the line of:

"Return SendMessage(hWnd, EM_CANUNDO, 0, 0) <> IntPtr.Zero"

with the error of:

"Operator '<>' is not defined for types 'System.IntPtr' and
'System.IntPtr'."

This is the only thing left that it doesn't like. Any suggestions jim?
:-)

Thanks guys,

-Tim

Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices


Namespace businessanyplace.CommonServices

'/ <summary>
'/ Summary description for ClipboardEdit.
'/ </summary>

Public Class EditMenuHelper


' API declarations
Private Const WM_CUT As Integer = &H300
Private Const WM_COPY As Integer = &H301
Private Const WM_PASTE As Integer = &H302
Private Const WM_CLEAR As Integer = &H303
Private Const WM_UNDO As Integer = &H304
Private Const EM_CANUNDO As Integer = &HC6
Private Const CF_UNICODETEXT As Integer = 13

<DllImport("coredll.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr,
ByVal wMsg As System.Int32, ByVal wParam As System.Int32, ByVal lParam
As System.Int32) As IntPtr
End Function
Public Declare Function GetFocus Lib "coredll.dll" Alias
"GetFocus" () As IntPtr
Public Declare Function IsClipboardFormatAvailable Lib
"coredll.dll" Alias "IsClipboardFormatAvailable" (ByVal uFormat As
System.Int32) As Boolean 'ToDo: Unsigned Integers not supported
Public Shared Function Cut() As IntPtr
Try
Dim hWnd As IntPtr = GetFocus()
Return SendMessage(hWnd, WM_CUT, 0, 0)
Catch ex As Exception
MessageBox.Show("Could not cut!")
Return New IntPtr(-1)
End Try
End Function 'Cut


Public Shared Function Copy() As IntPtr
Try
Dim hWnd As IntPtr = GetFocus()
Return SendMessage(hWnd, WM_COPY, 0, 0)
Catch ex As Exception
MessageBox.Show("Could not copy!")
Return New IntPtr(-1)
End Try
End Function 'Copy


Public Shared Function Paste() As IntPtr
Try
Dim hWnd As IntPtr = GetFocus()
Return SendMessage(hWnd, WM_PASTE, 0, 0)
Catch ex As Exception
MessageBox.Show("Could not paste!")
Return New IntPtr(-1)
End Try
End Function 'Paste


Public Shared Function Clear() As IntPtr
Try
Dim hWnd As IntPtr = GetFocus()
Return SendMessage(hWnd, WM_CLEAR, 0, 0)
Catch ex As Exception
MessageBox.Show("Could not delete!")
Return New IntPtr(-1)
End Try
End Function 'Clear


Public Shared Function Undo() As IntPtr
Try
Dim hWnd As IntPtr = GetFocus()
Return SendMessage(hWnd, WM_UNDO, 0, 0)
Catch ex As Exception
MessageBox.Show("Could not undo!")
Return New IntPtr(-1)
End Try
End Function 'Undo


Public Shared Function CanUndo() As Boolean
Try
Dim hWnd As IntPtr = GetFocus()
Return SendMessage(hWnd, EM_CANUNDO, 0, 0) <>
IntPtr.Zero
Catch ex As Exception
MessageBox.Show("Could not check if undo possible!")
Return False
End Try
End Function 'CanUndo


Public Shared Function ClipboardHasText() As Boolean
Try
Return IsClipboardFormatAvailable(CF_UNICODETEXT)
Catch ex As Exception
MessageBox.Show("Could not check if clipboard has
text!")
Return False
End Try
End Function 'ClipboardHasText
End Class 'EditMenuHelper


'ToDo: Unsigned Integers not supported
'ToDo: Unsigned Integers not supported
'ToDo: Unsigned Integers not supported


'<DllImport("coredll.dll")> Private Shared Function GetFocus()
As IntPtr


'<DllImport("Coredll.dll")> Private Shared Function
IsClipboardFormatAvailable(uFormat As System.UInt32) As Boolean 'ToDo:
Unsigned Integers not supported

End Namespace 'businessanyplace.CommonServices
 
Can you try something IntPtr.ToInt32?
"Return SendMessage(hWnd, EM_CANUNDO, 0, 0) <> IntPtr.Zero" will become

"Return SendMessage(hWnd, EM_CANUNDO, 0, 0) .ToInt32<> 0"

Hope this helps.

Xin
 
Back
Top