Issues in converting a usercontrol project from VB 6.0 to VB 2005

Hi,

I'm converting a VB 6.0 project to VB 2005. There are few issues, where i got stuck up.

They are

1. 'Ambient' is not a member of 'System.Windows.Forms.UserControl'
This is the code that gives this error.
If (mbHasFocus Or MyBase.Ambient.DisplayAsDefault) And m_Style <> 0 Then

2. AmbientProperties property Ambient.Font was not upgraded.
Ambient.Font is not recognised. How to get his issue resolved

3. UserControl property UserControl.AccessKeys was not upgraded.
How to set the AccessKey property for a usercontrol

4. ObjPtr function is not supported.
This is the code that gives the error.
gcTimerObjects.Add(ObjPtr(Me), mnTimerID) - Me refers to object of objTimer class.
How do i find the address of a object

5. Picture property picSource.handle was not upgraded.
picsource is System.Drawing.Image.
How can i get the handle of picSource

6.Picture property picSource.Type was not upgraded.
Code is
Select Case picSource.Type
Case vbPicTypeBitmap
'blah blah
Case vbPicTypeIcon
'blah blah
Case Else
'blah blah
End Select

Here i tried piSource.type with picSource.GetType.Name. Now the issues are what are the equivalents of vbPicTypeBitmap, vbPicTypeIcon. It seems the case statements expects some "type" in the code.

Pls help in reslving these issues.

Thanks in advance,
Sugan




Answer this question

Issues in converting a usercontrol project from VB 6.0 to VB 2005

  • Darren M. Bork

    I'm sorry. I did not work on this module for atleast a week. So could not reply immediately.

    Your answers for question 2 and 5 worked without problems.

    I'm now working on your answer for the fourth question.

    Can you pls explain on your answers for question 1 and 6.

    I'm actually converting a custom button control project from VB 6 to VB 2005.

    1) So how can i know, whether this button control is selected as the default button in the application that utilizes this button control

    6) Regarding the 6th question, i changed the picSource to PictureBox.

    Now i need to find the type of image in picturebox.

    So How should this code be rewritten in .Net 2005.

    Select Case picSource.Type
    Case vbPicTypeBitmap
    'blah blah
    Case vbPicTypeIcon
    'blah blah
    Case Else
    'blah blah
    End Select

    How do i get the type of image in picSource. What will be the options in case statements instead of vbPicTypeBitmap & vbPicTypeIcon .

    Thanx in advance,

    Sugan



  • kamkam2

    Button is actually not inside the usercontrol. My usercontrol itself is a custom button. So how to find whether this custom button is selected as default button in the form.

    Can you give some example about for the 6th question as i already went through this page in MSDN and still could not find an answer for this.

    Thanx,

    Sugan



  • ktietjen

    Did this solve your problem



  • traci779

    To make your usercontrol act like a button and be available to be selected as a form's AcceptButton it must implement the IButtonControl interface. You'll get the NotifyDefault method called if your control was selected as the default button. Please start a new thread if you have any questions about that.

    Inspecting the format:
    If PictureBox1.Image Is Nothing Then
    Debug.Print("No image selected yet")
    Else
    With PictureBox1.Image.RawFormat
    If .Guid = ImageFormat.Png.Guid Then
    Debug.Print("png")
    ElseIf .Guid = ImageFormat.Bmp.Guid Then
    Debug.Print("bmp")
    ElseIf .Guid = ImageFormat.Icon.Guid Then
    Debug.Print("icon")
    '... etc
    End If
    End With
    End If


  • naiveinVB

    A button inside your converted usercontrol cannot be selected as a form's AcceptButton. It can thus never be the default button. That would be pretty unusual anyway. Just remove all the code that depends on the button being the default button.

    As I mentioned, use PictureBox1.Image.RawFormat to retrieve the image type.



  • GG71

    Woa, that's enough material for 6 threads. Some hints:
    1. Ambient.DisplayAsDefault is relevant only for button controls. .NET now uses the Form.AcceptButton property to designate the default button. If your control has a button control which acts as the default button for a form, try adding a property to the user control that exposes that button.
    2. Try using ParentForm.Font
    3.
    4. Redesign the gcTimerObjects collection to a VB.NET collection to which you can just add Me.
    5. System.Drawing.Image is an abstract class, consider replacing it with a Bitmap class or PictureBox component. They have a Handle.
    6. Use Bitmap.RawFormat or PictureBox.Image.RawFormat



  • Issues in converting a usercontrol project from VB 6.0 to VB 2005