Announcement

Collapse
No announcement yet.

Issue with title bar icon

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

  • Michael Rice
    replied
    Oops!! I should have been more careful and should have checked the return value. Thanks for pointing out that I was using the wrong function. Hopefully I get 1/2 point for trying!!

    I have noticed a comment in some of Pierre’s code before (I’m paraphrasing here): “We should clean our house before we move out”...that’s good advice

    Leave a comment:


  • Michael Mattias
    replied
    This to %WM_DESTROY:
    Code:
    ....
    DeleteObject hTitleIcon
    Close.. but you have the wrong function to delete the icon from memory; and although you are not testing it (at least not in the code shown!), that is probably failing because the icon is in use... by the window being destroyed.

    So I would suggest something like....

    Code:
    ....
    CASE %WM_DESTROY
        hIcon =   SendMessage (hWnd, WH_SETICON, %ICON_BIG, [B]BYVAL[/B] [B]%NULL[/B])    ' remove icon from window; returns handle to prev icon
        DestroyIcon hIcon
    
        hIcon = SendMessage (hWnd, WH_SETICON, %ICON_SMALL, [B]BYVAL[/B] [B]%NULL[/B]) '  remove icon from window; returns handle to prev icon
        DestroyIcon hIcon
    .....

    FWIW, if you do not end the program when this window is destroyed (e.g it might be a dialog-type window you pop up on request), not properly handling the icons when no longer used is a good way to create a "resource leak."

    But regardless, good for you doing your own cleanup!

    Leave a comment:


  • Michael Rice
    replied
    Classy or Classic... It’s good to have options!! Thanks again for the help and hints!!

    Dave Thanks for pointing this “AfxLoadNamedIconFromResource” out to me. I was wondering about that.

    Leave a comment:


  • Dave Biggs
    replied
    Touché Click image for larger version

Name:	top.gif
Views:	163
Size:	141 Bytes
ID:	805464

    Leave a comment:


  • Stuart McLachlan
    replied
    Originally posted by Dave Biggs View Post

    Sure - it's just "Classier"
    As opposed to being "Classic" ?

    Leave a comment:


  • Dave Biggs
    replied
    Dave Does what I'm doing above do basically the same thing?
    Sure - it's just "Classier"

    .. to use Jose's functions as you are using a CWindow class window..

    BTW AfxLoadIconFromResource (or AfxLoadNamedIconFromResource to suit your alphanumeric Resource ID) uses LoadImage()
    which supersedes LoadIcon.
    Last edited by Dave Biggs; 28 Feb 2021, 11:25 PM. Reason: Added note

    Leave a comment:


  • Michael Rice
    replied
    Stuart Thanks for the hint and yep that was exactly it. I added this and all is well with the world now.

    I added this to %WM_CREATE:
    Code:
    hTitleIcon = LoadIcon(GetModuleHandle(BYVAL %NULL), "PROGICON")
    SendMessage hWnd, %WM_SETICON, %ICON_SMALL, hTitleIcon

    This to %WM_DESTROY:
    Code:
    DeleteObject hTitleIcon
    Dave Does what I'm doing above do basically the same thing?

    Anne I'll check that icon editor out. Right now my icon looks like crap by the time it gets to 16x16. It starts out as a 3000x2610 PNG file...it's just a blur at 16x16

    Leave a comment:


  • Dave Biggs
    replied
    Try,
    Code:
       pWindow.BigIcon = AfxLoadIconFromResource(100, hInstance)
       pWindow.SmallIcon = AfxLoadIconFromResource(101, hInstance)

    Leave a comment:


  • Stuart McLachlan
    replied
    Originally posted by Michael Rice View Post
    I'm using José's CWindow class to create an application. One issue that I'm having is the title bar icon for the window is showing up as plain ole window icon as if I hadn't included an icon at all.

    I'm using this statement to add the icon to the program:
    What statement are you using to assign the icon to the window?

    Hint: %WM_SETICON

    Leave a comment:


  • Anne Wilson
    replied
    A good icon editor , scale to your chosen size
    https://www.awicons.com/icon-editor/

    or use an online icon converter from png to ico file

    http://www.convertico.com/

    Leave a comment:


  • Michael Rice
    started a topic Issue with title bar icon

    Issue with title bar icon

    I'm using José's CWindow class to create an application. One issue that I'm having is the title bar icon for the window is showing up as plain ole window icon as if I hadn't included an icon at all.

    I'm using this statement to add the icon to the program:

    #RESOURCE ICON,PROGICON, "DatabaseSearch.ico"

    The icon displays properly in Windows File Explorer and also is fine in the Windows Task Bar at bottom of my screen.

    Here's the code that I use to create the window:
    Code:
       pWindow.CreateWindow(%NULL, "Database Search", 0, 0, 800, 600, _
                            %WS_OVERLAPPED OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
                            %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE, _
                            0, CODEPTR(WindowProc))
    Originally the code looked like this...both get same result with the title bar icon
    Code:
       pWindow.CreateWindow(%NULL, "Database Search", 0, 0, 800, 600, 0, 0, CODEPTR(WindowProc))
    Also wondering if anyone has any recommendations for a GOOD free icon editor. Hopefully one that can really scale icons. My icon file starts out large...by the time it gets to the 16x16 size...it's just a blur of pixels.
Working...
X