dialogs show up centered globally not locally.

Working on new editor enhancements?
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

dialogs show up centered globally not locally.

Post by superadnim »

Whenever a dialog pops up it's centered (ie. to the desktop) and not to the application itself (the IDE) this makes it very annoying for those using more than one monitor or split screen, it's just way too annoying.

Is there any way this could be fixed in the editor without having to resort for third-party solutions?

By dialog I mean syntax errors, etc. MessageBox()

:lol: should I bash the keyboard and give up?
:?
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Well, since its a standard MessageBox() you'll have to talk to Microsoft about changing that behavior.
quidquid Latine dictum sit altum videtur
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Post by superadnim »

I will pretend I didn't read that answer from the staff and will continue to wait for a proper answer. Passing the ball won't fix anything.

hint: HCBT_ACTIVATE

:lol: should I bash the keyboard and give up?
:?
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Messing with the positioning of standard dialogs is bad practice because then the dialog stops behaving the way people are used to. Its not about "passing the ball", its about complying to the rules set up by the OS to have a good overall user experience.

Anyway, have fun pretending and waiting... :roll:
quidquid Latine dictum sit altum videtur
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

superadnim wrote:I will pretend I didn't read that answer from the staff and will continue to wait for a proper answer.
Oh boy, the sensitivity of a butcher ... :roll:

It's actually pretty easy to fix that via API. On the other hand, you're such a dick I guess reading a little MSDN is what you really need. :wink:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

Fluid Byte wrote: ... the sensitivity of a butcher ...
I seen butchers crying... :twisted:
oh... and have a nice day.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

I took some code from user 'Eddy', below is my conversion of his code, it allows placement of any requester, AFAIK. It's Windows behaviour, by the way.

The code below is used in CodeCaddy, and seems to run fine...

Code: Select all

Procedure.i x_requesterposition_callback(window.i,message.i,wparam.i,lparam.i)               ; used for x_setrequesterposition()
  Protected result.i
  Global x_requesterposition_x.i, x_requesterposition_y.i, x_requesterposition_callback.i
  Global x_requesterposition_hook.i, x_requesterposition_window.i
  ;
  Select message
  Case #WM_DESTROY
    SetWindowLong_(window,#GWL_WNDPROC,x_requesterposition_callback)
  Case #WM_CREATE                            ; update requester position (special case for InputRequester)
    SetWindowPos_(window,#HWND_TOPMOST,x_requesterposition_x,x_requesterposition_y,0,0,#SWP_NOSIZE|#SWP_NOACTIVATE)
  Case #WM_INITDIALOG                        ; update requester position
    SetWindowPos_(Window,#HWND_TOPMOST,x_requesterposition_x,x_requesterposition_y,0,0,#SWP_NOSIZE|#SWP_NOACTIVATE)
    result = CallWindowProc_(x_requesterposition_callback,window,message,wparam,lparam)
    SetWindowPos_(Window,#HWND_TOPMOST,x_requesterposition_x,x_requesterposition_y,0,0,#SWP_NOSIZE|#SWP_NOACTIVATE)
    ProcedureReturn result
  EndSelect
  ProcedureReturn CallWindowProc_(x_requesterposition_callback,window,message,wparam,lparam)
EndProcedure

Procedure.i x_requesterposition_hook(idhook.i,wparam.i,lparam.i)                             ; used for x_setrequesterposition()
  Protected *x_requesterposition_cwp.CWPSTRUCT, windowclass.s, result.i, message.i, window.i
  Global x_requesterposition_x.i, x_requesterposition_y.i, x_requesterposition_callback.i
  Global x_requesterposition_hook.i, x_requesterposition_window.i
  ;
  *x_requesterposition_cwp.CWPSTRUCT = lParam
  message = *x_requesterposition_cwp\Message
  window = *x_requesterposition_cwp\hwnd
  ;
  ; special case for InputRequester
  ;
  windowClass = Space(255)
  GetClassName_(window,@windowclass,255)
  If LCase(windowclass)="inputrequester"
    message = #WM_INITDIALOG
  EndIf
  ;
  Select message
  Case #WM_INITDIALOG                            ; modify Requester callback
    x_requesterposition_callback = SetWindowLong_(window,#GWL_WNDPROC,@x_requesterposition_callback())
    result = CallNextHookEx_(x_requesterposition_hook, idHook,wParam,lParam)
    UnhookWindowsHookEx_(x_requesterposition_hook)
    x_requesterposition_hook = 0
  Default
    result = CallNextHookEx_(x_requesterposition_hook,idhook,wparam,lparam)
  EndSelect
  ;
  ProcedureReturn result
EndProcedure

Procedure x_setrequesterposition(x.i,y.i,windownr.i)                                         ; set x/y position of the next purebasic requester
  Global x_requesterposition_x.i, x_requesterposition_y.i, x_requesterposition_callback.i
  Global x_requesterposition_hook.i, x_requesterposition_window.i
  ;
  ; *** set x/y position of the next purebasic requester
  ;
  ; in:        x.l       - horizontal position
  ;            y.l       - vertical position
  ;            windownr  - number of parentwindow
  ; retval:    none
  ; out:       none
  ;
  ; from the purebasic forum, by eddy, dunno how it works, or even if it works properly... :-)
  ;
  ; note: only call this with a window open! otherwise it may cause all sorts of unpredictable errors, if neccessary open
  ;       an invisible window with x_requesterposition_window = OpenWindow(#PB_Any,x,y,0,0,#PB_Window_Invisible,"")
  ;
  x_requesterposition_x = x
  x_requesterposition_y = y
  x_requesterposition_window = windownr
  ;
  ; modify parent hook
  ;
  x_requesterposition_hook = SetWindowsHookEx_(#WH_CALLWNDPROC,@x_requesterposition_hook(),GetModuleHandle_(0),GetWindowThreadProcessId_(WindowID(x_requesterposition_window),0))
  ;
EndProcedure
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

What is this mess? :lol:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Afaik a Windows messagebox_() *will* position itself to the screen working on.
I can test tomorrow but imo it is related to mouse or parenthwnd.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

the default MessageBox_() is displayed Desktop centered. I tested it.
... and APPMODAL is the default Flag, so this doesn't change anything.

... but I wonder why it shouldn't display on the second desktop if the app is there...
oh... and have a nice day.
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

@superadnim: sounds like you're using (in nvidia terminology) "as one large horizontal desktop" (stretching the windows desktop across the two monitors)
So either switch to extended desktop mode (dualview in nvidia control panel language) or, if you have an nvidia card, go into nview properties and set the option "reposition dialog boxes on" to "move to application display" (I'm sure ati has a similar option)
If you don't like extended desktop mode; suck it up, or get something like ultramon for the "smart taskbar"
And answers like "I will pretend I didn't read that" are pretty childish. Especially when you have options like this
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

I have just tested and Windows messagebox (messagerequester) does follow the main window's monitor.

But i believe the orginal question was related to the ide and not the msgbox.
Post Reply