Postmessage API question

BrettM

just a pert, "ex" to come
Local time
Today, 21:14
Joined
Apr 30, 2008
Messages
134
Hi all,

Does anyone know of a way to set the size of the response window targeted by the PostMessage API?

...or better still, route the page it comes up with (in my case a page from my help.chm file) into the HTMLHelp program itself?

In other words, I have managed to replicate the "What's This" button as a standard button within a form however it displays it's info in a window that does not have the standard HTMLHelp controls in it.

I would either like to force the window host or at least force the window size.

Regards Brett

PS. If you want the "What's This" button simulator then let me know and I will send it to you.
 
If you're simply looking to set the window size and position you can use the following function:

Code:
[SIZE=2]Private Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _[/SIZE]
[SIZE=2]ByVal nHeight As Long, ByVal bRepaint As Long) As Long[/SIZE]

With that code you can set any window's size and x/y position that you have the hwnd for. I hope this helps.
 
I am using the PostMessage API function to display my help page. This acts independantly to Access and as such nothing I do to try and obtain the help page's hwnd seems to work.

I have tried GetActiveWindow etc however in every case it effects the calling Access window and not the help window.

Any suggestions on getting the hwnd of the window created with PostMessage?

Regards Brett
 
You can use the FindWindow Function in the user32 library. This retrieves a window's hwnd based on the text in its title bar. Here is the declaration:

Code:
Declare Function FindWindow Lib "user32" (ByVal lpszClassName As String, ByVal lpszWindow As String) As Long

For the class parameter use vbNullString and the other parameter is for entering the text you expect to be present in the title bar of the window you wish to target. This function returns a Long integer, which is the hwnd of the window if it finds the text, and a zero if it does not.
 
Thanks for that.

Like I said however, I am using the PostMessage function to emulate the "What's This" button and it is working perfectly. In such, the following code is called from a toolbar and the cursor changes to an arrowed question. You then click on an object in the current form and the appropriate help window appears.

Code:
Function WhatsThisMode(lngH As Long)
If PostMessage(lngH, WM_SYSCOMMAND, SC_CONTEXTHELP, 0) = 0 Then
    MsgBox "There has been an Error. Contact DTP. Refer to Support information as to how."
End If
End Function

The issue is that code is not suspended until the user clicks somewhere so any following code is active and effects the base form.

I am looking for a way to preset the size and location of the help window that pops up once the user clicks on something. It's info is stored somewhere. If you change it once, it will always reappear in the new position - even after restarting Windows.

It would be even better to be able to intercept the call and force it into the standard menued help screen though this is not a priority.

Regards Brett
 
Last edited:

Users who are viewing this thread

Back
Top Bottom