News:

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

Hidden Window

Started by PeterRod, November 02, 2008, 04:07:18 PM

Previous topic - Next topic

PeterRod

This is my first attempt with MASM and a Window.
The app is still a console app but I want it to have a hidden/invisible window.
The only purpose for this hidden Window is to receive messages sent via SendMessage in another process.
How do I go about this?
I tried searching hidden windows in this forum but nothing really relevant came up.
If I could have an example or tutorial or some instructions.
Thanks in advance
PeterRod


Vortex

PeterRod,

To hide a window, you can move it to coordinates outside of the screen :

   .IF uMsg==WM_INITDIALOG

        invoke  SetWindowPos,hWnd,0,10000,10000,0,0,\
                SWP_NOZORDER or SWP_NOSIZE

[attachment deleted by admin]

donkey

Quote from: Vortex on November 02, 2008, 04:45:06 PM
PeterRod,

To hide a window, you can move it to coordinates outside of the screen :

   .IF uMsg==WM_INITDIALOG

        invoke  SetWindowPos,hWnd,0,10000,10000,0,0,\
                SWP_NOZORDER or SWP_NOSIZE


Doesn't quite hide it completely, still appears on the task bar, you can go the complicated route of removing it from the taskbar, I posted some code once to do that or just use a message only window, it is meant for this type of situation.
"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

Vortex

Quote from: donkey on November 03, 2008, 12:57:32 AM
Doesn't quite hide it completely, still appears on the task bar, you can go the complicated route of removing it from the taskbar, I posted some code once to do that or just use a message only window, it is meant for this type of situation.

Edgar,

It's not advisable to remove the application from the task bar without knowing the exact intention of the thread starter.

PeterRod

Thanks all for the quick replies.
I am using the message-only type window.
Method:
After I define the properties of WNDCLASSEX (all NULL or zero except for ClassName , hInstance and WinProc address)
I register the class.
Then invoke CreateWindowEx (all NULL or zero except for ClassName,WindowName.hInstance and parent = HWND_MESSAGE)
Now I receive a handle to my message-only window(its name is MsgOnly)


Questions:
(1) Do I need a message loop for MsgOnly? I dont think so as it wont be responding to OS messages.
(2) Since the sole purpose of MsgOnly is to receive WM_COPYDATA messages will the following WinProc suffice:

WinProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD 
         mov eax,uMsg
         cmp eax,WM_COPYDATA
         je ProcessMsg
         invoke DefWindowProc, hWin, uMsg, wParam, lParam
         ret
ProcessMsg:   
         ;processing code goes here
         xor eax,eax
         ret
WinProc endp

or do I also have to respond to WM_DESTROY  or other messages.

(3) presently the code is in a console app but will shortly become a dll.
     Do I have to
           invoke DestroyWindow, hMsgOnly
          invoke UnregisterClassA, offset ClassName, offset hModule
before unloading the dll.

This is my first experience with a window of any type in MASM so I would like to know if I covered all the bases.

Thanks again.

PeterRod


kero

Vortex
> It's not advisable to remove the application from the task bar without knowing the exact intention of the thread starter.

Why "without"? - "Hidden Window".

[offtop] SetWindowPos can't hide just created modal DialogBox.  But we have some other ways for it. [/offtop]

Farabi

If the Thread starter want to hide it application from Windows taskbar, thats very dangerous. Im getting tired handling with virus without anti-virus.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"