VBA - Can't get sendmessage + WM_CLOSE to work
Posted on 2006-05-17
i've got the little problem that sometimes the property window appears in my access database when i don't want it. this happens very rarely but it's anoying.
I was thinking that i could use the sendmessage api to close the dialog in question. I already know the classname of the dialog it's : " OArgDlg" so i do the following :
Const WM_CLOSE = &H10
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
thehwnd = FindWindow("OArgDlg", vbNullString)
Debug.Print thehwnd '(to see if it actually found the window and it does)
SendMessage thehwnd, WM_QUIT, 0, 0&
and it does not work even doh it finds the window so it's something with the sendmessage that's not working for the sake of testing i saw if it worked with internet explorer when the page was google (thehwnd = FindWindow(vbNullString, "Google - Microsoft Internet Explorer")) again it found the window (thehwnd > 0) but the send message did not work.
I tried postmessage as well but that didn't work either. I also tried other window messages like WM_Hide etc but nothing seems to happen so i think i have something wrong with either my sendmessage api declaration or the sendmessage command itself.
anyone any idea how to get sendmessage working in ms access ?