Announcement

Collapse
No announcement yet.

Additional Icons in a windows title bar??

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

  • Additional Icons in a windows title bar??

    Greetings and Salutations all,
    Didn't I see on this BBS a while ago, someone post some code on how to
    add additional icons to a windows title bar??
    I know to paint there you need to process the NC_PAINT message, but I did a
    search of the BBS and returned nothing. Maybe I am mistaken and I did not
    see it, except in my dreams.
    If anyone could point me to such code that would be great.
    Kevin

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

  • #2
    Do you mean just using a different icon from your resource file?

    IF so.
    g_hIcon = LoadIcon( g_hInst, ByVal %PROGRAM)

    %PROGRAM is defined as 1024 in my apps, don't know why but it is

    You could change it at startup:
    Code:
        InitCommonControls
    
        wndclass.cbSize        = SizeOf(WndClass)
        wndclass.style         = %CS_HREDRAW Or %CS_VREDRAW
        wndclass.cbClsExtra    = 0
        wndclass.cbWndExtra    = 0
        wndclass.hInstance     = hInstance
        wndclass.hCursor       = LoadCursor( %NULL, ByVal %IDC_ARROW )
        wndclass.hbrBackground = GetStockObject( %WHITE_BRUSH )
        wndclass.lpszMenuName  = %NULL
        wndclass.lpszClassName = VarPtr(lpClassName)
        wndclass.lpfnWndProc   = CodePtr( WndProc )
        wndclass.hIcon         = LoadIcon( hInstance, ByVal %PROGRAM)
        wndclass.hIconSm       = LoadIcon( hInstance, ByVal %IDI_APPLICATION )
        RegisterClassEx wndclass

    But if you want to change it dynamically you can too, I just can't find that snippet of code for doing it.
    I had a program that would change icons every time you launched it hehe...


    Scott

    ------------------
    Scott
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    Comment


    • #3
      Scott,
      Not quite, I know how to change the program icon. I was looking to
      add another icon next to the minimize button on the title bar. Maybe I
      should have said I wanted to add another button next to the minimize
      button as it is a button I want not an icon.
      Thanks for the reply though.
      Kevin

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

      Comment


      • #4
        Here is a try

        Peter

        Code:
        #compile exe
        #dim all
        #register none
        #include "win32api.inc"
         
        global hInst as long
         
        declare callback function DlgProc
         
        function pbmain
         
            local hDlg as long
         
            hInst = GetModuleHandle(byval %NULL)
         
            dialog new 0, "",,,300, 100, %WS_SYSMENU or %WS_MINIMIZEBOX or %DS_CENTER to hDlg
            dialog show modal hDlg call DlgProc
         
        end function
         
        callback function DlgProc
         
            local hdc as long, ps as PAINTSTRUCT
            static hIcon1 as long, hIcon2 as long
         
            select case cbMsg
            case %WM_INITDIALOG
        	hIcon1 = LoadIcon(0,byval %IDI_APPLICATION)
        	hIcon2 = LoadIcon(0,byval %IDI_HAND)
         
        	dialog send cbhndl, %WM_SETICON, %ICON_BIG, hIcon1
         
            case %WM_PAINT
        	hdc = GetWindowDC(cbhndl)
        	DrawIcon hdc, 30, 1, hIcon2
        	ReleaseDC cbhndl, hdc
         
            end select
         
        end function
        ------------------
        [email protected]
        www.dreammodel.dk

        Comment


        • #5
          Peter,
          That is close to what I want to do. But I want to actually put the
          icon/button on the title bar. The example you wrote seems to draw over
          the title bar from the client area. Not quite what I wanted to do.
          Thank you for the reply though.
          Any other ideas.
          Kevin

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

          Comment


          • #6
            kevin,

            i hope your dreams come true...

            http://www.powerbasic.com/support/pb...ad.php?t=22694

            regards,
            jules
            Best regards
            Jules
            www.rpmarchildon.com

            Comment


            • #7
              Jules
              Thanks, that is the example I remember.

              Thanks to everyone for their help/time.
              Kevin

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

              Comment

              Working...
              X