borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

(Pages: Next Page 1 2 ) Print This Topic
Previous Topic (inserting data into a table)Next Topic (how to buy VB 6.0) New Topic New Poll Post Reply
AndreaVB Forum : VB General : desktop boundaries
Poster Message
tgtf38
Level: Guest


icon desktop boundaries

I am trying to create a docked toolbar application in VB6.  I need some help with keeping windows from maximizing under it while it is docked. (much like the windows taskbar does)   Tried looking every but cannot seem to find out how to set the desktop boundaries so maximized windows will be smaller to allow for the toolbar and the title bar.  Open to any suggestions.

[Edited by tgtf38 on 10-02-2004 at 08:55 PM GMT]

11-02-2004 at 02:55 AM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: desktop boundaries

If I undestood you well, I would like your windows to be maximized to size you determine. It that is so, you  would have to do next:

1) subclass your form,
2) intercept WM_GETMINMAXINFO
3) copy value from lParam to MINMAXINFO strucure
4) change values of MINMAXINFO strcture to your desired values
5) copy this structure back to lParam
6) pass the message to original window procedure.

All help you need about MINMAXINFO structure oyu can get from MSDN.

____________________________
If you find the answer helpful, please mark this topic as solved.

11-02-2004 at 03:18 PM
View Profile Send Email to User Show All Posts | Quote Reply
tgtf38
Level: Guest

icon Re: desktop boundaries

Thank you for your reply. I have been reading some of the other threads.. very good help for an old DOS coder in a Windows world.  

The only difference that i believe in what you showed and what i was looking for was that i need all windows (not just  my forms) to reduce its overall maximize size.

For instance.. if taskbar is on autohide, the desktop background and most windows go to the complete bottom of the screen.  If the taskbar is not on autohide and always on top, the desktop background resizes smaller and all windows when maximized stop at the border of the taskbar.  Could care less about the desktop background , but the windows resizing would help..

I will still look into this function on MSDN some more.  I'm not sure if this will do the job, but as always, i will not sleep until it works.    .. Thank you again..

12-02-2004 at 12:01 AM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: desktop boundaries

Desktop background isnt resized when hiding taskbar, it just reveals whole its area. What I dont understand is why do you want to prevent those windows from resizing, because you said not just yours but all of them.  

____________________________
If you find the answer helpful, please mark this topic as solved.

12-02-2004 at 01:45 AM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

quote:
Goran wrote:
Desktop background isnt resized when hiding taskbar, it just reveals whole its area. What I dont understand is why do you want to prevent those windows from resizing, because you said not just yours but all of them.  


Hi Goran. what I understand from his request, and I could be wrong, is that he wants to have his own task-bar like window that will come and stay there. If the user maximizes a form, even from another app, it should not cover the entire desktop but leave his task-bar visible, just like the normal task bar does.

I would look into this but I have to sleep for now (3:51am our time). See you guys later. Happy coding.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer
12-02-2004 at 01:56 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
tgtf38
Level: Guest

icon Re: desktop boundaries

You are right fabulous.  I cannot always seem to get words down in understandable form.  And i was wrong about the desktop resizing.  But basically I am either a.> trying to find out how to change all windows maximize size and resize them, or b.> find a windows function that does it for me. Thank you fabulous..

12-02-2004 at 12:42 PM
| Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

Hi tgtf38, I have just got in and I will look into this matter. Be back with something as soon as I find it.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

12-02-2004 at 06:47 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: desktop boundaries

Hello.
I was surfing, looking for an API that showing the height of Windows taskbar. I jumped in this: http://www.mentalis.org/tips/tip86.shtml and in this other one http://www.mentalis.org/apilist/FindWindowEx.shtml (click the sample link).
Have a look on them, even don't seem to be matching your question, they offer some points of reflection to start with. The second tutorial creates a new Start button, so we can retrieve its size. Hope they'll be useful.

