I have the following code to assign a value to the MouseIcon property
of a textbox control in an OL 2007 form region. I use this exact code
numerous places to assign values for icons, pictures, etc. without a
problem but when used for the MouseIcon property it throws a 'Value
does not fall within the expected range' error at the line assigning
the property. Everything else works fine - the control is correctly
declared, the MousePointer accepts the custom (99) value but the
property assignment throws an error. HAND is in the resources and is a
PNG file 32x32, but I've tried 16x16, even an .ico file and a .cur
file all to no avail. What am I missing?
m_Textbox = DirectCast(m_Form.Controls.Item("TextboxName"),
Outlook.OlkTextBox)
Dim imgStreamPic As System.Drawing.Image
Dim oPic As IPictureDisp = Nothing
Dim ax As MyAxHost = New MyAxHost()
Try
m_Textbox.MousePointer =
Outlook.OlMousePointer.olMousePointerCustom
imgStreamPic = My.Resources.HAND
oPic = ax.IPictureDispFromImage(imgStreamPic)
m_Textbox.MouseIcon = DirectCast(oPic, stdole.StdPicture)
Catch ex As Exception
Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name)
Debug.WriteLine(ex.Data)
Debug.WriteLine(ex.Message)
Debug.WriteLine(ex.Source)
Debug.WriteLine(ex.StackTrace)
Finally
ax = Nothing
oPic = Nothing
imgStreamPic = Nothing
End Try
Thanks!


|