dcsimg
Results 1 to 17 of 17

Thread: VS 2017 trying to load a icon and convert to int cant seem to get it right

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,967

    VS 2017 trying to load a icon and convert to int cant seem to get it right

    hey
    i am trying to load a custom icon and convert it to an integer
    i have the function that loads the icon
    but im stuck there.
    this is the code

    Code:
     Dim syspic As Long = LoadIconFromFile(strAppPath & "\question.ico")
    Code:
        Public Function LoadIconFromFile(ByVal fileName As String) As Icon
            Return New Icon(fileName, New Size(32, 32))
        End Function
    this needs to be an integer
    Code:
                Tc.MainIcon = TaskDialogIcon.xtpTaskIconCustom
                Tc.MainIconHandle = syspic 'need to be a number
    tnx for any help
    salsa

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,290

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    I'm not at my PC right now, but the Integer you're referring to is probably the DC. Have a look at .GethDC

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,967

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    Quote Originally Posted by .paul. View Post
    I'm not at my PC right now, but the Integer you're referring to is probably the DC. Have a look at .GethDC
    i dont understand sir.
    this:Tc.MainIconHandle = here needs to be a number

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,290

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    Syspic is not type Long.
    Tc.MainIconHandle should be an integer, so you need to look at the icon's properties in Intellisense.
    It will be a handle property or a DC property, which is what i've told you to look for

  5. #5

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,967

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    what is DC property?

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,290

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    I think you need to explain exactly what you are trying to do with your icon. A DC is a device context. I can't work out what you're trying to do with your code...

  7. #7

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,967

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    load an custom icon to a dialogbox
    i see this but it for vb6
    Code:
    Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst _
        As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 _
        As Long, ByVal un2 As Long) As Long
     
    Function LoadIcon(Path As String, cx As Long, cy As Long) As Long
        LoadIcon = LoadImage(App.hInstance, Path, IMAGE_ICON, cx, cy, LR_LOADFROMFILE)
    End Function
     
    taskDialog.MainIconHandle = LoadIcon(Path, 0, 0)

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,290

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    This works...

    Code:
    Dim frm As New Form2
    frm.Icon = Icon.FromHandle(New Bitmap("Z:\Pictures\red_dot.png").GetHicon)
    frm.ShowDialog()

  9. #9

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,967

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    Name:  555.jpg
Views: 24
Size:  12.4 KB

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,290

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    What type of dialog is tc? Is it a custom dialog you have created?

  11. #11

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,967

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    yes sir

  12. #12

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,967

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right


  13. #13
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,290

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    Quote Originally Posted by salsa31 View Post
    yes sir
    Change your icon exactly as i suggested in post #8.

  14. #14
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    33,847

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    Note that the example that .Paul showed in #8 used the method to set the icon itself. You then changed that to try to use the same method to set the handle. Those are not the same thing, which is why you got the error. A handle is always a 32 bit integer. In VB6, it would be a Long, but in .NET it would be either an Integer or a UInt, and either one would probably work. In Windows, EVERYTHING has a handle, which is just a way to reference the item. It's not the item itself, it's just a tag attached to the item.
    My usual boring signature: Nothing

  15. #15
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    33,847

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    Wow, four posts while I was writing just that?
    My usual boring signature: Nothing

  16. #16

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,967

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    Quote Originally Posted by .paul. View Post
    Change your icon exactly as i suggested in post #8.
    i did
    look post 9

  17. #17
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,290

    Re: VS 2017 trying to load a icon and convert to int cant seem to get it right

    Quote Originally Posted by salsa31 View Post
    i did
    look post 9
    You didn't you just need to set tc.icon
    Forget the mainicon and the iconhandle...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width