News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Hide Icon from TaskbarList

Started by ic2, December 14, 2007, 06:12:05 AM

Previous topic - Next topic

ic2

Since I got my Phone and DSL turned back on last week Hiding a Window from Taskbar was my problem for months.  Trying to Paint it all turned into learning something new to making-no-since (things got sloppy).  There had to be a easier, more practical way...

this is from the msdn:
QuoteThere are two ways to prevent a window from appearing on the shell's  taskbar and in the task list window that appears when you press ALT+TAB.

Give the window the WS_EX_TOOLWINDOW extended style, and remove the WS_EX_APPWINDOW style. As a side effect, the window will have a smaller caption than a normal window.

Give the window the WS_POPUP style and make it owned by a hidden window.

This is just about all the information to be founded ANYWHERE, nearly everywhere  when it comes to doing this type of thing.

After days of searching I finally founded this thread and donkey Go-Asm code.

I been trying to turn it into masm code.  I think I got most of the code ready for masm32.  I placed it all in a dialog example from the masm32 package attacted below.

The hardest part is the macro.  Macros is something I never really tried to learn much about until now because I like seeing how things works manually  and that must have turned into a bad habit.

Anyway,  a masm macro do seem more easy to follow than a Go-ASM macro.  I  did learn a lot about Go-ASM.  This code caused me to read a lot from the Go-ASM manual.

I did all the translation I can.  Could someone help correct this code.  I been at it for what seems like forever.  I thought I could do it with-out asking for help but now i'm totally lost, busted and discussed trying to figure out something that should be common knowledge for me by now :( 

Thanks in advance.


CoInvoke(%pInterface,%Method,%0,%1,%2,%3,%4,%5,%6,%7,%8

,%9) = \
#IF ARGCOUNT = 12 \
push %9 \
#ENDIF \
#IF ARGCOUNT > 10 \
push %8 \
#ENDIF \
#IF ARGCOUNT > 9 \
push %7 \
#ENDIF \
#IF ARGCOUNT > 8 \
push %6 \
#ENDIF \
#IF ARGCOUNT > 7 \
push %5 \
#ENDIF \
#IF ARGCOUNT > 6 \
push %4 \
#ENDIF \
#IF ARGCOUNT > 5 \
push %3 \
#ENDIF \
#IF ARGCOUNT > 4 \
push %2 \
#ENDIF \
#IF ARGCOUNT > 3 \
push %1 \
#ENDIF \
#IF ARGCOUNT > 2 \
push %0 \
#ENDIF \

push [%pInterface] \
mov eax, [%pInterface] \
mov eax,[eax] \
add eax, %Method \
call [eax]




PS:  Dark Schneider Started this thread but it seem that it moved on to other things.

http://www.masm32.com/board/index.php?PHPSESSID=5997bc318e1535bd00b60094fa10864e&topic=6148.0

so I post this question, a copy of donkey orginal code (ITaskbarList.zip)
and my attempt at it in masm code (TbDialog3.zip):

[attachment deleted by admin]

donkey

#1
You might think about using GoAsm ? However if you are determined to use MASM...

Unknown STRUCT
QueryInterface DWORD ?
AddRef DWORD ?
Release DWORD ?
Unknown ends

ITaskbarList STRUCT
IUnknown Unknown <>

HrInit DWORD ?
AddTab DWORD ?
DeleteTab DWORD ?
ActivateTab DWORD ?
SetActiveAlt DWORD ?
ITaskbarList ends

.const
sCLSID_TaskbarList textequ <{056fdf344H, 0fd6dH, 011D0H,\
{095H, 08ah, 000H, 060H, 097H, 0c9H, 0a0H, 090H}}>

sIID_ITaskbarList textequ <{056FDF342H, 0FD6DH, 011D0H,\
{095H, 08AH, 000H, 060H, 097H, 0C9H, 0A0H, 090H}}>

.data
CLSID_ITaskbarList GUID sCLSID_TaskbarList
IID_ITaskbarList GUID sIID_ITaskbarList

.code

ShowTab proc uses edi hWnd:DWORD,fShow:DWORD
LOCAL ptb :DWORD

invoke CoCreateInstance,ADDR CLSID_ITaskbarList,NULL,CLSCTX_INPROC_SERVER,\
ADDR IID_ITaskbarList,ADDR ptb
.IF eax != S_OK
mov eax,-1
ret
.endif

push ptb
mov edi,ptb
mov edi,[edi]
call [edi].ITaskbarList.HrInit
.IF eax != S_OK
push ptb
call [edi].ITaskbarList.IUnknown.Release
mov eax,-1
ret
.endif

push hWnd
push ptb
.IF fShow
call [edi].ITaskbarList.AddTab
.ELSE
call [edi].ITaskbarList.DeleteTab
.ENDIF
.IF eax != S_OK
push ptb
call [edi].ITaskbarList.IUnknown.Release
mov eax,-1
ret
.endif

push ptb
call [edi].ITaskbarList.IUnknown.Release

xor eax,eax

ret
ShowTab endp
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ic2

