Screen Positioning of a Dialogue Box !

G

Guest

Hi all,

Is it possible to have an XL builtin Dialogue Box ( For Ex ' Format Cells ')
displayed at the Bottom Right of the Screen instead of the Center ?

Jaafar.
Regards.
 
K

keepITcool

Hi Jaafar :)

it is possible, but .. there we go again.. only with api's

michel pierron has published a few examples for msgbox positioning that
you may want to adapt to your dialog situation.

and ofcourse you;ll need to add some code
to read the screensize,dialogsize and compute the new x,y of the dialog
iso hardcoding it like in next example:

michel is apt to replace the constants with numbers..
making it a bit harder to see what he does :)

he SETS the hook with &H5,
read that as WH_CBT (window hook computer based training)

his WinProc reacts to lMsg=5
read that as HCBT_ACTIVATE the hooked window is being Activated..

he moves the window with &H15
read that as SWP_NOSIZE OR SWP_NOZORDER OR SWP_NOACTIVATE


Private Declare Function UnhookWindowsHookEx Lib "user32" _
(ByVal hHook As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias _
"SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long _
, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long _
, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long _
, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private lgHook As Long

Sub Positionned_MsgBox()
lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, 0, GetCurrentThreadId)
MsgBox "Special msgbox (Left = 100 / Top = 100) !", 64
End Sub

Private Function WinProc(ByVal lMsg As Long, ByVal wParam As Long) As
Long
If lMsg = 5 Then
SetWindowPos wParam, 0, 100, 100, 0, 0, &H15
UnhookWindowsHookEx lgHook
End If
WinProc = False
End Function




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


RAFAAJ2000 wrote :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top