Api SetWindowPos and style

BlitzPlus Forums/BlitzPlus Programming/Api SetWindowPos and style

Richard Betson(Posted 2004) [#1]
I'm having problems getting windows api SetWindowPos() to work with windows that have a menu and status bar (ex: CreateWindow("Test",0,400,400,100,0,7+8) ). I have included this in the user32.decal , SetWindowPos% (hwnd%, hWndInsertAfter%, x%, y%, cx%, cy%, wFlags%) : "SetWindowPos" .

Any ideas?

L8r,


Eikon(Posted 2004) [#2]
Never had an issue with menu'd windows that I know of. Here's the code I used to make a window fullscreen, see if it works for you.

;.lib "user32.dll"
;SetWindowPos%(hWnd%,hAfter%,x%,y%,cx%,cy%,flags%)

SetWindowPos QueryObject(Window(0), 1), -1, 0, 0, ClientWidth(Desktop()), ClientHeight(Desktop()), 0
* edit * Just tested it and it's giving me problems with the status bar too. Seeing if I can come up with a fix...

* edit 2 *
Found a fix:
;.lib "user32.dll"
;GetActiveWindow%()
;SetWindowPos%(hWnd%,hAfter%,x%,y%,cx%,cy%,flags%)

test = CreateWindow("Test",0,400,400,100,0,7 + 8)
hwnd = GetActiveWindow()

Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = 1
Const SWP_NOMOVE = 2
Const SWP_NOACTIVATE = 16
Const SWP_SHOWWINDOW = 64

SetWindowPos hwnd, HWND_TOPMOST, 0, 0, ClientWidth(Desktop()), ClientHeight(Desktop()), 0

Repeat: Until WaitEvent() = $803
Looks like QueryObject doesn't return a proper hWnd on status windows.

* edit 3 *
You're welcome, Richard :)


Richard Betson(Posted 2004) [#3]
Very Nice!!

Thanks alot Eikon!


L8r,


Richard Betson(Posted 2004) [#4]
One more thing :)

How would I keep the "TopMost" window active all the time? I've tried SetActiveWindow(), ShowWindow() (win api) and alike, with no help.

I've also tried catching event $2001 and using ActivateWindow(), also no luck.

Ideas?

L8r,


Eikon(Posted 2004) [#5]
I tried every API function in the book and I can't get a modal window working. I also searched the forums and no one else seems to have figured it out either.

I will look into it more tommorow at work. Would a DLL be ok?


Richard Betson(Posted 2004) [#6]
Would a DLL be ok

Sure:)

What I'm up to is working on an IDE. So, when I launch/run the compiler app. I set the IDE window to "TopMost" and then set foucus to that window. I next use FindWindow() to look for a specific compiler window and then when it's gone continue to run the compiled app. This is the only way I could get it all to work. FindWindow() seems not to work unless I set the window to "TopMost" and SetFocus().

Getting the window to stay active would be nice. But getting ShowWindow() to work right would be even better. ShowWindow() seems to work oddly with B+. I tried minimizing and then restoring the IDE window, which worked, but it for some reason stays inactive when it's restored (huh..what). In fact after doing this no windows are active on the desktop. Soooo.. I hope this add s some light to at least what I'm doing.

BTW.. These are the ShowWindow() flags I'm using:

;#define SW_HIDE 0
;#define SW_SHOWNORMAL 1
;#define SW_NORMAL 1
;#define SW_SHOWMINIMIZED 2
;#define SW_SHOWMAXIMIZED 3
;#define SW_MAXIMIZE 3
;#define SW_SHOWNOACTIVATE 4
;#define SW_SHOW 5
;#define SW_MINIMIZE 6
;#define SW_SHOWMINNOACTIVE 7
;#define SW_SHOWNA 8
;#define SW_RESTORE 9
;#define SW_SHOWDEFAULT 10
;#define SW_FORCEMINIMIZE 11
;#define SW_MAX 11


-- EDIT --
Well.. I still need a "TopMost" window but it's not needed to get FindWindow() to work correctly. If I use WaitEvent(0) (notice the zero) instead of WaitEvent() FindWindow() seems to work fine. It's polling all the time that way but I guess it makes sence. ShowWindow() was unaffected (still not working) by zero polling.

Thanks for the help :)
L8r,


Perturbatio(Posted 2004) [#7]
Always on top (mixed in with other code) (note that this is code for B3D and may need some messing around with):



Mr Brine(Posted 2004) [#8]
Cool Information Eikon!

Thanks