Thanks donkey

I was hoping that you would have the time to help.  I was seriously at the border of switching, but to switch just because of one block of fancy code would have been crazy..

Like nearly everyone here, I got a tons of programs (examples) and everything build with masm over a lot of years.

There really should be a entire tute for your Taskbar example, or more comments.  I know it was just a example to help someone but that will be a great start for me and others because it does a lot of little things that can be explain for GoAsm.  It made me more wise about GoAsm but I'm not ready to switch yet.

Anyway, I put all of the code in an easer to follow dialog example and the code is not working.  I'm sure I set everything up properly.       Could you show me what's wrong.

Attachment below



.386   
.model      flat, stdcall
option      casemap:none

;     include files
;     ~~~~~~~~~~~~~
      include \masm32\include\windows.inc
      include \masm32\include\masm32.inc
      include \masm32\include\gdi32.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc
      include \masm32\include\Comctl32.inc
      include \masm32\include\comdlg32.inc
      include \masm32\include\shell32.inc
      include \masm32\include\oleaut32.inc
      include \masm32\include\ole32.inc

;     libraries
;     ~~~~~~~~~
      includelib \masm32\lib\masm32.lib
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      includelib \masm32\lib\Comctl32.lib
      includelib \masm32\lib\comdlg32.lib
      includelib \masm32\lib\shell32.lib
      includelib \masm32\lib\oleaut32.lib
      includelib \masm32\lib\ole32.lib

DlgProcedure PROTO :DWORD, :DWORD, :DWORD, :DWORD
ShowTab PROTO :DWORD,:DWORD

    str$ MACRO DDvalue
      LOCAL rvstring
      .data
        rvstring db 20 dup (0)
        align 4
      .code

PUSH  offset rvstring
PUSH  DDvalue
CALL  dwtoa

      EXITM <ADDR rvstring>
    ENDM


.Const
BTN_ONE         equ 101
IDC_EDIT        equ 102
BTN_TWO         equ 103


Unknown STRUCT
QueryInterface     DWORD ?
AddRef             DWORD ?
Release            DWORD ?
Unknown ends

ITaskbarList STRUCT
IUnknown Unknown <>

HrInit DWORD ?
AddTab DWORD ?
DeleteTab DWORD ?
ActivateTab DWORD ?
SetActiveAlt DWORD ?
ITaskbarList ends

.const
sCLSID_TaskbarList textequ <{056fdf344H, 0fd6dH, 011D0H,\
{095H, 08ah, 000H, 060H, 097H, 0c9H, 0a0H, 090H}}>

sIID_ITaskbarList textequ <{056FDF342H, 0FD6DH, 011D0H,\
{095H, 08AH, 000H, 060H, 097H, 0C9H, 0A0H, 090H}}>

.Data

szDlg       db  "DLG", 0
szTest      db  "TEST", 0

CLSID_ITaskbarList      GUID        sCLSID_TaskbarList
IID_ITaskbarList        GUID        sIID_ITaskbarList


.Data?
hInst      HINSTANCE ?

.Code                                 
Start:           

invoke GetModuleHandle, NULL
mov hInst, eax
invoke DialogBoxParam, hInst, addr szDlg, 0, addr DlgProcedure, 0


invoke CoInitialize,NULL        ;    !!!

;invoke InitCommonControls
;invoke CoUninitialize           ;    !!!

invoke ExitProcess, NULL

; ######################################################## 
; ######################################################## 

DlgProcedure Proc uses esi edi hDlg:DWORD,uMsg:DWORD,
                                wParam:DWORD,lParam:DWORD
.if uMsg==WM_INITDIALOG
; invoke GetWindowRect, hDlg, addr rect
.elseif uMsg==WM_CLOSE
xor eax, eax
invoke EndDialog, hDlg, NULL
.elseif uMsg==WM_COMMAND
.if wParam!=0
mov eax, wParam
mov edx, wParam
shr edx, 16

            .if dx==BN_CLICKED

            .if ax==BTN_ONE

PUSH  0                         ;;;  H I D E      !!!
PUSH  hDlg
CALL  ShowTab

    .endif
            .if ax==BTN_TWO

PUSH  1                         ;;;  S H O W      !!!
PUSH  hDlg
CALL  ShowTab

    invoke MessageBox, hDlg, addr szTest, 0, 0

.endif
.endif
.endif
.else
mov eax, FALSE
ret
.endif
mov eax,TRUE
ret
DlgProcedure EndP

; ######################################################## 
; ######################################################## 

ShowTab proc hWnd:DWORD,fShow:DWORD
LOCAL ptb :DWORD

invoke CoCreateInstance,ADDR CLSID_ITaskbarList,NULL,CLSCTX_INPROC_SERVER,\
ADDR IID_ITaskbarList,ADDR ptb


;    PUSH  ptb                           ;  ADDR ptb     
;    PUSH  offset IID_ITaskbarList       ;  GUID
;    PUSH  1                             ;  CLSCTX_INPROC_SERVER
;    PUSH  0                             ;  NULL
;    PUSH  offset CLSID_ITaskbarList     ;  GUID
;    CALL  CoCreateInstance