PS. not about the lower boundary (I didn't yet succeed to get the taskbar top boundary), but regarding the other three boundaries you should keep an eye on the Screen object. If I find more, I'll post again

[Edited by yronium on 13-02-2004 at 01:32 AM GMT]

____________________________
Real Programmer can count up to 1024 on his fingers

13-02-2004 at 12:31 AM
View Profile Send Email to User Show All Posts | Quote Reply
tgtf38
Level: Guest

icon Re: desktop boundaries

Thank you for your replies.   They've got me thinking.. would it be possible to enumerate thru all visible forms and set limits thru the WM_GETMINMAXINFO property for each form?  And with that I would have to trigger off of an event for form state changes to keep up with the windows from there.  Dunno.. I have never gotten stuck to this point before.. laters  

13-02-2004 at 04:39 AM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: desktop boundaries

WM_GETMINMAXINFO is send to window every time a resising or repositioning is going to occur. So, you cannot just set its value, hoping it will do the work for you all the time. You need to set it every time its resised (or changing position). This is done by subclassing.

Now, considering your own app, this is easy to do. But, considering otther app's, I never did manage to succeed in doing this, altough I have tried only once about 6 months ago.   When I tried to subclass Windows Commander, for instance, SetWindowLong function succeeds (returns previous procedure address), but the function never receives any window message. So, it seems that it cant be done. Or I didnt know how to.  

There is another issue here: let's say subclassing windows of other app's can be done, and lets say those windows where already subclassed. So, what we would have here is - we are receiving message WM_GETMINMAXINFO, changing Max size to whatever we want, and passing message to previous window procedure, which would be window procedure of that APP (cause its already been subclassed). And lets say that this procedure also monitors WM_GETMINMAXINFO, and sets its own value, which will override your settings, and then pass this message to original window procedure. Then your subclassing will have no effect.

Tgtf38, as for you question about enumeration there is a way how you can enumerate through all windows (Child and non-child) - using EnumWindows and EnumChildWindows API's, respectively.

So I am coming back to my first question - What exactly are you up to? Maybe we can help you to do it in some other way For instance, if you want your window not to be covered by other App's then maybe making it topmost would be enough

SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE


[Edited by Goran on 13-02-2004 at 02:11 PM GMT]

____________________________
If you find the answer helpful, please mark this topic as solved.

13-02-2004 at 01:08 PM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

Hi guys.

I was thinking that there must be a way to tell all windows not to take a certain part of the screen, the way the task bar does it. I was thinking of looking at the SystemsParametersInfo API function but my MSDN.OLD is not installed on this machine and I cannot get hold of it soon. I don't know how your program is right now Goran, but could you have a look at the documentation of what you could do with SystemParametersInfo, including some of the SPI_ constants. I think a solution could be found there. As soon as I get MSDN installed (cannot say when) I will look into this.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

13-02-2004 at 06:45 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

I have just taken a look through the API viewer. I found 2, maybe three entries that could help, or not, but I think this is a start.

Private Const SPI_GETWORKAREA = 48

Private Const SPI_SETNONCLIENTMETRICS = 42

Private Const SPI_SETWORKAREA = 47


My bet, if I was to gamble, would be on GETWORKAREA and SETWORKAREA. A possible next step is to find out exactly what they do and how to make use of them. In fact, let me check MSDN.NET, they could still be there.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

13-02-2004 at 06:55 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

I have some good news, and I think shortly I will have even better news. In MSDN.NET I just found these two following entries:

GETWORKAREA

quote:
Retrieves the size of the work area on the primary screen. The work area is the portion of the screen not obscured by the system task bar or by toolbars displayed on the desktop by applications. The pvParam parameter must point to a RECT structure that receives the coordinates of the work area, expressed in virtual screen coordinates.
To get the work area of a screen other than the primary screen, call the GetMonitorInfo function.


SETWORKAREA
quote:
Sets the size of the work area — the portion of the screen not obscured by the system taskbar or by toolbars displayed on the desktop by applications. The pvParam parameter is a pointer to a RECT structure that specifies the new work area rectangle, expressed in virtual screen coordinates. In a system with multiple screens, the function sets the work area of the monitor that contains the specified rectangle.
If pvParam is NULL, the function sets the work area of the primary screen to the full screen.


What is left now is to put some code to it. Bye for now.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer
13-02-2004 at 07:13 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

I have the code.

Basicall, what it is is a task bar, with a title bar, control box and only one button to close it. When you run it, it checks the Workarea and moves itself to the bottom - its height.

It then modifies the work area and broadcasts the message to all other windows which will resize accordingly. On unloading it restores the settings. I did not make it always on top (http://www.andreavb.com/forum/database/index.php?action=showmod&page=0&mod=29).

I'm sure tgtf38 can use this code in his application. I hope this helps. See the attached project.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

____________________________
Attached:
spi.zip 2 KB (Downloads: 78)

13-02-2004 at 08:24 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: desktop boundaries

I just came home, and had a quick look on your post, fab. And I didnt have time to try them cause I am still in a hurry. I tried them once, but as I recall, and I dont know for sure, bradcasting messages to all top level windows didnt work quite well. And, to add, this rect only reffers to maximizing windows, I think you can still move windows out of that area, so they can still cover whole screen resolution. Anyway, fab, its good that U have remembered this one.  

____________________________
If you find the answer helpful, please mark this topic as solved.

13-02-2004 at 08:48 PM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

The broadcasting of the message in this case is via a parameter to SystemParametersInfo in the form of SPIF_SENDWININICHANGE (a constant) in the last parameter. All other windows will receive a message from windows itself and react accordingly. I just tested it with some windows maximized and they adjust themselves to the new work area.

However, if the windows are not maximized they remain where they are. (You can move a normal window below the confines of the screen.) When you maximize these they take the new size without affecting the toolbar.

The issue I am getting however is when unloading the form. I am reseting everything but none of the windows are responding. If I restore them and maximize them again they take the ordinary setting. I didn't worry too much about this because I have seen other apps fail to restore things. Some windows respond and others don't.

But I guess this combined with always on top as you said Goran would make a pretty normal toolbar. Happy coding.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

13-02-2004 at 09:03 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: desktop boundaries

Yep, I know. But, as you can see, this code doesnt resize windows that were already been loaded. This is what I had in mind when I said that broadcasting this message doesnt work quite well. SPIF_SENDWININICHANGE (or =SPIF_SENDCHANGE) sends WM_SETTINGCHANGE message to all top level windows after updating the user profile. In this case it doesnt update any window position on screen. I think I have tried to send this message using SendMessageTimeout API, but no benefit from that, too.  

As for SPI_SETWORKAREA, I think that MS made a miss here. If work area = screen  area, then max window width= screen width, and max window height = screen height. If you set work area to be smaller than screen, then max window width and height would still remain screen width and height, not work area width and height.  

[Edited by Goran on 14-02-2004 at 01:46 AM GMT]

____________________________
If you find the answer helpful, please mark this topic as solved.

14-02-2004 at 12:16 AM
View Profile Send Email to User Show All Posts | Quote Reply
tgtf38
Level: Guest

icon Re: desktop boundaries

Before I read the oodles of information on all the posts you guys so generously posted..     

Basically my toolbar resides at the top of the desktop (taskbar at bottom).  Now it has always on top and a few other goodies to make it a toolbar.  But when i maximize a window, the active title bar of that windows tucks under my toolbar.  Of course this hides the title and the control buttons of that window.. which can be slightly annoying.. that is really the only concern. (not like I am making this program for money, just for my own personal utility)  If i'm stupid enough to move a window up there, thats my fault   ..

So rather than make it an autohide toolbar which could also get annoying everytime you try to close a maximized app, i am shooting for this..  I have seen other programs do it and i don't wanna have mine feel left out.

So i am off to read the forum and msdn side by side.  Thank you guys, you're great.

14-02-2004 at 02:56 AM
| Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

Hi tgtf38.

I have just seen your reply and that there is one download for the code I uploaded, I don't know whethe it is you or Goran who donwloaded it. Just wanted to bring your attention to it. To have your toolbar at the top modify the code to this:

    Me.Top = 0
'    Me.Top = ScaleY(r.Bottom, vbPixels, vbTwips) - Me.Height    'adjust my top
    Me.Width = Screen.Width                                     'get the full screen width
    Me.Left = 0                                                 'go to the left
'    r.Bottom = ScaleY(Me.Top, vbTwips, vbPixels)                'change the setting in the RECT variable
    r.Top = ScaleY(Me.Height, vbTwips, vbPixels)


These are changes to made to Form_Load, you will see where they need to go. Do the following in Form_Unload:

'    r.Bottom = r.Bottom + ScaleY(Me.Height, vbTwips, vbPixels)      'change it in the varialbe
    r.Top = r.Top - ScaleY(Me.Height, vbTwips, vbPixels)
    'send the change to Windows and let it broadcast the message to all open windows


I have left the old code, commented for you to easily identify what to change. That should have your problem solved. Happy coding.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

14-02-2004 at 03:10 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
tgtf38
Level: Guest

icon Re: desktop boundaries

Thank you man, you have cured my endless search .. Til next time..

14-02-2004 at 02:22 PM
| Quote Reply
GCamaro83
Level: Guest

icon Re: desktop boundaries

I am getting the message type mismatch when I try and run the attached program from one of the previous threads.  I am using vb 5.0, could that be why?  It is occuring at...

Private Sub Form_Load()
    Dim lng As Long, r As RECT
    lng = SystemParametersInfo(SPI_GETWORKAREA, 0&, ByVal r, 0&) 'get the size

Sorry if this is a dumb question, but I am new to programming.  Thank you

11-05-2004 at 01:02 PM
| Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

Welcome to the forum GCamaro83.

There is no such thing as a dumb question, if you get the answer to it, you become a lot wiser/smarter.

Please tell me whether you have all the code that I uploaded. It could be possible that you could have switched the order of one of the arguments.

At this point I cannot say whether or not it has to do with VB5. Please advise whether or not you have all the code before we can help.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

15-05-2004 at 04:49 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
amol
Level: Guest

icon Re: desktop boundaries

code is ok but the .exe file is not working

what is solution for that

31-05-2004 at 12:21 PM
| Quote Reply
GCamaro83
Level: Guest

icon Re: desktop boundaries

Actually I ended up figuring it out that same day.  I used your code as a starting block then just adjusted it to fit what i was looking for.  Thanks a million.

31-05-2004 at 02:05 PM
| Quote Reply
RobbieD
Level: Guest

icon Re: desktop boundaries

The program works when running in the VB IDE, but it does not work when running the compiled version (the working area of the screen is not chnaged).

SystemParametersInfo returns a value of 0 in the compiled version.

Is there any way to make it work in the compiled version?

14-06-2004 at 10:14 PM
| Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

Here is the fixed code thanks to my good friend Goran. Let me know if there are any other issues. Sorry for the delay, I have been quite busy with other things.

Happy coding

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

____________________________
Attached:
spi.zip 2 KB (Downloads: 82)

18-06-2004 at 11:08 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
RobbieD
Level: Guest

icon Re: desktop boundaries

Thanks fabulous and Goran!!

You guys are great!

21-06-2004 at 07:15 PM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: desktop boundaries



____________________________
If you find the answer helpful, please mark this topic as solved.

22-06-2004 at 06:01 PM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: desktop boundaries

Happy coding

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

22-06-2004 at 06:42 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
hyousuf
Level: Protégé

Registered: 24-02-2005
Posts: 4
icon Re: desktop boundaries

hi there people, i dunno when was this originally posted but to tell u wat i had the same prob to start wid n was just wasting my time searching the net until i found this thread i have read it from top to bottom n it exaclty matches my requirement, i downloaded the first code spi.zip which had the problem that it din't work when it was compiled n then fabulous returned with modifications in it, but the problem is that im unable to access that link , it says that "you're not logged in or you do not have permissions to read it"
pls fabulous n goran help me get that code as soon as possible or upload it again
thnkx in advance !

24-02-2005 at 12:21 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : desktop boundaries
Previous Topic (inserting data into a table)Next Topic (how to buy VB 6.0) New Topic New Poll Post Reply
(Pages: Next Page 1 2 )
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder