Does anybody know how to get the below windows API working in Xojo;
Declare Sub SetWindowPos Lib “User32” ( hwnd as Integer, after as Integer, x as Integer, y as Integer, _
width as Integer, height as Integer, flags as Integer )
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_NOTOPMOST = -2
SetWindowPos( self.handle, HWND_NOTOPMOST , 0, 0, me.Width , me.Height , SWP_NOMOVE )
Does anybody know how to get the below windows API working in Xojo;
Declare Sub SetWindowPos Lib “User32” ( hwnd as Integer, after as Integer, x as Integer, y as Integer, _
width as Integer, height as Integer, flags as Integer )
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_NOTOPMOST = -2
SetWindowPos( self.handle, HWND_NOTOPMOST , 0, 0, me.Width , me.Height , SWP_NOMOVE )
[/quote]
Yes I’m executing this code from the window open event. Before this method I have another method that hides the application icon from taskbar, tha’s all.
Looks like this declare works, but it is telling the window “set the height to the height and the width to the width…”
Notice, if you change the me.width to me.width+100, the window resizes.
To create a window that can’t be moved, try changing the frame to “Plain Box”. There will be no titlebar, but I can’t think of any other way to prevent moving that won’t cause all sorts of flashing/flickering…
According to msdn, this function returns a boolean, and you had set it up with no return value. I tested it, and it works fine to position the window. Not really necessary as you can do that in Xojo, but this does work :
Declare Function SetWindowPos Lib "User32" ( hwnd as Integer, after as Integer, x as Integer, y as Integer, _
width as Integer, height as Integer, flags as Integer ) as boolean
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_NOTOPMOST = -2
Const HWND_TOP = 0
dim nothing as boolean = SetWindowPos( self.handle, HWND_TOP , 0, 0, me.Width , me.Height , SWP_NOSIZE )
It involves placing a hook on the window messaging system and blocking the move messages. It should be possible to adapt it to Xojo declares, but it will be much more difficult than changing the window type.
Modal dialog seems better than plain box, as it keeps the menu, and you can always add a small red closing box in the upper right hand side.
I was just playing with a custom shape window and the idea came about : create a custom shape window with the picture of a normal window. Since the standard control bar is invisible, it becomes impossible to move such a window.
Try this. Grab WFS, which has some support for hooking into WndProc. Add WFS to a new project and insert a new Window (NonMovableWindow) specifying this interface for it: WndProcSubclassWFS
This adds the WndProc method to the window.
In the Open event handler of the Window, add this code:
WndProcHelpersWFS.Subclass( Self, self )
In the WndProc method (added when you selected the interface) add this code (translated from the StackOverflow link above):
[code]
// Part of the WndProcSubclassWFS interface.
Paul I suspected the solution might be in WFS but the documentation for it is so terse I usually go for msdn instead.
It took me a while to locate WndProcHelpersWFS.rbbas in
WFS-master\Windows Functionality Suite\UI Extras\Modules
and WndProcSubclassWFS.rbbas in
WFS-master\Windows Functionality Suite\UI Extras\Interfaces
Then I applied your advice and it works great. Thank you.