Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I tried using DestroyWindow to remotely destroy a password prompt dialog box that keeps popping-up every time I remotely open a particular PDF document. (It doesn't work!)
 
Before this I was also trying SendMessage with the WM_CLOSE value as shown below:
 

Public Const WM_CLOSE = &H10
 
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, _
         ByVal wParam As IntPtr, ByRef lParam As IntPtr) As IntPtr
 
    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, _
        ByVal wParam As Integer, ByRef lParam As IntPtr) As Integer
 
    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, _
        ByVal wParam As Integer, ByRef lParam As Integer) As Integer
 
    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, _
        ByVal wparam As Integer, ByVal lparam As System.Text.StringBuilder) As IntPtr
 
Dim dialog_title As String = "Password"
Dim hwnd As IntPtr = FindWindow(vbNullString, dialog_title)
SendMessage(hwnd, WM_CLOSE, 0, 0)
 

When I do this virtually nothing happens (nothing ever happens).
Upon keen observation I did notice that the cursor blinking in the password input field went off for about half-a-second then started blinking again; that's all.
 
Maybe I'm not using the SendMessage function right; I dunno. I've tried so many ways.
 
Can anyone see whats wrong with my code or suggest a "sure-fire" way that might work to get rid of the modal dialog.
 
Thanks.
Posted 1-Jun-10 11:45am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I looked at your solution and that's exactly what I would have tried. Two questions for you:
 
1. Have you used the debugger to look at the value of hwnd? You should make sure it's the right window.
 
2. If on Vista or later, have you tried running this program as an admin?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Question - is the parent app recreating the dialog right away because no password was entered ?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Christian Graus says:
 
Question - is the parent app recreating the dialog right away because no password was entered ?

 

No. When I manually click any button on the password dialog, apart from the OK button, it closes and never re-appears unless the document is re-opened.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hans Dietrich says:
 
I looked at your solution and that's exactly what I would have tried. Two questions for you: 1. Have you used the debugger to look at the value of hwnd? You should make sure it's the right window. 2. If on Vista or later, have you tried running this program as an admin?

 

Yeah, the hwnd is a large +ve integer. And i don't have any other windows open or visible with the "Password" title.
 
Also, I am using Windows XP.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

You need to verify that you have the correct window handle. Use Spy++ to confirm.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Hans Dietrich says:
 
You need to verify that you have the correct window handle. Use Spy++ to confirm.
 

There seems to be two (2) window handles associated with the "Password" dialog box. One is static and is always 32770, while the other changes with each new instance of the dialog window. Invoking SendMessage on both handles yields the same result- nothing!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 410
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 264
3 BillWoodruff 235
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 28 Jun 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100