Extend non-client area on form with custom drawn titlebar - vb.net

I used the awesome tutorial at http://www.codeproject.com/Articles/44235/Painting-Vista-s-Aero-NonClientArea-in-VB-NET to make my form have custom non-client area controls. It now looks like so:
http://i.imgur.com/5A1GtF7.jpg
I would like to make it so that the non-client area extends all the way down to the TabControl page start, so the logo is completely in the non-client area and there is no grey at the top of the window.

Find this line in the form's code:
dwmMargins.cyTopHeight = nccsp.rect2.Top - nccsp.rect1.Top
Now just add however many pixels you need:
dwmMargins.cyTopHeight = nccsp.rect2.Top - nccsp.rect1.Top + x

Since you can use DLL's, I found this:
Download this DLL: http://www.mediafire.com/download/jmvjiu2wty4/rtaGlassEffectsLib.dll
Then create an instance of rtaGlassEffect
Dim glass As New rtaGlassEffectsLib.rtaGlassEffect
Finally put this in your form's Load event handler:
glass.TopBarSize = yourSize
glass.ShowEffect(Me)

Related

Dynamically Resize forms and controls inspite of change in Display size (Small/Medium/Large) in VB.net

We have developed windows application which is including many forms and controls with default small display size and it is working fine.
but in client systems,displays are not consistent. so when the same code runs with medium/large screen size, the controls are overlapping
It would be great help if anyone gives solution for dynamic re-size/fit the form & controls for any display (small-100%, medium-125%, large-150%)
and also Is there any way to find the Display size (small-100%, medium-125%, large-150%) in vb.net
You can change display size in control-Panel.
You can use the Anchor property to automatically adjust the control size according to its form size. You can anchor any side of the control to that side of the form. For example, if I anchor all four sides of a picturebox to the form, the picturebox will mimic the shape of the form when the form is resized. If you anchor only the top and the bottom of the picturebox, for example, it will change height with the form, but the width and horizontal position will remain constant.
Finally found a solution by doing R&D
call the below function in the Form_Load like ScaleForm(me)
Public Sub ScaleForm(WindowsForm As System.Windows.Forms.Form)
Using g As System.Drawing.Graphics = WindowsForm.CreateGraphics
Dim sngScaleFactor As Single
Dim sngFontFactor As Single = 1
If g.DpiX > 96 Then
sngScaleFactor = g.DpiX / 96
'sngFontFactor = 96 / g.DpiY
End If
If WindowsForm.AutoScaleDimensions = WindowsForm.CurrentAutoScaleDimensions Then
'ucWindowsFormHost.ScaleControl(WindowsForm, sngFontFactor)
WindowsForm.Scale(sngScaleFactor)
End If
End Using
End Sub

ToolStripTextBox image is not appearing

I am using WindowsForms and I am trying to put a Textbox into my main menu and add an Image. However I cannot get the image to appear. What am I missing here.
txtRequestEdit.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
txtRequestEdit.Image = Properties.Resources.Wrench16 'This is a valid image.
txtRequestEdit is a System.Windows.Forms.ToolStripTextBox
EDIT- Here is an image of the menu. The item at the bottom of this menu is the txtRequestEdit control.
Strangely the no matter how you apply the image, it won't show on ToolStripTextBox. I think this is a bug because I found nothing about this behavior in the documents or on the web.
I will try doing this with a hack like owner-drawing the item or something else and will put the wrong answer here so the next person with this issue avoids this wrong path.
This is wrong:
Apparently the Image property "supports the .NET Framework infrastructure and is not intended to be used directly from your code.", so if (as you say) everything's OK and you've checked the image itself to be valid, using ImageList and ImageIndex may solve the problem (assuming the item lies inside a MenuStrip named menuStrip1:
txtRequestEdit.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
menuStrip1.ImageList = New ImageList()
menuStrip1.ImageList.Images.Add(Properties.Resources.Wrench16)
txtRequestEdit.ImageIndex = 0

Change location of buttons at execution VB.NET

I am trying to change the location and size of buttons I have contained in a panel on a WinForm (vb.NET).
Initially the buttons have a location and an image (no text), but in execution I want to set a new location and text.
I am able to set the text for each button, and as they are set to Autosize, they increase in width.
But despite I set the location by code correctly, when the buttons are displayed they "come back" to their initial position.
Any help would be appreciated.
Thanks,
IM
The following code will change the location to the co-ordinates you specify:
Button1.Location = New Point(x, y)
You must change the x,y values to the co-ordinates on the form that you want to move the button too.
The next bit of code with change the size of your button:
Button1.Height = 10
Button1.Width = 50

Add Icon to context Menu in VB.NET inside a windows forms appliction

I have searched many times here and on Google looking for a solution that did not envolve utilizing someone's class.
This context menu is pops up where the user right clicks inside a dataGridView
When adding the items the VB code is
Dim m As New ContextMenu()
m.MenuItems.Add(New MenuItem("Disassociate *A* Device"))
m.MenuItems.Add(New MenuItem("Purge Device Assosciations"))
Is there no simple way to reference a resource to add an icon to said menuItems?
Pseudo
m.MenuItem(0).Icon.Source = ....
?
Assuming that this is for a Windows Forms application.
Why not use the ContextMenuStrip?
Example:
Dim m As New ContextMenuStrip()
Dim item As New ToolStripMenuItem("Click Me!")
item.Image = My.Resources.image
m.Items.Add(item)
DataGridView1.ContextMenuStrip = m
You will need to set Owner Draw to true and actually draw the menu item yourself
Here is a good detailed example
I use the image propery and assign a system.drawing.image object to it.
You wont be able to do it in one line, you do the add once all the properties of the newmenu is set.

ClickTag banner issues in Flash CS5

I've created some animated as well as static banners in Flash CS5 and I'd like to apply clickTag ActionScript 2.0 code to them. However, I only found tutorials where over all the existing layers, you create a rectangle using the Rectangle Primitive Tool, set the border, fill, and opacity to 0 and then apply the code and export the movie. When I create the rectangle, there is no setting for opacity, and when I set no border and no fill, the rectangle disappears and the dark dot in the timeline becomes empty so I can't click on the rectangle in order to convert it into a symbol.
I would really appreciate any advice on this!
Create your rectangle using 'Rectangle Primitive' tool shapes menu instead of the regular Rectangle tool.
select your rectangle by a single click.
From the properties panel select the bucket symbol (the one used to control the fill color) and you will find a setting 'alpha' for setting the transparency.
change the alpha value to 0. after that remove the stroke.
select your rectangle, from the top menu : Modify > Convert to symbol. give it a name and select 'button' from the dropdown. press ok.
now select the button you just created, open the actions panel and paste the following code :
on (release) {
if (clickTAG.substr(0, 5) == "http:")
{
getURL(clickTAG, "_blank");
}
}