 |
(Pages: 1 2 ) |
 |
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
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 |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
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 |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
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 |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
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 |
|
|
fabulous Level: VB Guru

 Registered: 03-08-2002 Posts: 439
|
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 |
|
|
hyousuf Level: Protégé
 Registered: 24-02-2005 Posts: 4
|
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 |
|
|
|
|
 |
 |