Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » center an SWT filedialog
center an SWT filedialog [message #452344] Thu, 17 March 2005 16:34 Go to next message
Eclipse UserFriend
Originally posted by: ps7.bolton.ac.uk

Hi,

I'm using 3.1M5. Can anyone confirm if there any way to center a file
dialog in the middle of the parent shell. (This always opens in the top
left of the parent)

FileDialog dlg = new FileDialog(shell, SWT.OPEN);



....I saw this message already posted and wanted to confirm that this is
correct & also appies to the filedialog....

Many thanks for your time...

Paul

------------------------------------

The platform decides where native message dialogs such as message boxes
should be placed.

"Mark McLaren" <noone@nowhere.com> wrote in message
news:cpa1c3$as4$1@www.eclipse.org...

>> What about placing a message box in the center of its parent shell? Is
>> there some reason this isn't done by default by SWT?
>>
>> Benjamin Pasero wrote:
>>
>
>>> > Wayne Miller wrote:
>>
>>>> >> How do you center an Application Window on the screen? I found

examples

>>>> >> of AWT but no SWT.
>>>> >>
>>>> >> Thanx...
>>>> >>
>>
>>> > See
Re: center an SWT filedialog [message #452347 is a reply to message #452344] Thu, 17 March 2005 17:22 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

"The platform decides where native message dialogs such as message boxes"
it's true, but on win32 there is a solution to add a hook function and on
WM_INITDIALOG message center the window. On other platform I don't know if
exists such a support, probably this is why the Eclipse team did'nt centered
the platform specific dialog boxes.

Regards,
Boby


"Paul Sharples" <ps7@bolton.ac.uk> wrote in message
news:d1cbjb$fil$1@www.eclipse.org...
> Hi,
>
> I'm using 3.1M5. Can anyone confirm if there any way to center a file
> dialog in the middle of the parent shell. (This always opens in the top
> left of the parent)
>
> FileDialog dlg = new FileDialog(shell, SWT.OPEN);
>
>
>
> ...I saw this message already posted and wanted to confirm that this is
> correct & also appies to the filedialog....
>
> Many thanks for your time...
>
> Paul
>
> ------------------------------------
>
> The platform decides where native message dialogs such as message boxes
> should be placed.
>
> "Mark McLaren" <noone@nowhere.com> wrote in message
> news:cpa1c3$as4$1@www.eclipse.org...
>
> >> What about placing a message box in the center of its parent shell?
Is
> >> there some reason this isn't done by default by SWT?
> >>
> >> Benjamin Pasero wrote:
> >>
> >
> >>> > Wayne Miller wrote:
> >>
> >>>> >> How do you center an Application Window on the screen? I found
>
> examples
>
> >>>> >> of AWT but no SWT.
> >>>> >>
> >>>> >> Thanx...
> >>>> >>
> >>
> >>> > See
>
Re: center an SWT filedialog [message #452366 is a reply to message #452347] Fri, 18 March 2005 09:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ps7.bolton.ac.uk

Hi Robert,

Thanks for the reply. I've not come across this before - is it possible
for you to give me some pointers on how to do this on win32?

thanks again

Paul

Robert Bacs wrote:
> Hi,
>
> "The platform decides where native message dialogs such as message boxes"
> it's true, but on win32 there is a solution to add a hook function and on
> WM_INITDIALOG message center the window. On other platform I don't know if
> exists such a support, probably this is why the Eclipse team did'nt centered
> the platform specific dialog boxes.
>
> Regards,
> Boby
>
>
> "Paul Sharples" <ps7@bolton.ac.uk> wrote in message
> news:d1cbjb$fil$1@www.eclipse.org...
>
>>Hi,
>>
>>I'm using 3.1M5. Can anyone confirm if there any way to center a file
>>dialog in the middle of the parent shell. (This always opens in the top
>>left of the parent)
>>
>>FileDialog dlg = new FileDialog(shell, SWT.OPEN);
>>
>>
>>
>>...I saw this message already posted and wanted to confirm that this is
>>correct & also appies to the filedialog....
>>
>>Many thanks for your time...
>>
>>Paul
>>
>>------------------------------------
>>
>>The platform decides where native message dialogs such as message boxes
>>should be placed.
>>
>>"Mark McLaren" <noone@nowhere.com> wrote in message
>>news:cpa1c3$as4$1@www.eclipse.org...
>>
>> >> What about placing a message box in the center of its parent shell?
>
> Is
>
>> >> there some reason this isn't done by default by SWT?
>> >>
>> >> Benjamin Pasero wrote:
>> >>
>> >
>> >>> > Wayne Miller wrote:
>> >>
>> >>>> >> How do you center an Application Window on the screen? I found
>>
>>examples
>>
>> >>>> >> of AWT but no SWT.
>> >>>> >>
>> >>>> >> Thanx...
>> >>>> >>
>> >>
>> >>> > See
>>
>
>
>
Re: center an SWT filedialog [message #452372 is a reply to message #452366] Fri, 18 March 2005 13:59 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

I will assume that you want only the file open dialog for the save dialog
you need to do the same. You need to make the following changes in os.c file
from the sources of SWT dll.
- locate in os.c file GetOpenFileNameW or GetOpenFileNameA depending if
it's unicode platform or not
- befor the following line rc =
(jboolean)GetOpenFileNameW((LPOPENFILENAMEW)lparg0); you need to set in the
Flags member OFN_ENABLEHOOK and OFN_EXPLORER flags, also you need to set the
lpfnHook member to OFNHookProc() this will be your hook procedure.
- declare your hook procedure before this JNI function like this:
UINT_PTR CALLBACK OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM
lParam){
- in this hook procedure you need to process the WM_INITDIALOG message
and center the messagebox
- build the new DLL and use this one

I made those changes to make some tests, but there is a problem with this
hooking thing, form MSDN:
"For compatibility reasons, the Places Bar is hidden if Flags is set to
OFN_ENABLEHOOK and lStructSize is OPENFILENAME_SIZE_VERSION_400". I did'nt
find yet how to get rid of this.

Regards,
Boby

"Paul Sharples" <ps7@bolton.ac.uk> wrote in message
news:d1e6at$frc$1@www.eclipse.org...
> Hi Robert,
>
> Thanks for the reply. I've not come across this before - is it possible
> for you to give me some pointers on how to do this on win32?
>
> thanks again
>
> Paul
>
> Robert Bacs wrote:
> > Hi,
> >
> > "The platform decides where native message dialogs such as message
boxes"
> > it's true, but on win32 there is a solution to add a hook function and
on
> > WM_INITDIALOG message center the window. On other platform I don't know
if
> > exists such a support, probably this is why the Eclipse team did'nt
centered
> > the platform specific dialog boxes.
> >
> > Regards,
> > Boby
> >
> >
> > "Paul Sharples" <ps7@bolton.ac.uk> wrote in message
> > news:d1cbjb$fil$1@www.eclipse.org...
> >
> >>Hi,
> >>
> >>I'm using 3.1M5. Can anyone confirm if there any way to center a file
> >>dialog in the middle of the parent shell. (This always opens in the top
> >>left of the parent)
> >>
> >>FileDialog dlg = new FileDialog(shell, SWT.OPEN);
> >>
> >>
> >>
> >>...I saw this message already posted and wanted to confirm that this is
> >>correct & also appies to the filedialog....
> >>
> >>Many thanks for your time...
> >>
> >>Paul
> >>
> >>------------------------------------
> >>
> >>The platform decides where native message dialogs such as message boxes
> >>should be placed.
> >>
> >>"Mark McLaren" <noone@nowhere.com> wrote in message
> >>news:cpa1c3$as4$1@www.eclipse.org...
> >>
> >> >> What about placing a message box in the center of its parent shell?
> >
> > Is
> >
> >> >> there some reason this isn't done by default by SWT?
> >> >>
> >> >> Benjamin Pasero wrote:
> >> >>
> >> >
> >> >>> > Wayne Miller wrote:
> >> >>
> >> >>>> >> How do you center an Application Window on the screen? I found
> >>
> >>examples
> >>
> >> >>>> >> of AWT but no SWT.
> >> >>>> >>
> >> >>>> >> Thanx...
> >> >>>> >>
> >> >>
> >> >>> > See
> >>
> >
> >
> >
>
Re: center an SWT filedialog [message #452375 is a reply to message #452372] Fri, 18 March 2005 14:59 Go to previous message
Eclipse UserFriend
Originally posted by: ps7.bolton.ac.uk

Robert,

Thanks for the reply and all of your help.

Paul

Robert Bacs wrote:

> Hi,
>
> I will assume that you want only the file open dialog for the save dialog
> you need to do the same. You need to make the following changes in os.c file
> from the sources of SWT dll.
> - locate in os.c file GetOpenFileNameW or GetOpenFileNameA depending if
> it's unicode platform or not
> - befor the following line rc =
> (jboolean)GetOpenFileNameW((LPOPENFILENAMEW)lparg0); you need to set in the
> Flags member OFN_ENABLEHOOK and OFN_EXPLORER flags, also you need to set the
> lpfnHook member to OFNHookProc() this will be your hook procedure.
> - declare your hook procedure before this JNI function like this:
> UINT_PTR CALLBACK OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM
> lParam){
> - in this hook procedure you need to process the WM_INITDIALOG message
> and center the messagebox
> - build the new DLL and use this one
>
> I made those changes to make some tests, but there is a problem with this
> hooking thing, form MSDN:
> "For compatibility reasons, the Places Bar is hidden if Flags is set to
> OFN_ENABLEHOOK and lStructSize is OPENFILENAME_SIZE_VERSION_400". I did'nt
> find yet how to get rid of this.
>
> Regards,
> Boby
>
> "Paul Sharples" <ps7@bolton.ac.uk> wrote in message
> news:d1e6at$frc$1@www.eclipse.org...
>
>>Hi Robert,
>>
>>Thanks for the reply. I've not come across this before - is it possible
>>for you to give me some pointers on how to do this on win32?
>>
>>thanks again
>>
>>Paul
>>
>>Robert Bacs wrote:
>>
>>>Hi,
>>>
>>> "The platform decides where native message dialogs such as message
>
> boxes"
>
>>>it's true, but on win32 there is a solution to add a hook function and
>
> on
>
>>>WM_INITDIALOG message center the window. On other platform I don't know
>
> if
>
>>>exists such a support, probably this is why the Eclipse team did'nt
>
> centered
>
>>>the platform specific dialog boxes.
>>>
>>>Regards,
>>>Boby
>>>
>>>
>>>"Paul Sharples" <ps7@bolton.ac.uk> wrote in message
>>>news:d1cbjb$fil$1@www.eclipse.org...
>>>
>>>
>>>>Hi,
>>>>
>>>>I'm using 3.1M5. Can anyone confirm if there any way to center a file
>>>>dialog in the middle of the parent shell. (This always opens in the top
>>>>left of the parent)
>>>>
>>>>FileDialog dlg = new FileDialog(shell, SWT.OPEN);
>>>>
>>>>
>>>>
>>>>...I saw this message already posted and wanted to confirm that this is
>>>>correct & also appies to the filedialog....
>>>>
>>>>Many thanks for your time...
>>>>
>>>>Paul
>>>>
>>>>------------------------------------
>>>>
>>>>The platform decides where native message dialogs such as message boxes
>>>>should be placed.
>>>>
>>>>"Mark McLaren" <noone@nowhere.com> wrote in message
>>>>news:cpa1c3$as4$1@www.eclipse.org...
>>>>
>>>>
>>>>>>What about placing a message box in the center of its parent shell?
>>>
>>>Is
>>>
>>>
>>>>>>there some reason this isn't done by default by SWT?
>>>>>>
>>>>>>Benjamin Pasero wrote:
>>>>>>
>>>>>
>>>>>>>>Wayne Miller wrote:
>>>>>>
>>>>>>>>>>How do you center an Application Window on the screen? I found
>>>>
>>>>examples
>>>>
>>>>
>>>>>>>>>>of AWT but no SWT.
>>>>>>>>>>
>>>>>>>>>>Thanx...
>>>>>>>>>>
>>>>>>
>>>>>>>>See
>>>>
>>>
>>>
>
>
Previous Topic:Problem with adding more than two pages to a Wizard
Next Topic:Q: SWT/JFace utilities project
Goto Forum:
  


Current Time: Sun Nov 17 05:01:44 GMT 2019

Powered by FUDForum. Page generated in 0.01956 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top