Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Screen Positioning of a Dialogue Box !

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Screen Positioning of a Dialogue Box !


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 :

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Screen Positioning of a Dialogue Box !

Thanks KeepItCool,

I'll have a look into this and get back to you.

Jaafar.
Regards.



"keepITcool" wrote:


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 :

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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink Destination Positioning On Screen Mike Rice Excel Worksheet Functions 0 November 8th 06 05:27 PM
print box opens in right screen of dual screen setup why gerrys Excel Discussion (Misc queries) 1 June 30th 06 06:47 PM
Positioning a cell at the top left of the screen Ben Excel Programming 4 May 14th 05 01:22 PM
How to copy data from excel to power point screen by screen? luvgreen[_3_] Excel Programming 0 April 9th 04 03:51 PM
Positioning Data / Form dialogue box Mark Flaxman[_2_] Excel Programming 3 February 6th 04 10:33 PM


All times are GMT +1. The time now is 03:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"