Announcement

Collapse
No announcement yet.

program icon

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

  • program icon

    This one has got me buggered...
    Ive got an .rc file - test.rc, with this:
    Code:
    #include "resource.h"
    PROGRAMICON ICON MYICON.ICO
    And my program:
    Code:
    #COMPILE EXE
    #RESOURCE "myicon.pbr"
    #INCLUDE "win32api.inc"
    GLOBAL Form1 AS LONG
     
    FUNCTION WINMAIN (BYVAL hCurInstance AS LONG, _
                      BYVAL hPrevInstance AS LONG, _
                      lpCmdLine AS ASCIIZ, _
                      BYVAL nCmdShow AS LONG) AS LONG
    DIALOG NEW 0, "Icon Test",  50,  50,  195,  87,  %DS_CENTER + %DS_SETFOREGROUND + %WS_MINIMIZEBOX + %WS_SYSMENU + %WS_CAPTION TO Form1
    DIALOG SHOW MODAL Form1
    END FUNCTION
    That compiles fine and looking at my exe in Explorer I can clearly see that the icon is successfully assigned to it. But when I run the program, the icon is the standard Windows icon !?!?! It doesnt make any sense to me, does anybody know whats going on here?


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

  • #2
    Wayne,

    Explorer shows the icon because that's the association with
    the EXE file.

    I dont't use DDT, but this is what you'll need to do:

    1. Load the icon resource with the LoadIcon() fn.
    2. Use the SetClassLong() fn to put the icon in the dialog, or
    AKA window.

    Should work fine!!!

    Cheers,
    Cecil

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

    Comment


    • #3
      Another way:
      Code:
        DIALOG NEW ..
        SendMessage Form1, %WM_SETICON, %ICON_SMALL, _
                    LoadIcon(GetModuleHandle(BYVAL %NULL), "PROGRAMICON")
        SendMessage Form1, %WM_SETICON, %ICON_BIG, _
                    LoadIcon(GetModuleHandle(BYVAL %NULL), "PROGRAMICON")

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

      Comment


      • #4
        Thankyou very much! In the past though my initial dialog window always seemed to have the icon in its dialog by default somehow but not anymore for some reason, but Borje those two lines did the trick perfectly (without modification! )


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

        Comment


        • #5
          Wayne,

          Sidebar: While the SendMessage fn is functional also,
          the WM_SETICON message id has OS limitations.

          Code:
          QuickInfo
            Windows NT: Requires version 4.0 or later.
            Windows: Requires Windows 95 or later.
            Windows CE: Requires version 1.0 or later.
            Header: Declared in winuser.h.
          In other words, will not work on NT3.XX.

          Cheers,
          Cecil


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

          Comment


          • #6
            Well, Windows CE is not an issue as PowerBASIC does not support that platform. The rest can be taken care of with a #OPTION VERSION4 metastatement.

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Lance,

              Granted CE is not an issue, never the question to begin with.
              Stating that #OPTION VERSION3 or 4 would be the cure is incorrect
              also. What the above means is that at API Level 3, the
              DefWindowProc would not process the WM_SETICON message, period,
              its' return is guaranteed to be zero(0) on any message id that
              it does not have built in.

              Running the above test EXE on an OS at API Level3 would not
              result in the icon change. I don't have NT3.51 on my machine
              but if anyone does, see if it works.

              Cheers,
              Cecil

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

              Comment


              • #8
                Cecil, you may have taken my message in the wrong light?!

                By specifying #OPTION VERSION4, you effectively prevent your app from running on NT3.51 and therefore no icon problem will exist... hence the smiley face on the end of my comment.



                ------------------
                Lance
                PowerBASIC Support
                mailto:[email protected][email protected]</A>
                Lance
                mailto:[email protected]

                Comment

                Working...
                X