News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

About icons.

Started by felipe, October 02, 2017, 04:52:07 AM

Previous topic - Next topic

felipe

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

hutch--

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.

jj2007

Quote from: hutch-- on October 02, 2017, 10:24:36 AMyou 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


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

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

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

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

fearless

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



.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




felipe

Great! Thanks fearless!  :t