Announcement

Collapse
No announcement yet.

Application icon

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

    Application icon

    [ATTACH]144[/ATTACH]

    #2
    I'm trying to replace the generic title bar icon with my custom application icon.

    1. I created a 16 x 16 bitmap image -- "c:\IconTest\IconA.BMP"

    2. Using RESOURCE BUILDER, I simultaneously created

    a script file: "c:\IconTest\IconA.rc",
    a resource file: "c:\IconTest\IconA.res" and
    an icon file: "c:\IconTest\ICON_0.ICO" from the bitmap image

    3. I copied the icon file and renamed it "IconA.ICO" -- placing it in the same folder.

    "ICON_0.ICO" is the first icon in the "c:\IconTest\" folder

    4. On the command line, in PB4.04, I typed:
    PBRES "c:\IconTest\IconA"

    This successfully created the necessary .PBR file from the .res file. Below is the test program that was designed to replace the generic title bar icon with my custom icon.

    [The main function portion is actually an adaptation of Brent Gardner's post -- March 11th, 2006]

    This test program does NOT change the generic title bar icon to my custom icon as expected.

    Strangely (to me), it changes the generic icon in EXPLORER to the custom icon!

    The commented lines show the various combinations which I have tried, with no success. I am glad for the Explorer icon; however, my primary goal is the title bar icon.

    I need heeeeee-lllp!

    ======================================================

    $COMPILE EXE "c:\IconTest\AppExec.exe"
    #CONSOLE OFF
    #REGISTER NONE
    #INCLUDE "c:\IconTest\Win32Api.Inc"
    #RESOURCE "c:\IconTest\IconA.PBR"
    ' declarations
    ' ............
    GLOBAL GraphicWindowChildOldProc AS DWORD
    FUNCTION GraphicWindowChildNewProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    DIM lResult AS GLOBAL LONG

    ' more declarations
    ' ............
    ' code
    ' ............

    lResult = CallWindowProc (GraphicWindowChildOldProc, hWnd, wMsg, wParam, lParam)
    SELECT CASE wMsg

    ' code
    ' ............

    CASE %WM_NCHITTEST
    IF lResult = %HTTRANSPARENT THEN lResult = %HTCLIENT
    CASE %WM_MOUSEMOVE

    ' code
    ' ............

    CASE %WM_LBUTTONDOWN

    ' code
    ' ............

    CASE %WM_RBUTTONDOWN

    ' code
    ' ............

    END SELECT
    FUNCTION = lResult
    END FUNCTION

    ' ====================================

    FUNCTION WINMAIN (BYVAL hCurInstance AS LONG, _
    BYVAL hPrevInstance AS LONG, _
    BYVAL lpszCmdLine AS ASCIIZ PTR, _
    BYVAL nCmdShow AS LONG) _
    EXPORT AS LONG
    'LOCAL hIcon AS DWORD, hInstance AS LONG
    GLOBAL hIcon AS DWORD, hInstance AS LONG
    hInstance = hCurinstance
    'hIcon = LoadIcon(hInstance, "c:\IconTest\IconA.ICO")
    hIcon = LoadIcon(hInstance, "c:\IconTest\ICON_0.ICO")
    DESKTOP GET CLIENT TO ncWidth&, ncHeight&
    GRAPHIC WINDOW "AppName",0,0, ncWidth&, ncHeight& TO hWin&
    SendMessage hwin&, %WM_SETICON, %ICON_SMALL,hIcon
    GRAPHIC REDRAW : SLEEP 5000
    END FUNCTION

    [Please disregard the initial posting; I am still learning the new forum format.]

    Comment


      #3
      Help in replacing the generic titlebar icon

      I'm trying to replace the generic title bar icon with my custom application icon.

      1. I created a 16 x 16 bitmap image -- "c:\IconTest\IconA.BMP"

      2. Using RESOURCE BUILDER, I simultaneously created

      a script file: "c:\IconTest\IconA.rc",
      a resource file: "c:\IconTest\IconA.res" and
      an icon file: "c:\IconTest\ICON_0.ICO" from the bitmap image

      3. I copied the icon file and renamed it "IconA.ICO" -- placing it in the same folder.

      "ICON_0.ICO" is the first icon in the "c:\IconTest\" folder

      4. On the command line, in PB4.04, I typed:
      PBRES "c:\IconTest\IconA"

      This successfully created the necessary .PBR file from the .res file. Below is the test program that was designed to replace the generic title bar icon with my custom icon.

      [The main function portion is actually an adaptation of Brent Gardner's post -- March 11th, 2006]

      This test program does NOT change the generic title bar icon to my custom icon as expected.

      Strangely (to me), it changes the generic icon in EXPLORER to the custom icon!

      The commented lines show the various combinations which I have tried, with no success. I am glad for the Explorer icon; however, my primary goal is the title bar icon.

      I need heeeeee-lllp!

      ======================================================

      $COMPILE EXE "c:\IconTest\AppExec.exe"
      #CONSOLE OFF
      #REGISTER NONE
      #INCLUDE "c:\IconTest\Win32Api.Inc"
      #RESOURCE "c:\IconTest\IconA.PBR"
      ' declarations
      ' ............
      GLOBAL GraphicWindowChildOldProc AS DWORD
      FUNCTION GraphicWindowChildNewProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
      DIM lResult AS GLOBAL LONG

      ' more declarations
      ' ............
      ' code
      ' ............

      lResult = CallWindowProc (GraphicWindowChildOldProc, hWnd, wMsg, wParam, lParam)
      SELECT CASE wMsg

      ' code
      ' ............

      CASE %WM_NCHITTEST
      IF lResult = %HTTRANSPARENT THEN lResult = %HTCLIENT
      CASE %WM_MOUSEMOVE

      ' code
      ' ............

      CASE %WM_LBUTTONDOWN

      ' code
      ' ............

      CASE %WM_RBUTTONDOWN

      ' code
      ' ............

      END SELECT
      FUNCTION = lResult
      END FUNCTION

      ' ====================================

      FUNCTION WINMAIN (BYVAL hCurInstance AS LONG, _
      BYVAL hPrevInstance AS LONG, _
      BYVAL lpszCmdLine AS ASCIIZ PTR, _
      BYVAL nCmdShow AS LONG) _
      EXPORT AS LONG
      'LOCAL hIcon AS DWORD, hInstance AS LONG
      GLOBAL hIcon AS DWORD, hInstance AS LONG
      hInstance = hCurinstance
      'hIcon = LoadIcon(hInstance, "c:\IconTest\IconA.ICO")
      hIcon = LoadIcon(hInstance, "c:\IconTest\ICON_0.ICO")
      DESKTOP GET CLIENT TO ncWidth&, ncHeight&
      GRAPHIC WINDOW "AppName",0,0, ncWidth&, ncHeight& TO hWin&
      SendMessage hwin&, %WM_SETICON, %ICON_SMALL,hIcon
      GRAPHIC REDRAW : SLEEP 5000
      END FUNCTION

      [Please disregard the initial posting; I am still learning the new forum format.]
      Last edited by George Oluikpe; 3 Feb 2008, 07:04 PM. Reason: To make corrections

      Comment


        #4
        I'm trying to replace the generic title bar icon with my custom application icon.

        1. I created a 16 x 16 bitmap image -- "c:\IconTest\IconA.BMP"

        2. Using RESOURCE BUILDER, I simultaneously created

        a script file: "c:\IconTest\IconA.rc",
        a resource file: "c:\IconTest\IconA.res" and
        an icon file: "c:\IconTest\ICON_0.ICO" from the bitmap image

        3. I copied the icon file and renamed it "IconA.ICO" -- placing it in the same folder.

        "ICON_0.ICO" is the first icon in the "c:\IconTest\" folder

        4. On the command line, in PB4.04, I typed:
        PBRES "c:\IconTest\IconA"

        This successfully created the necessary .PBR file from the .res file. Below is the test program that was designed to replace the generic title bar icon with my custom icon.

        [The main function portion is actually an adaptation of Brent Gardner's post -- March 11th, 2006]

        This test program does NOT change the generic title bar icon to my custom icon as expected.

        Strangely (to me), it changes the generic icon in EXPLORER to the custom icon!

        The commented lines show the various combinations which I have tried, with no success. I am glad for the Explorer icon; however, my primary goal is the title bar icon.

        I need heeeeee-lllp!

        ======================================================

        $COMPILE EXE "c:\IconTest\AppExec.exe"
        #CONSOLE OFF
        #REGISTER NONE
        #INCLUDE "c:\IconTest\Win32Api.Inc"
        #RESOURCE "c:\IconTest\IconA.PBR"
        ' declarations
        ' ............
        GLOBAL GraphicWindowChildOldProc AS DWORD
        FUNCTION GraphicWindowChildNewProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
        DIM lResult AS GLOBAL LONG

        ' more declarations
        ' ............
        ' code
        ' ............

        lResult = CallWindowProc (GraphicWindowChildOldProc, hWnd, wMsg, wParam, lParam)
        SELECT CASE wMsg

        ' code
        ' ............

        CASE %WM_NCHITTEST
        IF lResult = %HTTRANSPARENT THEN lResult = %HTCLIENT
        CASE %WM_MOUSEMOVE

        ' code
        ' ............

        CASE %WM_LBUTTONDOWN

        ' code
        ' ............

        CASE %WM_RBUTTONDOWN

        ' code
        ' ............

        END SELECT
        FUNCTION = lResult
        END FUNCTION

        ' ====================================

        FUNCTION WINMAIN (BYVAL hCurInstance AS LONG, _
        BYVAL hPrevInstance AS LONG, _
        BYVAL lpszCmdLine AS ASCIIZ PTR, _
        BYVAL nCmdShow AS LONG) _
        EXPORT AS LONG
        'LOCAL hIcon AS DWORD, hInstance AS LONG
        GLOBAL hIcon AS DWORD, hInstance AS LONG
        hInstance = hCurinstance
        'hIcon = LoadIcon(hInstance, "c:\IconTest\IconA.ICO")
        hIcon = LoadIcon(hInstance, "c:\IconTest\ICON_0.ICO")
        DESKTOP GET CLIENT TO ncWidth&, ncHeight&
        GRAPHIC WINDOW "AppName",0,0, ncWidth&, ncHeight& TO hWin&
        SendMessage hwin&, %WM_SETICON, %ICON_SMALL,hIcon
        GRAPHIC REDRAW : SLEEP 5000
        END FUNCTION

        [Please disregard the initial posting; I am still learning the new forum format.]

        Comment


          #5
          Code:
          hIcon = LoadIcon(hInstance, "c:\IconTest\ICON_0.ICO")
          If you had (correctly) tested the value of hIcon returned here, you would see that it is null, meaning the load has failed.

          The second parameter to the LoadIcon() function is the name/number of an icon resource, not the name of an icon file.

          So unless the icon resource is named "c:\IconTest\ICON_0.ICO" (case-sensitive) this is your problem. Unfortunately your resource script file is not shown, so I am limited to making this guess. (But I'd bet real money I have made a very good guess).

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


            #6
            Thanks, Michael, for comong to my rescue. Here is the resource script as retrieved from "Resource Builder."

            ===========================

            /*********************************************
            File: C:\TOWERICON\ICONA.RC
            Generated by Resource Builder (2.6.4.1).
            *********************************************/
            /*
            OutputExt=res
            */

            //MS Visual C++ compatible header
            #define APSTUDIO_READONLY_SYMBOLS
            #include "afxres.h"
            #undef APSTUDIO_READONLY_SYMBOLS
            //end of MS Visual C++ compatible header

            ICON_0 ICON "IconA_rc_Files\\ICON_0.ico"

            =============================

            Notice that the script was created in a different folder -- "c:\TOWERICON\." From that I converted to .PBR and then ported everything to the final folder. [I have not been able to extract the .PBR file to list here.]

            Should everything -- the original icon, resource script and the .PBR converstion -- have been placed in the same folder?

            Honestly, I need to be walked through the rest of the process.

            Comment


              #7
              Replace ...
              Code:
              hIcon = LoadIcon(hInstance, "c:\IconTest\ICON_0.ICO")
              ... with ...
              Code:
              hIcon = LoadIcon(hInstance, "ICON_0")
              ... and you should be fine.

              After you've created the *.pbr file, the *.rc, *.res and all other files don't matter to PB anymore. The icon is included in the *.pbr (that why its called a resource) and has been assigend a name (ICON_0) with which you could retrieve the icon form the resource.

              Comment


                #8
                As far as simplifying it.. since your resouces for this program consist only of an icon, I'd just put that icon file in my program folder (where the *.bas and *.rc file are), and eliminate the use of "resource builder" by just hand-typing the resource script.

                I always use a version resource (the use of which I absolutely recommend), which will require the resource.h file be included...and I use other #defines to make it easier to change the version number when I update the software, so my files tend to look like this:
                Code:
                // FILE: filename
                // comments and history go here 
                
                #include resource.h
                
                #define VERSION_MAJOR      3
                #define VERSION_MINOR      2
                #define VERSION_BUILD      0
                #define VERSION_DATE     "August 1 2007\0"
                #define VERSION_LITERAL  "Version 3.2.0\0"
                #define APPL_LITERAL     "PPPS User Interface\0"
                
                // ====================/
                // ICONS AND BITMAPS      //
                // ====================
                
                ICON_O     ICON ICON_0.ICO
                
                // OTHER STUFF (dialog templates, stringtables, etc) goes here
                
                
                
                //PRODUCT VERSION is the one used
                VS_VERSION_INFO VERSIONINFO
                FILEVERSION    VERSION_MAJOR, VERSION_MINOR, 0, VERSION_BUILD
                PRODUCTVERSION VERSION_MAJOR, VERSION_MINOR, 0, VERSION_BUILD
                FILEOS VOS_WINDOWS32
                FILETYPE VFT_APP
                BEGIN
                  BLOCK "StringFileInfo"
                  BEGIN
                    BLOCK "040904E4"
                    BEGIN
                      VALUE "CompanyName",      "Tal Systems Inc.\0"
                      VALUE "FileDescription",   APPL_LITERAL
                      VALUE "FileVersion",       VERSION_LITERAL
                      VALUE "InternalName",     "PPPS\0"
                      VALUE "OriginalFilename", "ppps25\0"
                      VALUE "LegalCopyright",   "\251  2001, 2002 Michael C. Mattias Racine WI USA\0"
                      VALUE "LegalTrademarks",  "Provider Payment Partner is a trademark of Tal Systems Inc.\0"
                      VALUE "ProductName",      "Provider Payment Partner UI\0"
                      VALUE "ProductVersion",   VERSION_LITERAL
                      VALUE "VersionDate",      VERSION_DATE
                    END
                  END
                END
                "\251" is the copyright symbol. Some of my later apps use "equates" for the common symbols....
                Code:
                #define COPYRIGHT_SYMBOL "\251"
                #define REGISTERED_SYMBOL "\256"
                #define TRADEMARK_SYMBOL  "\231"
                FWIW, I have reversed the build and sub-build numbers. Don't do this. (I started this way by mistake and never changed it).

                MCM
                Last edited by Michael Mattias; 5 Feb 2008, 08:14 AM.
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                  #9
                  Thanks, Michael and Knuth. Michael (I believe) correctly diagnosed the problem. When I implemented the change which Knuth suggested (and Michael implicitly), it worked like a charm in the skeletal code which I had posted.

                  Curiously, when I tested it in the real code, I got the icon on the taskbar, but not on the titlebar: the generic icon remains on the titlebar.

                  I am studying what might be taking place in the real code. I appreciate Michael's providing a sample code. I will take time to study it.

                  Any further assistance in pinpointing why the icon now appears on the taskbar but not the titlebar will be appreciated.

                  Comment


                    #10
                    Send two WM_SETICON messages with ICON_BIG and then ICON_SMALL, otherwise the wrong icon will show in Alt+Tab and other places.
                    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                    Comment


                      #11
                      Application icon

                      Hi, Kev;

                      Does this mean also defining two icons, one big and the other small? I have tried just two literal statements and it has not made a difference.

                      I would appreciate a little more detail?

                      Comment


                        #12
                        Hi, Michael, Knuth and Kev; thanks again. After a long break from the program, I have discovered that the culprit was buried deep into the code, overwriting the cusom icon with the unwanted generic one!

                        All I had to do was eliminate the lines of code that overwrote the displayed icon. It is now working as designed. You guys are great.

                        Comment

                        Working...
                        X
                        😀
                        🥰
                        🤢
                        😎
                        😡
                        👍
                        👎