1 Attachment(s)
Desktop-style application
Hello,
I've been puzzling over the best strategy for my application for a while now, but keep on coming up against brick walls, so i thought i'd pick the brains of the people here.
The application has a main form from which subforms are launched (but kept within the boundaries of the main form). The main form should always remain behind the subforms (like the desktop always remains behind the applications in windows) but still respond to click events, and there is the equivalent of the windows taskbar at the bottom of the application to manage all the forms.
The attached picture explains it better. I created the app using MDI, but i had to use a borderless form as the background so it keeps coming to the front. I haven't managed to find a way of keeping one form to the back.
It seems that i can't do it that way, so i was wondering if anyone knew of similar examples, or other ways in which this could be achieved.
Thanks for your help,
Re: Desktop-style application
Zorder might help.. just create a Public sub that sets the Zorder so the main form is always last...
Re: Desktop-style application
you can try using SetWindowPos API. try putting this in a module:
VB Code:
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 HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
and while loading the sub-form, use this:
VB Code:
Call SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
Re: Desktop-style application
but that will also keep the windows above other apps as well.. just so u know
Re: Desktop-style application
Quote:
Originally Posted by Static
Zorder might help.. just create a Public sub that sets the Zorder so the main form is always last...
but then the back-form wont react to any mouse press or any such event.
Re: Desktop-style application
Quote:
Originally Posted by Static
but that will also keep the windows above other apps as well.. just so u know
yes it will. but actually what he is trying to do is that when the user tries to click on the background form to open another subform, all the previously opened subforms must not get back to the main form. Zorder wont help in this regard, i think so.
Re: Desktop-style application
Zorder will not stop u from clicking the form..
it just sets the order of "who" is in front.. BUT I just thought of this.. it will cause a flicker of being brought to the top, then being pushed to the back again.
you could always create your own forms from picture boxes :) if might take more work but it would work
Re: Desktop-style application
In MDI pictured above there is frmMain - the MDIForm and frmTimeTable - MDIChild which is the background you can see with two buttons.
i wish to keep frmTimeTable at the back of all the MDIChild forms. Neither zorder, nor setwindowpos can do this. Putting controls on the MDIForm background isn't possible either, so i guess i can't do what i want to do that way. i was wondering if there were any alternative solutions to create the app i want (or solutions to the MDI problem!)
1 Attachment(s)
Re: Desktop-style application
attached is a quick sample I just made....using a picturebox as a "form"
Re: Desktop-style application
thanks static, that's the style of app that i want. but i wanted to keep nice xp gradient borders round the 'subforms'.
1 Attachment(s)
Re: Desktop-style application
then all u need to do is create a "picture" in as the background in your pictureboxes.. it could make it look exactly like the form :)
take a look at this attachment
Re: Desktop-style application
i won't be able to resize the form if i do that though, will i?
otherwise it'd be perfect :(
Re: Desktop-style application
well.. u could with a bit of coding.. never tried that.. but search for resising controls
then search for resizing images :) should be able to do it