• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2245
  • Last Modified:

VBA - Can't get sendmessage + WM_CLOSE to work

Hi,

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 ?
0
joyrider
Asked:
joyrider
  • 2
  • 2
1 Solution
 
Jonathan KellyCommented:
If your using Access 2000 you can set the Allow Design Changes Property of the form to 'Design View Only'
This will stop the property dialog from appearing when the form is in Form View.

0
 
harfangCommented:
Hello joyrider

The property sheet for forms and controls appears when the form is not in design view? If that is the problem, open each form in turn and set "Allow Design changes: Design View Only", which should be the default anyway...

This being said, you sample works with "SendMessage thehwnd, 16&,0&,0&". Maybe the wrong constant?

Cheers!
(°v°)
0
 
flavoCommented:
Why not just disable them all the together from the users view:

Tools -> Option -> StartUp -> And untick the checkboxes.

To open the database so you can see them, hold down the shift key when opening it

Dave
0
 
flavoCommented:
woow.. I was on the phone and didn't refresh.
0
 
harfangCommented:
There is also: "RunCommand acCmdProperties", but it's a toggle.
(°v°)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now