Announcement

Collapse
No announcement yet.

System Icon Does not Show in Shortcut or Taskbar

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

  • System Icon Does not Show in Shortcut or Taskbar

    Sometimes I like using a system icon for my app, just to pretty it up without having to include a #Resource or to distribute the ico file, like this ...

    Code:
             hIcon = LoadIcon(ByVal %Null, ByVal %IDI_Question)  'use a system icon for the dialog
             SendMessage hDlg, %WM_SetIcon, %ICON_BIG, hIcon        'use a system icon for the dialog
    The icon shows in the Dialog caption bar, but not in a shortcut to the EXE nor on the TaskBar when the EXE is running. Can I use a system icon for those two purposes?

  • #2
    Gary

    I use icons so that I can have easy to use references in my task bar for selecting a program. I also have one program which I want to demonstrate it is running so it puts a nice recognisable icon in the task bar. I like single big colour icons as they stand out. Actually they also make the program stand out in the folder listing.

    But I am quite interested - what is wrong with using #Resource icons?

    Kerry

    ps I have decided to use British spelling in my messages!!
    [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
    Kerry Farmer

    Comment


    • #3
      Hi Kerry!

      I use #Resource all the time - love it. But sometimes I want to post an example that is easier for forum folks to test out - something that does not depend on other files so that I don't have to post links and folks here don't have to download anything but the code.

      Comment


      • #4
        Try setting %ICON_SMALL too. This works for me:
        Code:
          DIALOG SEND hDlg, %WM_SETICON, %ICON_SMALL, LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
          DIALOG SEND hDlg, %WM_SETICON, %ICON_BIG, LoadIcon(%NULL, BYVAL %IDI_APPLICATION)

        Comment


        • #5
          But quick test shows setting only big icon show small icon in taskbar when running too, so don't understand the problem. Only have Win7, so maybe later system treats icons slightly different?

          Comment


          • #6
            Howdy, Borje!

            Win10 here. I pulled out just the basic code. When I compile it, the Explorer listing of the EXE does not show the Question icon.

            If I create a shortcut to the EXE, the shortcut icon is not the Question.

            If I run the app, the TaskBar does have the Question icon. But on the gbProcedures app I recently posted, using similar code, the TaskBar does not display the Question. Likewise, adding the small icon as you suggest does not display the Question in gbProcedures. I'll have to look at that to see what I might have done to make it fail.

            Code:
            'Compilable Example:
            #Compile Exe
            #Dim All
            %Unicode = 1
            #Include "Win32API.inc"
            
            Global hDlg,hIcon As Dword
            
            Function PBMain() As Long
               Dialog Default Font "Tahoma", 12, 1
               Dialog New Pixels, 0, "Email Date",300,300,350,200, %WS_OverlappedWindow To hDlg
               Dialog Show Modal hDlg Call DlgProc
            End Function
            
            CallBack Function DlgProc() As Long
               Select Case Cb.Msg
                  Case %WM_InitDialog
                     hIcon = LoadIcon(ByVal %Null, ByVal %IDI_Question)  'use a system icon for the dialog
                     SendMessage hDlg, %WM_SetIcon, %ICON_BIG, hIcon        'use a system icon for the dialog
               End Select
            End Function

            Comment


            • #7
              Gary,

              This is a TWAG... (Totally Wild A$$ Guess)

              Thought crossed my mind:
              Maybe Win won't display the icon if there's not enough space for it? (similar to when a control doesn't have enough height for a font)

              So I don't know if this is relevant, but I recalled seeing something that may be worth a look:
              Look at the API Help for: GetSystemMetrics, under SM_CXSMICON, SM_CYSMICON...

              I hope this isn't a rabbit-hole looking for a guest!

              -John

              Comment


              • #8
                Originally posted by Gary Beene View Post
                Sometimes I like using a system icon for my app, just to pretty it up ...
                I ran across your post but I have a different issue. I want the little icon in the title bar and the Powerbasic docs say it is supposed to be there if you select the ws_caption and ws_sysmenu styles. I'm running Win 10 and I find out that the icon sometimes displays and sometimes it doesn't when the dialog opens. Oddly enough it seems to display while you are designing the dialog in PBForms and almost always in the "Test" mode of PBForms. So I did some digging and found on Microsoft that you need to SendMessage WM_SETICON when the dialog is initialized. Exactly the stuff noted here! I like the way Borje does it because it requires less setup and is cleaner. I'm only doing the small icon because that is all I care about. Worked like a charm! Seems like this may be a slip up on PB part.

                Comment


                • #9
                  I ran across your post but I have a different issue. I want the little icon in the title bar and the PowerBASIC docs say it is supposed to be there if you select the ws_caption and ws_sysmenu styles.
                  No. Those styles must be set for DIALOG SET ICON or SendMessage %WM_SETICON to show the icon.

                  I am unable to duplicate the sometimes icon doesn't show problem. Either the DIALOG SET ICON (DDT method) or the SendMessage (API/SDK method) will work in PBWin 9.xx or 10.xx for dialogs and GRAPHIC WINDOWs. In PBCC the console icon is automatic if icon is a resource. GRAPHIC WINDOWs in PBCC require SendMessage.

                  PBForms 2.00 is older than PBWin 9.05. PBWin 9.xx only had #RESOURCE "xxxx.pbr" command, not all the #RESOURCE xxxx, ###, "xxxxx.xxx" commands that PBWin 10.xx has. So PBForms works as designed "at-the-time"; no slip-ups.

                  Personally, when I use PBForms with PBWin 10, and have all the controls I need, I view RC Code in PBForms and copy the pieces I need to #RESOURCE lines in the .bas file, then delete the xxxx.pbr line.

                  If still having problem with icons, please post sample code that fails and the downloadable icon that does not display every time.

                  Cheers,

                  (added - I expect TXT.WINDOW to behave like GRAPHIC WINDOW (Re icons) in PBWin and PBCC. (not tested))
                  Dale

                  Comment


                  • #10
                    Originally posted by Dale Yarker View Post
                    Personally, when I use PBForms with PBWin 10, and have all the controls I need, I view RC Code in PBForms and copy the pieces I need to #RESOURCE lines in the .bas file, then delete the xxxx.pbr line.
                    Me too.
                    I go further. There's a lot of extraneous stuff in the PBForms code so I just copy the dialog and control layout and style definitions etc and scrap the rest. I've got a template which already includes manifest and version info #RESOURCE statements.)

                    Comment


                    • #11
                      Originally posted by Ray Crumrine View Post
                      Seems like this may be a slip up on PB part.
                      No slip up. That's what DIALOG SET ICON does

                      Comment


                      • #12
                        Originally posted by Gary Beene View Post
                        Howdy, Borje!

                        Win10 here. I pulled out just the basic code. When I compile it, the Explorer listing of the EXE does not show the Question icon.

                        If I create a shortcut to the EXE, the shortcut icon is not the Question.

                        If I run the app, the TaskBar does have the Question icon. But on the gbProcedures app I recently posted, using similar code, the TaskBar does not display the Question. Likewise, adding the small icon as you suggest does not display the Question in gbProcedures. I'll have to look at that to see what I might have done to make it fail.
                        You need to be aware that Windows caches icons. If you change the icon after you have compiled your application once, Windows will frequently remember the old icon and not reflect the change. In extremis, you can delete iconcache.db in %appdata%\local and/or all of the iconcache*.db files in
                        \AppData\Local\Microsoft\Windows\Explorer. (depending on Windows version)


                        For the process to delete the cache files, see https://www.howtogeek.com/232779/how...in-windows-10/

                        Comment


                        • #13
                          Originally posted by Dale Yarker View Post
                          PBForms 2.00 is older than PBWin 9.05. PBWin 9.xx only had #RESOURCE "xxxx.pbr" command, not all the #RESOURCE xxxx, ###, "xxxxx.xxx" commands that PBWin 10.xx has. So PBForms works as designed "at-the-time"
                          That explains it but the PB web page indicates they are still shipping version 2.01 today.

                          If still having problem with icons...
                          Nope, Borge's code line fixes it perfectly. I'll just add "PBR" in the generated code [and the path to the file to be safe but that's another story]

                          Thanks

                          Comment


                          • #14
                            That explains it but the PB web page indicates they are still shipping version 2.01 today.
                            Why not? It still saves a lot of arithmetic (location & sizes), and typing (styles ORed). Easy change to PBWin 10 (without PBR).

                            Cheers,
                            Dale

                            Comment

                            Working...
                            X