Announcement

Collapse
No announcement yet.

LoadImage problem...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • LoadImage problem...

    Hello all...

    I am having troubles getting the following function to return a valid icon handle.

    hicon = LoadImage(%NULL, ByVal %IDI_WINLOGO, %IMAGE_ICON, 16, 16, %LR_DEFAULTSIZE)

    Would anybody out there be able to help me understand why this does not work?

    Cheers!


  • #2
    Mark;

    You should use the Loadicon function for the builtin Icons.

    hIcon&=LoadIcon(0, BYVAL MAKLNG(%IDI_WINLOGO,0))



    ------------------
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #3
      LoadImage will work too, but as I recall you have to use %LR_SHARED for the stock icons because they are "shared" resources.

      -- Eric

      ------------------
      Perfect Sync: Perfect Sync Development Tools
      Email: mailto:[email protected][email protected]</A>

      "Not my circus, not my monkeys."

      Comment


      • #4
        Hello again!

        Well, now the icon shows up but it doesn't want to be resized to 16x16 so that it will look right on the status bar.

        Any ideas?

        ------------------

        Comment


        • #5
          The built-in Icons are not 16 x 16. They are only 32 x 32.

          For Icons that look good at 16 x 16, you may have to create your own. If you use a 16 x 16 icon, then you should use LoadImage and not LoadIcon.


          ------------------
          Chris Boss
          Computer Workshop
          Developer of "EZGUI"
          http://cwsof.com
          http://twitter.com/EZGUIProGuy

          Comment


          • #6
            Hello again...

            Well thats all well and good but isn't the windows logo icon on the start button 16x16?

            Cheers!

            ------------------

            Comment


            • #7
              Mark --
              Do not mix id for LoadIcon and LoadBitmap
              Code:
              #Compile Exe
              #Register None
              #Include "Win32Api.Inc"
              Function PbMain
                  Local hDlg As Long, i As Long
                  Dialog New 0 ,"Test",0,0, 70, 140, %DS_CENTER Or %WS_OVERLAPPEDWINDOW To hDlg
                  For i = 100 To 105
                     Control Add ImgButton, hDlg, 101 + i,  "", 10, 20 * (i- 100)+10, 50, 15
                     Control Send hDlg, 101 + i, %BM_SETIMAGE, %IMAGE_ICON, _
                     LoadImage(ByVal 0, ByVal i, %IMAGE_ICON, 16, 16, 0)
                   Next
                  Dialog Show Modal hDlg
              End Function
              ------------------

              Comment


              • #8
                Mark --

                > isn't the windows logo icon on the start button 16x16?

                The Task Bar is a little weird... The Start button is actually a true Button, and that's a Windows Logo bitmap, not an icon. The rest of the Task Bar "buttons" are actually part of a tab control with the button style, and Windows displays icons on the tabs.

                And while the IDI_WINLOGO icon actually does contain a 16x16 image (as well as 10x10, 12x12,14x14, 22x22, and 32x32), what you see is what you get. The 16x16 icon just isn't as "pretty" as the Start button's bitmap. (Stock icons are located in USER32.DLL and can be extracted with programs like MicroAngelo if you want to examine them.)

                HTH.

                -- Eric



                ------------------
                Perfect Sync: Perfect Sync Development Tools
                Email: mailto:[email protected][email protected]</A>

                "Not my circus, not my monkeys."

                Comment


                • #9
                  Folks --
                  Is it possible to create non-owndrawn button with text + bitmap/ico ?

                  ------------------

                  Comment


                  • #10
                    Hello Semen and others!

                    I tried your example and it worked, my question is, why does the MSDN documentation say to use the OEM constants to select what icon to display. for example %OIC_WINLOGO. I would also like to know why Microsoft has the same numbers defined twice?

                    OIC_WINLOGO = 32517
                    IDI_WINLOGO = 32517

                    I would like to know where you found the icon numbers in your example. Are there any constants defined for these already?

                    Cheers!


                    ------------------

                    Comment


                    • #11
                      Semen --

                      You mean like "%BS_TEXT OR %BS_ICON"? The numeric value of %BS_TEXT is zero, so it is not possible to OR it with a value like %BS_BITMAP or %BS_ICON and really accomplish anything. I believe that a non-owner-draw button can contain text or an image, not both.

                      -- Eric

                      P.S. I suppose you could simulate a button with text+image by creating a bitmap that included the image of some text.

                      ------------------
                      Perfect Sync: Perfect Sync Development Tools
                      Email: mailto:[email protected][email protected]</A>



                      [This message has been edited by Eric Pearson (edited March 09, 2000).]
                      "Not my circus, not my monkeys."

                      Comment


                      • #12
                        Eric --
                        Yes, I mean something like "%BS_TEXT OR %BS_ICON".
                        With own-drawn all is clear, but I'm too lazy to do it each time.

                        Mark --
                        Icon #: interesting question - I took them from one sample.
                        In NT4, NT5, Win95b - works, sure.
                        In Win98 - not tested, but I think works also.

                        [This message has been edited by Semen Matusovski (edited March 09, 2000).]

                        Comment


                        • #13
                          Mark;

                          The reason Microsoft has icon constants with the same numeric value in the API inc file is simply "redundancy". Some constants are used with LoadIcon and others are used with the MessageBox function.

                          There is actually quite a lot of "Redundancy" in the API.


                          ------------------
                          Chris Boss
                          Computer Workshop
                          Developer of "EZGUI"
                          http://cwsof.com
                          http://twitter.com/EZGUIProGuy

                          Comment

                          Working...
                          X