Author Topic: About icons.  (Read 264 times)

felipe

  • Member
  • ***
  • Posts: 376
  • assemble the unassembled.
About icons.
« on: October 02, 2017, 04:52:07 AM »
I'm happy to report  :biggrin: that i was able to create and load a small and big icon to a window program  :greensml:
Then i tryed, just to see if can be done, to doit with a console program and it work!.   :greensml:
Of course it's great and i'm very happy with that.  :greenclp:
But i'm a curious cat  :P, why it worked if i didn't changed anything in the console program and, of course, there wasn't a function in the console program like LoadIcon or similar, like in a window program?  :redface:

Thanks in advance for your responses  :t
Felipe.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4934
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: About icons.
« Reply #1 on: October 02, 2017, 10:24:36 AM »
felipe,

The OS will find an icon in an executable file but from memory you can't get a manifest to work from a console app. You can use an RC file to store binary data and unicode strings but I don't think you can set up a version control block from a console app. I personally use console apps just for non UI grunt work so I am not particularly bothered by the stuff they can't do.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

jj2007

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Re: About icons.
« Reply #2 on: October 02, 2017, 10:41:31 AM »
you can't get a manifest to work from a console app. You can use an RC file to store binary data and unicode strings but I don't think you can set up a version control block from a console app.

I don't use it either in console apps but it is possible:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  Inkey "The application uses ComCtl32.dll version ", ComCtl32$("%i.%i")
EndOfCode


Code: [Select]
The application uses ComCtl32.dll version 6.16
Check also the properties of the attached exe.

For a more detailed example, see this thread.

felipe

  • Member
  • ***
  • Posts: 376
  • assemble the unassembled.
Re: About icons.
« Reply #3 on: October 02, 2017, 10:50:44 AM »
Ok. Thanks.
I want to do other question related to icons:

Is there a way to create an icon with transparent background (to only see the figure of the icon, not in a square) with the tools in the masm32 sdk package, or i have to look for other program to doing that work?

Thanks in advance! :icon14:
Felipe.

felipe

  • Member
  • ***
  • Posts: 376
  • assemble the unassembled.
Re: About icons.
« Reply #4 on: October 02, 2017, 11:10:25 AM »
Btw, thanks a lot!  :biggrin: I'm very new to icons and .rc files.  Also, i hadn't seen the link of the thread pointed to by jj. First i didn't undestand to much what hutch was saying  :biggrin:, but soon as i can i will start to familiarize with manifest, icons and others...

Thank you very much!  :icon14:
Felipe.

felipe

  • Member
  • ***
  • Posts: 376
  • assemble the unassembled.
Re: About icons.
« Reply #5 on: October 02, 2017, 12:10:48 PM »
Btw, here is an example of the icon in the console program. The program is an old toy that i posted some months ago, but is used here to show an example. With the .rc file, the .asm file and the .ico file only, qeditor  :biggrin: with the option  "Console Build All", creates an executable with an icon (in the window menu, task bar, etc).  :t

Edited: I took away the path's format: "c:\masm32\..." that was in that old program... :redface:  :P
Felipe.

fearless

  • Member
  • ***
  • Posts: 281
    • LetTheLightIn
Re: About icons.
« Reply #6 on: October 03, 2017, 03:10:39 AM »
There is also a SetConsoleIcon api call, so icon can be changed to reflect different status to user or whatever use you can imagine. I used this along with CreateTimerQueueTimer recently to have an eye icon appear to be 'blinking' every 5 seconds for a tool i contributed to called DbgChild. NewProcessWatcher.exe (which is part of the DbgChild package) is a console based program: https://github.com/David-Reguera-Garcia-Dreg/DbgChild/blob/dd92fef9d8e42f5fd4909679f9f5d29bac7da2c2/NewProcessWatcher/NewProcessWatcher/NewProcessWatcher.cpp#L92



Code: [Select]
.data
szSetConsoleIconProc    db "SetConsoleIcon", 0
szKernel32Proc          db "kernel32.dll",0

.code
;-----------------------------------------------------------------------------------------
; ConsoleIcon
;-----------------------------------------------------------------------------------------
ConsoleIcon PROC    IcoResID:DWORD
    LOCAL hMod:DWORD
    LOCAL hModKernel32:DWORD
    LOCAL hConIcon:DWORD
 
    Invoke GetModuleHandle, 0
    mov hMod, eax
    Invoke LoadIcon, hMod, IcoResID
    mov hConIcon, eax
   
    Invoke GetModuleHandle, Addr szKernel32Proc
    mov hModKernel32, eax
   
    Invoke GetProcAddress, hModKernel32, Addr szSetConsoleIconProc
    push hConIcon
    call eax ; call SetConsoleIcon with one parameter: handle of icon to set
    ret
ConsoleIcon endp


fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI, Samsung 256GB + 1TB SSD, WD Black 2TB x2 + 4TB HDD, Asus 27" LCD

www.LetTheLight.in  My Github

felipe

  • Member
  • ***
  • Posts: 376
  • assemble the unassembled.
Re: About icons.
« Reply #7 on: October 03, 2017, 04:35:07 AM »
Great! Thanks fearless!  :t
Felipe.