|
-
Jul 4th, 2000, 05:37 AM
#1
Thread Starter
PowerPoster
How can I make my window always staying behind all other apps? As the desktop does I mean.
Need answers soon
-
Jul 4th, 2000, 06:23 AM
#2
_______
not sure if this is the answer but it's a thing to check out
ZOrder Method
Places a specified MDIForm, Form, or control at the front or back of the z-order within its graphical level. Doesn't supportnamed arguments.
Syntax
object.ZOrder 1
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 4th, 2000, 06:26 AM
#3
Thread Starter
PowerPoster
Nope, Im sorry...
I thought about a API call like SetWindowPos but I didnt find a parameter to set it always behind
-
Jul 4th, 2000, 06:34 AM
#4
_______
I personally haven't tried this...
Public Const HWND_BOTTOM = 1
Public Declare Function SetWindowPos Lib "user32.dll" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
dim retval as long
retval = SetWindowPos(Form1.hWnd, HWND_BOTTOM, 0, 0, 1, 1, flags)
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 4th, 2000, 06:55 AM
#5
Thread Starter
PowerPoster
*hehe* already tried this 
Well, it puts the window behind all other... but after it gets the focus it's on top again. 
But you know ie. the desktop is alwaysbehind...
-
Jul 4th, 2000, 09:07 AM
#6
Thread Starter
PowerPoster
-
Jul 4th, 2000, 11:29 AM
#7
Hyperactive Member
I had to conduct a little testing for this, but alas, I was right 
What you need to do is, find the handle to the desktop- not the field that holds the icons, but the one that contains the picture. Use the SetParent API call to make your window a child of that window. I don't know if this will do exactly what you wanted; when you make it a child it will no longer show up on the taskbar, but it is always on bottom!
-
Jul 4th, 2000, 02:52 PM
#8
Thread Starter
PowerPoster
ok, I'll try this.. thx!
I hope it also works when i dont have a desktop (Explorer.exe)... you should know I'm making an alternative shell...
-
Jul 4th, 2000, 03:09 PM
#9
Hyperactive Member
That's the only reason I could think that you would want to do this. Just make sure you use the background window and no window directly associated with Explorer.exe. Goodluck, I hope it works.
-
Jul 4th, 2000, 03:51 PM
#10
Thread Starter
PowerPoster
Didn't work I tried both, 0 and GetDesktopWindow() as parent but nothing happened...
Anyway, thx for help
Anyone other an idea? Kedaman; Megatron, yer GURUs, help me out
-
Jul 4th, 2000, 04:38 PM
#11
transcendental analytic
Hehe, sorry i was gone for a day, ok, well i see that didn't work, never tested my self anyway
And that's because most of the windows actully are parents to desktop and they have a zorder, well i'll try to think of something...
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 4th, 2000, 04:51 PM
#12
Fanatic Member
I'm pretty sure that the way this is done is explorer's desktop window (btw, this includes the icons area) sets all of the open top-level forms as children of itself. (i.e. if you open notepad, notepad becomes a child of explorer's desktop, not windows' desktop.)
-
Jul 5th, 2000, 12:13 AM
#13
Thread Starter
PowerPoster
Ok, so how can I replace the desktop window with my app?
-
Jul 5th, 2000, 12:20 AM
#14
Hyperactive Member
I think my method might work as well, it wouldn't be a very effective if you made it a child window of explorer! Try changing you sys.ini file shell=progman.exe. This way you can still get around on your computer. THEN, find out what the handle is that holds the background image and make your app a child of it. You can find what its handle is by using WindowFromPoint or something like that.
-
Jul 5th, 2000, 01:38 AM
#15
Fanatic Member
not what i meant. once you're rid of explorer, make a maximized form with no titlebar. this is the new desktop. make all the open windows children of your form. this is how explorer does it (i think) except it also has a listview where the icons are.
-
Jul 5th, 2000, 01:44 AM
#16
Thread Starter
PowerPoster
Phobic
We all know that the hWnd you mean is 0
agent
Ok, that's a good idea! I'll try that, thx!
-
Jul 5th, 2000, 02:00 AM
#17
transcendental analytic
Same problem will probably return when:
You launch an application,
you could probably set it as a child but you would have to do this in a loop since other applications also could launch apps, and they will get under your desktop if you don't handle them.
So you won't get rid of the "loop" you wanted to.
Well I hope there is a way anyway
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 5th, 2000, 02:26 AM
#18
Fanatic Member
BEWARE, for I have neglected to warn of one danger with my method: do not set a higher up window (a window that is a parent or a parent's parent... of yours) as a child. Windows doesn't try to prevent it and it will crash without an error message.
About the previous message; instead of looping, other forms will only go under yours if your form becomes activated (gets focus). Just check for new windows in the paint event, or better yet, subclass the gotfocus event (the vb version doesn't always work) and check for windows every time your window gets focus.
[Edited by agent on 07-05-2000 at 03:32 AM]
-
Jul 5th, 2000, 02:39 AM
#19
Thread Starter
PowerPoster
ok, well...
I tried something like this:
SetParent Shell("C:\Win98\Calc.exe"), Me.hWnd
well, when I selected my window again the calc was behind it 
So how does the Explorer do that? Does it install a hook to catch new apps and make them children of itselves or does it really use a loop? (I don't hope so )
-
Jul 5th, 2000, 12:46 PM
#20
Fanatic Member
you'll need to get the window's handle. findwindow(vbnullstring,"Calc")
-
Jul 5th, 2000, 03:27 PM
#21
Thread Starter
PowerPoster
Like kedaman said: What when a program opens another app? I wouldn't know the caption or hWND I need another way... sorry
-
Jul 8th, 2000, 11:58 PM
#22
Code:
'Add this into your module
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Global Const conHwndTopmost = -1
Global Const conHwndNoTopmost = -2
Global Const conSwpNoActivate = &H10
Global Const conSwpShowWindow = &H40
'Ontop
SetWindowPos hwnd, conHwndTopmost, 100, 100, 205, 141, conSwpNoActivate Or conSwpShowWindow
'NotOntop
SetWindowPos hwnd, conHwndNoTopmost, 100, 100, 205, 141, conSwpNoActivate Or conSwpShowWindow
-
Jul 9th, 2000, 04:31 AM
#23
Thread Starter
PowerPoster
I'm so sorry Matthew, but that's absolutely not what I was looking for But if you know a solution... I need code to make a window always stay behind like the desktop does.
-
Jul 9th, 2000, 12:02 PM
#24
Frenzied Member
Just a suggestion...
Wouldn't it be cooler showing the "desktop" just by clicking it?
Also, if you have an API function to send it to the back, use it in the _GotFocus event.
Bye,
-Jotaf98
"Cyberspace forever"
[email protected] - ICQ#60784495 - http://jotaf98.cjb.net
-
Jul 9th, 2000, 01:43 PM
#25
Thread Starter
PowerPoster
I also thought about menus coming when you move the mouse to a side, but that would also require a loop... well, for the first time I want to nearly copy the windows desktop. I like this system with the icons, even I have many improvements 
Thanks for the tip, i'll try that with GotFocus. I think it won't work or at least flicker, but it's worth giving it a try.
-
Jul 9th, 2000, 01:53 PM
#26
_______
<?>...maybe this is what you've already tried...maybe not...
Code:
'How to set a form as bottom of the order and keep it there
'using subClassing
'
'I didn't write this it was handed over to me..I tried it out
'and it does seem to do the trick..however you must end it by
'using dblClick on form..if you use the stop key in VB it will
'crash....so it must be unloaded via code
'bas module code
Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" _
Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Public Const GWL_WNDPROC = (-4)
Public Const WM_PAINT = &HF
Public Const WM_ACTIVATE = &H6
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_BOTTOM = 1
Public winProc As Long
Public Function WindowProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim lFlags As Long
lFlags = SWP_NOSIZE Or SWP_NOMOVE
Select Case wMsg
Case WM_ACTIVATE
SetWindowPos hwnd, HWND_BOTTOM, 0, 0, 0, 0, lFlags
Case Else
WindowProc = CallWindowProc(winProc, hwnd, wMsg, wParam, lParam)
Exit Function
End Select
End Function
Public Sub SubClass(hwnd As Long)
On Error Resume Next
winProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub UnSubClass(hwnd As Long)
If winProc Then
SetWindowLong hwnd, GWL_WNDPROC, winProc
winProc = 0
End If
End Sub
'Form Event Code
Private Sub Form_Activate()
Me.ClipControls = False
Me.BorderStyle = 0
Me.Caption = ""
Me.Refresh
End Sub
Private Sub Form_DblClick()
UnSubClass Me.hwnd
Unload Me
End Sub
Private Sub Form_Load()
SubClass Me.hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubClass Me.hwnd
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 9th, 2000, 02:05 PM
#27
Code:
'Your program
Public Const HWND_BOTTOM = 1
Public Declare Function SetWindowPos Lib "user32.dll" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Timer1_Timer()
Dim retval as long
retval = SetWindowPos(Me.hWnd, HWND_BOTTOM, 0, 0, 1, 1, flags)
End Sub
Another program:
Code:
Public Const HWND_BOTTOM = 1
Public Declare Function SetWindowPos Lib "user32.dll" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Declare Function findwindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Timer1_Timer()
Dim thewindow As Long, retval As Long
thewindow = findwindow(vbNullString, "Form1")
retval = SetWindowPos(thewindow, HWND_BOTTOM, 0, 0, 1, 1, Flags)
End Sub
-
Jul 9th, 2000, 02:11 PM
#28
Thread Starter
PowerPoster
HeSaidJoe
Thanks a million! That's what I needed! Yeah!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|