Is it possible to show MessageDialog at a specified location?

Hello,

Is it possible to show MessageDialog and msgbox at a specified location, say top = y, Left = x?

Thanks.

Lennox

I know how to move the front window in Windows through declares. I have been using that to center the Print dialog.

The same is most probably possible in OS X.

That said, how difficult would it be to design a modal window with the same attributes as dialog, so you can set its position the exact way you want ?

Hi Michel.

I thought as much, (No it’s not possible).

Could you share your Windows declares with me and the Forum?

What font does Mac use in their message boxes?

Thanks.

Lennox

…and reuse over and over again going forward.

That’s not difficult.

Could you share your Windows declares with me and the Forum?

What font does Mac use in their message boxes?

Thanks.

Lennox

Use what Xojo calls “System” as it’s different for different systems.
Lucida Grande for <= 10.9
Helvetica Neue for 10.10
and Apple made their own font, which I think they’re using for the next one to unify OSX, iOS, and Watch

Thanks Tim
Lennox

[quote=198656:@Lennox Jacob](No it’s not possible).

[/quote]

Just curious why …

[quote=198656:@Lennox Jacob]Could you share your Windows declares with me and the Forum?
[/quote]

I am not on Windows at this moment. The code is based on SetWindowPos you will find in WFS.

See https://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx

Hi Michel.

I have a window in which the user has to complete several fields.

It has a Save and a Close Pushbutton. If all the fields are not filled in a message dialog box appears indicating that “x” fields were not filled in.
The message dialog box has two pushbuttons, one to proceed, “OK”, and one to go back, “Thanks Please go back”.

When the message dialog appears the box appears some distance away from the Pushbuttons on the main window and I prefer it to be much closer.

This screenshot - a moveable modal window that I created - shows it the way I like it.
https://www.mediafire.com/?ncz2cudrfh4o47g

Lennox

[quote=198700:@Lennox Jacob]This screenshot - a moveable modal window that I created - shows it the way I like it.
https://www.mediafire.com/?ncz2cudrfh4o47g [/quote]

It is extremely simple to do with a modal window. I have done that in one of my projects to be able to have a different icon.

Hi Michel,

Yes, It is extremely simple to do with a modal window.
The screenshot is the moveable modal window I created on Mac.
But I do not want to use that window on Mac.

If I can use your suggestion on PC using the built-in messagedialog with SetWindowPos (w as Window, x as Integer, y as Integer), I tried…

Dim dMessageDialog as New MessageDialog //declare the MessageDialog object
'dMessageDialog.Top = 500
'dMessageDialog.Left = 300
#if TargetWin32 then SetWindowPos (dMessageDialog, 300, 500)

Dim bMessageDialogButton as New MessageDialogButton //for handling the result

dMessageDialog.icon= 1 //display warning icon
dMessageDialog.ActionButton.Caption= “&OK”
dMessageDialog.CancelButton.Caption= “&Cancel”
dMessageDialog.CancelButton.Visible = False
dMessageDialog.AlternateActionButton.Visible = True
dMessageDialog.AlternateActionButton.Caption= “&Thanks! Please go back”
dMessageDialog.Message = “Incomplete record…”
dMessageDialog.Explanation = “Some expalanation…”

bMessageDialogButton = dMessageDialog.ShowModal //display the dialog
Select Case bMessageDialogButton //determine which button was pressed.
Case dMessageDialog.ActionButton //user clicked OK
//Proceed with the “Close” and do nothing else
Case dMessageDialog.AlternateActionButton //user clicked OK
Self.Hide
Window2.ShowModal

'Return

End select

How do I use SetWindowPos (w as Window, x as Integer, y as Integer)

Thanks.

Lennox

[quote=198732:@Lennox Jacob]The screenshot is the moveable modal window I created on Mac.
But I do not want to use that window on Mac.[/quote]

I do not understand.

[quote=198732:@Lennox Jacob]How do I use SetWindowPos (w as Window, x as Integer, y as Integer)
[/quote]

You need to build a declare function. What you did cannot work.

You can find the proper way to declare into SetWindowPos by loading Windows Functionality Suite and search for SetWindowPos. Then read the page I linked to at Msdn to know which parameters are needed by the method.

I will see what I can do tomorrow if I get enough time to work on PC.

Yet, I do not see why using a modal window to create a dialog is such an issue for you under Windows. I have done so numerous times, including lately to emulate the Metro UI. It is a valid way. Have you tried ?

Hi Michel

But I do not want to use that window on Mac should be But I do not want to use that window PC.

I have Windows Functionality Suite and I found SetWindowPos.
SetWindowPos is for a window not a messagedialog.

I have not tried creating a modal window to emulate the messagedialog as yet, I will try and see how it works.

Thanks.

Lennox

[quote=198738:@Lennox Jacob]Hi Michel

But I do not want to use that window on Mac should be But I do not want to use that window PC.

I have Windows Functionality Suite and I found SetWindowPos.
SetWindowPos is for a window not a messagedialog.

I have not tried creating a modal window to emulate the messagedialog as yet, I will try and see how it works.

Thanks.

Lennox[/quote]

Sigh. For Windows, any window is a window is a window. MsgBox, Printer Dialog, Message Dialog. SetWindowPos works for any kind.

I still think your best bet is to create your own MessageDialog window. It will be cross platform and allow you much more control.

OK Michel,

I am working on it now.
Thanks.

Lennox

Here is the code I use to center the Print dialog window. It picks the topmost window handle, and move it to the center of the screen. The same code can be used for any window.

See https://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx for the value of extra parameters in SetWindowPos

[code] Declare Function GetForegroundWindow Lib “User32” () as Integer
Declare Function SetWindowPos Lib “user32” (hwnd as Integer, hWndInstertAfter as Integer, _
Left as Integer, Top as Integer, cx as Integer, cy as Integer, flags as Integer) as Integer

dim rien as integer = setwindowpos(GetForegroundWindow, 0, (screen(0).width-460)/2,(screen(0).Height-418)/2,400,400,1)[/code]

Thanks Michel,

I got it to work with my customised modal window.

I will try your code above this evening, I am not on a PC at the moment.

Thanks again.

Lennox

[quote=198821:@Lennox Jacob]Thanks Michel,

I got it to work with my customised modal window.

I will try your code above this evening, I am not on a PC at the moment.[/quote]

The modal window is much better, it lets you customize the dialog any way you want, for instance changing the background color, font style, icon, button style. THat was what I did to have this kind of Metro style Messagebox in Windows :

I use the declare mainly to control where I display the Print dialog. It could be used also for exterior programs you launch, since it works on the topmost window regardless of it is your program or another.

Thanks Michel,

I tried the code, it works and I must argot is not as good as the customised window as you suggested.

Thanks again.

Lennox