; .........................................
.IF eax != S_OK
mov eax,-1
ret
.endif

push ptb
mov edi,ptb
mov edi,[edi]
call [edi].ITaskbarList.HrInit
; .........................................
; .........................................
.IF eax != S_OK
push ptb
call [edi].ITaskbarList.IUnknown.Release
mov eax,-1
ret
.endif

push hWnd        ; ...............  how is this possible
push ptb         ; ...............  between .endif - .IF
; .........................................
.IF fShow
call [edi].ITaskbarList.AddTab

.ELSE
call [edi].ITaskbarList.DeleteTab

.ENDIF
; .........................................

.IF eax != S_OK
push ptb
call [edi].ITaskbarList.IUnknown.Release
mov eax,-1
ret
.endif

push ptb
call [edi].ITaskbarList.IUnknown.Release

xor eax,eax

ret
ShowTab endp


End Start




[attachment deleted by admin]

donkey

Quote from: ic2 on December 15, 2007, 03:57:26 AM
Thanks donkey

I was hoping that you would have the time to help.  I was seriously at the border of switching, but to switch just because of one block of fancy code would have been crazy..

Not a problem, I had written a MASM translation some time ago for some-one and just had to dig through some archives and make a simple change.

QuoteThere really should be a entire tute for your Taskbar example, or more comments.  I know it was just a example to help someone but that will be a great start for me and others because it does a lot of little things that can be explain for GoAsm.  It made me more wise about GoAsm but I'm not ready to switch yet..

Well, I didn't bother to comment the code much as I found it very straight forward and easy to follow, it was very simple COM and I never expected that it would need much in the way of comments. I don't really have the time to make any tutorials these days, mostly I just take a day and translate a PSDK example once in a while and work on my header project but I don't do much original programming anymore. But my main interest lies in COM and COM related coding, though my interest tends to be quite capricious and changes with the weather.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ic2

QuoteBut my main interest lies in COM and COM related coding,

I know nothing much about COM ... All I want to do is hide a taskbar icon for a full functioning window... Now you got me wondering...

What's so interesting about COM, what does it do and why would one want to learn it ?   What is the best programming tool to use, sites to see... does OOP has anything to do with it..  Where can I read about it ASM related.   Also once the MASM example above get to working would that be enough for someone like me  to get a full understanding of basic COM if I debug, test and play with for a while ...It has been boring around here lately, doing the same stuff over and over again..  Sorry about the many extra questions.  I'll do some searchng right now...

ic2

Quote[t has been boring around here lately, doing the same stuff over and over again.. 

I just woke up and re-read this and realize it could easily be taken the wrong way... Around here means,  my personal surroundings and old-fashioned programming habits ...  BTW: I could not find much about COM and ASM on the net

donkey

COM is Component Object Model, and is essentially object oriented programming. There are many features of Windows that can only be accessed by using the COM interface they expose or by providing a COM server for them to call. For example the shell is largely accessible through COM, though many of the interfaces are wrapped in shlwapi they are natively COM. To correctly modify the desktop wallpaper or find the target / create a shortcut you should be using COM interfaces exposed by the shell, similarly to add to the explorer context menu you must write a server application that exposes IShellExt. Without being able to use the COM interfaces much of Windows is closed to you. COM can be frustrating as the levels of indirection can be confusing but once you understand a few basic principles and write a couple of simple macros it can be very rewarding.

No, there is not alot of COM and ASM information around, Ernie wrote some excellent examples that are distributed with MASM32.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ic2

I founded the other threads about ItaskbarList.asm
QuoteIt's not so bad, I don't use any of the COM preprocessors or macros so they could be a lot worse :grin:

You are a Genius...

Than I read into the Win32 Help Files
QuoteBecause CreateLink calls the CoCreateInstance function, it is assumed that the CoInitialize function has already been called.

So I placed this at start of ShowTab proc
invoke CoInitialize,NULL

Then I invoke CoUninitialize at the end of each call to the ShowTab proc just incase it fail for some reason.  This can be placed more correctly and only once..

Otther than that it works perfectly.

Thank You Very Much donkey for making this and a WHOLE lot more even more clearer.  Now we got a nice road map to COM... Thanks again

Attached Is a working copy -- ItaskbarList for MASM Final


[attachment deleted by admin]

donkey

Quote from: ic2 on December 16, 2007, 01:10:01 AMThen I invoke CoUninitialize at the end of each call to the ShowTab proc just incase it fail for some reason.  This can be placed more correctly and only once..

Hi ic2,

You should only call CoInitialize once in your application, I usually call it at the beginning of an application usually the second API call after GetModuleHandle and call CoUninitialize just before ExitProcess. There is no need to call it repeatedly in a procedure, even a library procedure just make sure you document that the procedure requires COM to be initialized. However the exception to this rule is when you have multiple threads, in that case you should really be using CoInitializeEx and tracking the return value to make sure that there are balanced CoInitializeEx / CoUninitialize calls.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable