|
-
Feb 11th, 2008, 06:34 AM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] Problems with custom shaped Forms
I've been working on developing a custom UI for one of my recent programs, and decided to make my own form. The problem is that since I override the OnPaint method of the form and I can't draw into the non-client area I must set the form border style to none, and therefore the main form loses a lot of its functions.
I've alrady implement some of these features, but there are two I still wonder how to re-implement, one is the possibility of minimizing the program when I single-clicking the "program description" (I don't know its correct name) on the taskbar, and the other is the menu that appears when you right-click on it. I guese both are managed by some API, but I don't know which one.
Another option would be subclassing the form and so allowing me to draw to the non-client area, but I prefer not to swich to this one if possible, since I already have the rest of the logic for the previous way. I know this would be easier using WPF, but there are several points making it not an option right now.
-
Feb 11th, 2008, 09:32 AM
#2
Fanatic Member
Re: [2005] Problems with custom shaped Forms
Hello NeverBirth,
I had the same problem and I solved it using the NotifyIcon component from the toolbox. I used the contextMenu for the Icon and the following code. Once implemented I am able to use a single click on the taskbar to minimize and maximize the form.
Hope this help.
Code:
If Me.ContxtMenu.MenuItems.Item(0).Text = "Restore" Then
' Set the WindowState to normal if the form is minimized.
If (Me.WindowState = FormWindowState.Minimized) Then _
Me.WindowState = FormWindowState.Normal
' Activate the form.
Me.Activate()
Me.ContxtMenu.MenuItems.Item(0).Text = "Hide"
Else
Me.WindowState = FormWindowState.Minimized
Me.ContxtMenu.MenuItems.Item(0).Text = "Restore"
End If
-
Feb 11th, 2008, 11:21 AM
#3
Thread Starter
Addicted Member
Re: [2005] Problems with custom shaped Forms
 Originally Posted by Clanguage
Hello NeverBirth,
I had the same problem and I solved it using the NotifyIcon component from the toolbox. I used the contextMenu for the Icon and the following code. Once implemented I am able to use a single click on the taskbar to minimize and maximize the form.
I think you are misunderstanding me (either that or I'm missing your point), NotifyIcon is for adding an icon in the System Tray, so how does it affect the taskbar itself?
When a program is maximized and it has the focus if you click on its correspondent "name" on the taskbar it minimizes, however when a form doesn't have any of the sizable borders it does nothing.
-
Feb 11th, 2008, 11:54 AM
#4
Fanatic Member
Re: [2005] Problems with custom shaped Forms
Sorry I have not replied sooner. I am not getting the replies.
I do not know how it affects the Taskbar but I am able to click on my application in the taskbar and I can restore the form when it is minimized. I did add a button to minimize the app on my form though.
The notify icon can always be made invisible.
[IMG]c:\PScreen.bmp[/IMG]
-
Feb 11th, 2008, 01:00 PM
#5
Thread Starter
Addicted Member
Re: [2005] Problems with custom shaped Forms
Then I'm not understanding you. The notify icon events react to events caused by some interaction with the icon or its BalloonTip, I think you are confusing the taskbar itself with the system tray. What I want to know is when I click on the taskbar button corresponding to my program, so I can minimize my application, and how to re-add its context menu or add a custom one (I think I saw some tutorial about this latest topic, but I don't remember where :/).

EDIT: I found an article regarding how to add more items into the system menu of a program, but it doesn't help me, as it won't appear anyway in a borderless window. I guess subclassing is right way of going. Looking a bit at it when I click on the taskbar button it seems the messages with values 6, 7 and 134 are most times sent, but I don't know what they are and therefore which one would be the correct to catch.
Last edited by Neverbirth; Feb 11th, 2008 at 01:19 PM.
-
Feb 11th, 2008, 01:22 PM
#6
Fanatic Member
Re: [2005] Problems with custom shaped Forms
I am talking about the taskbar. See the image. It is a side effect.
Last edited by Clanguage; Apr 14th, 2008 at 01:10 PM.
-
Feb 11th, 2008, 01:29 PM
#7
Thread Starter
Addicted Member
Re: [2005] Problems with custom shaped Forms
 Originally Posted by Clanguage
I am talking about the taskbar. See the image. It is a side effect.
Then I'm not able to get it to reproduce, I tried it before my previous replies with no luck.
-
Feb 11th, 2008, 01:53 PM
#8
-
Feb 11th, 2008, 02:20 PM
#9
Fanatic Member
Re: [2005] Problems with custom shaped Forms
Try this if you do not mind making calls to the API
http://www.vbcity.com/forums/topic.asp?tid=72198&
-
Feb 11th, 2008, 03:22 PM
#10
Re: [2005] Problems with custom shaped Forms
I personally hate non standard/skinned applications that act like what you are describing.
People all the time bash Microsoft for not conforming to standards, yet they release an OS with certain standards in how windows should look and behave under certain actions, and then developers try to throw that all out the window because they think they can do a better job.
The end result is usually a program that looks nothing like what people are used to, so right away there is a learning curve just to figure out how to do stuff. The next issue is the fact that you will likely end up breaking some standard functionality that people use (even if you don't). So even when you figure out ways to implement the functionality you just broke because you had to make your app look "custom" will you think of all functionality? What about standard shortcut keys in windows for doing things like minimizing/maximizing windows, etc... there are a whole bunch of shortcuts that may now not work correctly with a borderless form (which is what windows sees the form as) and then what? Are you going to implement system wide keyboard hooks so your app will work correctly when a user hits a shortcut key combination?
Do everyone who is going to use your app a favor, and just leave it fixed single and leave the built in functionality in place. Eye candy will never replace good old functionality. Sometimes you get lucky and the 2 can work together.
-
Feb 11th, 2008, 04:11 PM
#11
Fanatic Member
Re: [2005] Problems with custom shaped Forms
The way I see it, it is not a standard problem but a lack of functionallity. If MS wanted to enforce standards they would not allow a FormBorderStyle of none. Alternatives to MS forms are sometimes warranted.
I do agree on many of your points especially the keyboard mapping and honestly I wish MS had provided me with the capability to make my forms truly borderless without the hassle I have to go through.
-
Feb 11th, 2008, 04:14 PM
#12
Re: [2005] Problems with custom shaped Forms
A border style of non is generally for use with forms that
1) take up the entire screen (including taskbar) and are modal (don't allow other windows to come into focus while this window is open)
2) popup style windows (similar to tooltips, popup notifications in the tasktray area, etc..)
3) some other reason I can't think of right now
Anyway my point is that borderless forms were not included with the direct intention of doing what is trying to be done here, they are for other purposes.
Of course that doesn't mean you CAN'T use them for what you are trying to do, I just think its a whole lot of extra work, and in the end, it usually just frustrates the end user.
-
Feb 11th, 2008, 04:19 PM
#13
Fanatic Member
Re: [2005] Problems with custom shaped Forms
I agree but I do not make the rules so I have to work with what is given me. Anyway you seem to be very knowledgeable with VB. Thank you for your answers.
-
Feb 11th, 2008, 04:22 PM
#14
Re: [2005] Problems with custom shaped Forms
I hear ya, and I also know that sometimes you want to implement something that isn't there, and in many cases that is a totally valid thing to do.
Sometimes I work on a project only to back track later because while the feature was "cool" to have, it just made things a nightmare to manage, and wasn't actually increasing the productivity of the software. It was actually making it harder to use.
Perhaps what you should work on, is making a class to wrap up all this custom functionality that needs to be implemented when doing this style of form, and then you could just use that class anytime you wanted to have a non standard form, and you would automatically just get all the built in functionality that is needed.
-
Feb 11th, 2008, 04:27 PM
#15
Fanatic Member
Re: [2005] Problems with custom shaped Forms
Actually it will be very simple to do that since I always isolate this kind of functionality. Thank you for the tip and have a great day/evening?
-
Feb 11th, 2008, 05:41 PM
#16
Thread Starter
Addicted Member
Re: [2005] Problems with custom shaped Forms
 Originally Posted by kleinma
I personally hate non standard/skinned applications that act like what you are describing.
Well, I don't find those two features that important, but I don't like it either, that's why I'm implementing them. They are, AFAIK, the only things missing. I find to be more annoying when proffessional apps don't provide a right tab order on forms.
 Originally Posted by kleinma
People all the time bash Microsoft for not conforming to standards, yet they release an OS with certain standards in how windows should look and behave under certain actions, and then developers try to throw that all out the window because they think they can do a better job.
The thing is they are the first ones to break standars, WMP, Office 2007, custom controls on tons of their apps, etc. I've never bashed them for it tho, I find it to be a normal thing, nor I do think I can do better, just want to give my app another personal touch, and I know it will attract some more people that way.
 Originally Posted by kleinma
The end result is usually a program that looks nothing like what people are used to, so right away there is a learning curve just to figure out how to do stuff. The next issue is the fact that you will likely end up breaking some standard functionality that people use (even if you don't). So even when you figure out ways to implement the functionality you just broke because you had to make your app look "custom" will you think of all functionality?
I'm not trying to make something bizarre, nor extremely non-standard, and I do know that making some things in a more visual and therefore intuitive way is simpler for them. I wish most of my end-users would know about all those functionalities... when I started making some of my first applications I had to rewrite some of them because the users found too hard to use treeviews for some hierarchical lists, and they had some complications using some context menus...
 Originally Posted by kleinma
What about standard shortcut keys in windows for doing things like minimizing/maximizing windows, etc... there are a whole bunch of shortcuts that may now not work correctly with a borderless form (which is what windows sees the form as) and then what? Are you going to implement system wide keyboard hooks so your app will work correctly when a user hits a shortcut key combination?
Adding back the shortcuts isn't something difficult and already added them, they are just a bother to add back.
Lastly, I may end switching over drawing the window using native APIs, as I already have some base for that on a previous project, or I may not add it at the end (don't think so heh), this is a personal project for some familiars and friends, so I don't have any time frame to finish it.
Thks for the link Clanguage, I'll have a look at it.
LATE EDIT: After looking at the samples attached on thread Clanguage linked it solved the rest of my doubts. Thank you .
Last edited by Neverbirth; Feb 11th, 2008 at 07:16 PM.
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
|