I have created a plain dialog and it is soon expected to be working as a local search engine on my hard drive. What it has to do is to be hidden when it is first started so I can let it be shown on the screen with a hot key. The problem is that the dialog wouldn't get hidden. I have tried invoking ShowWindow() at the window message WM_INITDIALOG but it didn't work.

I also tried doing the same at WM_SHOWWINDOW and it didn't work either. I removed the WS_VISIBLE bit in the dialog style and it is still shown. I removed that bit manually at WM_INITDIALOG with GetWindowLong and SetWindowLong and there it is, still shown. What can I do to hide this dialog from hell? Can anybody help, please?
Posted on 2007-01-31 01:06:22 by XCHG
Seems kinda impossible xD Paste the code ^^
Posted on 2007-01-31 10:14:56 by ti_mo_n
Use the CreateDialogParam api to create the dialogbox.
Don't have the VS_VISIBLE style in the resource file that defines the dialogbox.
Use SW_HIDE with the ShowWindow api.

To demonstrate an invisible dialogbox use Iczelion's tutorial 10-1
which creates a dialogbox using CreateDialogParam with a resource file.
  invoke CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL

Remove the VS_VISIBLE style in the resource file,
change the ShowWindow parameter SW_SHOWNORMAL to SW_HIDE
with both these modifications it will create an invisible dialogbox.
  invoke ShowWindow,hDlg,SW_HIDE
Posted on 2007-01-31 19:32:04 by dsouza123
I removed everything from the dialog box in a test project and the new dialog doesn't hide either. I am using DialogBoxParam() to initialize the dialog and not the CreateDialogParam() because the latter doesn't work for me.

The code for the dialog is here:

  .386
  .MODEL FLAT, STDCALL
  OPTION CASEMAP:NONE

  INCLUDE \MASM32\INCLUDE\windows.inc
  INCLUDE \MASM32\INCLUDE\user32.inc
  INCLUDE \MASM32\INCLUDE\kernel32.inc
  INCLUDE \MASM32\INCLUDE\Comctl32.inc
 
  INCLUDELIB \MASM32\lib\user32.lib
  INCLUDELIB \MASM32\lib\kernel32.lib
  INCLUDELIB \MASM32\lib\Comctl32.lib
 
  .DATA
  .CONST
    ALIGN 04
  .CODE
ALIGN 04
;-------------------------------------------
WndProc PROC hWin:HWND, Msg:UINT, wParam:WPARAM, lParam:LPARAM 
  MOV    EAX , Msg

  EVEN
  @@:
    CMP    EAX , WM_CLOSE
    JNE    @F
    INVOKE  EndDialog, hWin, 0b
    RET

 
  EVEN
  @@:
    CMP    EAX , WM_INITDIALOG
    JNE    @F
    INVOKE  ShowWindow, hWin, SW_HIDE
    INVOKE  GetWindowLong, hWin, GWL_STYLE
    AND    EAX , (NOT WS_VISIBLE)
    INVOKE  SetWindowLong, hWin, GWL_STYLE, EAX
    RET

  @@: 
  @@__EP:
    XOR    EAX , EAX
  RET
WndProc ENDP
;-------------------------------------------
START:
  INVOKE  InitCommonControls
  INVOKE  GetModuleHandle, 0b
  INVOKE  DialogBoxParam, EAX, 1000, 0b, ADDR WndProc, 0b
  INVOKE  ExitProcess, 0b
END START



The dialog's resource script is:

#define IDD_DLG1 1000
#define IDC_SBR1 1014
IDD_DLG1 DIALOGEX 6,6,196,132
CAPTION "Search and replace"
FONT 8,"Verdana",400,0
STYLE 0x00CA0000
EXSTYLE 0x00000000
BEGIN
  CONTROL "Ready and awaiting commands",IDC_SBR1,"msctls_statusbar32",
          0x50000003,0,113,196,12,0x00000000
END
Posted on 2007-01-31 20:30:59 by XCHG
>> What it has to do is to be hidden when it is first started
> I am using DialogBoxParam() to initialize the dialog and not the CreateDialogParam()

Just one of ways:


DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
  .if uMsg==WM_CLOSE
    invoke EndDialog,hWnd,0

  .elseif uMsg==WM_INITDIALOG
.data
_parent db "static",0
.data?
hwin dd ?
.code
    invoke CreateWindowEx,0,offset _parent,0,0,0,0,0,0,0,0,0,0
    mov hwin,eax
    invoke SetParent,hWnd,hwin
    invoke SetTimer,hWnd,1,100,0

  .elseif uMsg==WM_TIMER
    invoke GetKeyState,VK_CONTROL
    and ax,8000h
    .if ax!=0
      invoke KillTimer,hWnd,1
      invoke SetParent,hWnd,0
      invoke DestroyWindow,hwin
    .endif

  .else
    mov eax,FALSE
    ret
  .endif
  mov eax,TRUE
  ret
DlgProc endp

start:
  invoke GetModuleHandle,0
  invoke DialogBoxParam,eax,1000,0,offset DlgProc,0
  invoke ExitProcess,eax
  invoke InitCommonControls
end start
Posted on 2007-02-25 19:58:47 by kero