creating a static vb.net "app" that consist of a single picture - vb.net

I need to create a vb.net program that consists of a unmovable, always on top bitmap, with no menu bar or anything, and does not show up in the task bar as program.
It needs to always start in the same place.
Essentially I need to mask a part of the screen by using a bitmap that blends into the scenery.
I am not sure which properties I need to tweak to achieve all of this.

Just to try changing the properties until you get the right result, but the below is probably sort of what you're looking for.
StartPosition = Manual
ShowInTaskBar = False
SizeGripStyle = Hide
TopMost = True
ControlBox = False
FormBorderStyle = None
Location = X, Y 'wherever it should be

Related

How to change the background color of a windows context menu using the winapi

I am currently trying to customize a context menu in Outlook. For the regulars I have had a series of issues which can be seen in this question and with this question.
I would like to adjust the background color a little.
Dim hBrush As IntPtr = NativeMethodsEX.CreateSolidBrush(ColorTranslator.ToWin32(System.Drawing.Color.Red))
Dim mi As New NativeMethodsEX.MenuInfo
With mi
.cbSize = Marshal.SizeOf(mi)
.fMask = NativeMethodsEX.MIM_STYLE Or NativeMethodsEX.MIM_BACKGROUND Or NativeMethodsEX.MIM_APPLYTOSUBMENUS
.dwStyle = NativeMethodsEX.MNS_NOCHECK
.hbrBack = hBrush
End With
NativeMethodsEX.SetMenuInfo(aHwnd, mi)
This code however produces this;.
How can I also change the background of the left hand side or what even is the class name of that part of the window. Also it has a border as well. What is its class name or how can I either remove it or change it?

RadioButtons Highlighting Incorrectly

On my form, I have 4 RadioButtons, each with its appearance set to Button. In my program, I change each of these RadioButton's ForeColour, BackColour and AutoCheck status, as below:
ARadioButton.AutoCheck = False
ARadioButton.BackColor = Color.FromKnownColor(KnownColor.ControlLightLight)
ARadioButton.ForeColor = Color.FromKnownColor(KnownColor.ControlDark)
However, later on, I reset these properties back to default:
ARadioButton.AutoCheck = True
ARadioButton.BackColor = DefaultBackColor
ARadioButton.ForeColor = DefaultForeColor
My issue is that instead of the entire button being highlighted, only the outside is, as shown in the images below.
Originally:
After changes are made and RadioButtons reset to default using code above:
I know this may seem trivial, but I would like the entire RadioButton to be highlighted when the user clicks on the RadioButton, not just the outside.
Is there a way I could somehow reset this?
Try setting the BackColor property to Color.Transparent

Reading input text through scrolled window?

I have created a scrolled window using pyGTK. When I type some text in the scrolled window,that typed text must be written in a file. I have a function which could write to the file. But as and when I go typing some text into the scrolled window that function must be called. If anyone suggest me the solution that would be very helpufull.
import glib, gtk
saveFilePath = 'textview.txt'
isChanged = True
def onBufferChanged(b):
global isChanged
isChanged = True
def onTimeout():
if isChanged:
text = textbuff.get_text(textbuff.get_start_iter(), textbuff.get_end_iter())
open(saveFilePath, 'w').write(text)
isChanged = False
return True ## Continue loop
textview = gtk.TextView()
textbuff = textview.get_buffer()
textbuff.connect('changed', onBufferChanged)
glib.timeout_add_seconds(1, onTimeout)
dialog = gtk.Dialog()
dialog.vbox.pack_start(textview, 1, 1)
dialog.vbox.show_all()
dialog.run()
You should subscribe to change event of text area were you type text and then schedule and execution of function that saves the text to file say each 1 second, so as you type your text would automatically saved. or you could have a background thread that monitors state of that control and save-s it regularly with 1 second delay so that. I think thread way is more correct

Color.ToArgb relation between 5046311 and 14221235?

the form backcolor is 14221235 , but when i set the customcolor in colordialog to equal the form backcolor, it sets it to 5046311 !!! what is the problem?
this is how i am getting the background color:
get_background = Str(Abs(Form1.BackColor.ToArgb))
the reason i am turning it into a string is because i will feed it into a string which has "32498239, 234234234, 23423234, 32234432432, 423324234"
then i take this string and put it in customcolors like this. btw this piece of code works fine:
Dim numberStrings = My.Settings.mytext1.Split(","c).Select(Function(x) x.Trim())
ColorDialog1.CustomColors = numberStrings.Select(Function(x) CInt(x)).ToArray()
a user below mentioned that toargb takes into account the opacity. this is an excellent point indeed, and i want to clarify that i DO NOT need the opacity. how would i do toargb without taking into opacity?
this is what you want
Microsoft.VisualBasic.RGB(Me.BackColor.R, Me.BackColor.G, Me.BackColor.B).ToString
The 32-bit result from .ToArgb() contains not just the three visible color components (red, green and blue) but also the alpha component, which is essentially opacity. This is a pure guess on my part, but I think the ColorDialog is just used for picking RGB values, so when you set the color to the form's BackColor, the dialog just ignores the alpha component (or sets it to zero), which is why you end up getting a different number from the .ToArgb() method.
Note: this is just speculation on my part. It would help if you posted a code sample that demonstrates the specific problem.
I don't really understand the question. You want to set the custom color dialog CustomColor property to (the form's backcolor) r + g + b components? Not sure why you would do that, you can always just get the form's backcolor, set the Alpha value to 255 and then set the result to the CustomColor property:
Color c = Color.FromArgb( 255, form1.BackColor );
myColorDlg.CustomColor = c;
Or just use form1.BackColor.ToArgb() & 0xFFFFFF (if you want the integer value).
If you are asking for ARGB (A = Alpha) then you are asking for the opacity information. Instead you could use the R, G, B Properties of Color Independently.
You could use Color.FromArgb(255, me.BackColor).ToArgb() in order to get the ARGB value of the same color with 100% opacity.
To highlight how to pass the same colour (Using Fredou's answer) from a colorDialog to set a pie chart segment colour, one which is a .Net embedded chart and the other an Excel chart:
embchartPie.Series(0).Points(Index).Color = ColorDialog1.Color
With ColorDialog1.Color
xl_Pie_Chart.SeriesCollection(1).points(Index + 1).format.fill.forecolor.rgb = RGB(.R, .G, .B).ToString
End With

Best way to combine Play and Pause button?

this is more of an advise thread I guess.
I've been wondering how one could create a button which display "play" when it's not pressed. And then shows "pause" once it's pressed. And visa versa when it's pressed again.
I had a similar problem when trying to create an expand panel button, but that was easy because I could just set a variable to true or false if PanelCollapsed was true.
But in this case I couldn't find any property in a button that I could query.
So I came up with this but I can't help thinking that this is a rather unsmart way of doing it?
If isPlay = True Then
If isPaused = False Then
btnPlay.Image = Image.FromFile("iconPause.png")
isPaused = True
isPlay = False
End If
GoTo Endline
End If
If isPlay = False Then
If isPaused = True Then
btnPlay.Image = Image.FromFile("iconPlay.png")
isPaused = False
isPlay = True
End If
End If
Endline:
How about using only one variable and code like this:
If isPlay Then
btnPlay.Image = Image.FromFile("iconPause.png")
else
btnPlay.Image = Image.FromFile("iconPlay.png")
End If
isPlay = not isPlay
You can use the "Tag" property. Its type is "object" so you can use any object you want, but in your case a string will do:
If Button1.Tag = "Pause" Then
Button1.Image = Image.FromFile("iconPlay.png")
Button1.Tag = "Play"
Else
Button1.Image = Image.FromFile("iconPause.png")
Button1.Tag = "Pause"
End If
Most .NET WinForm controls have a 'Tag' property (a button has one). You can set the Tag to be anything you want. An easy way to do this is to set the 'Tag' property to a boolean with the state of the button.
Just an idea...sure there are many other approaches.
UPDATE:
Otherwise, you can maintain the state of the button in your application as its own member variable. This might have several advantages because you can pass this state to other controls that might need it. The only weakness with this approach is that the state must be maintained separately.
If you have a fairly straight-forward implementation, use the Tag property.
A contrary opinion ...
... while other answers have given you some techniques to achieve your desired result, I'm going to ask you to reconsider your UI design.
Dual state buttons - ones that alternate purpose when clicked - can be a source of user frustation.
Here are two scenarios.
Scenario #1 ... if the users machine is under load (for any reason), there may be a perceptible delay between the users actual click on your button and when your click handler is executed.
Normally the time between click and handler is a few milliseconds or less, but it can run to several seconds. If this happens when the user clicks on a dual state button, they are likely to click the button again. Net effect, when the application catches up, is to toggle on, then immediately off again.
Scenario #2 ... many users habitually double click everything. Even experienced users who've been using computers for years may have this weird habit. When they try to press a dual state button, guess what happens ... the action toggles on, then immediately off again.
There are at least two solutions ...
Solution #1 ... use two buttons, one for "On", one for "Off".
Solution #2 ... write some debouncing code to suppress the effect of a second click if processed immediately (ie: < 75ms) after the first.
I don't personally use Visual Basic, but I do know that Buttons in Windows Forms have a property called 'Tag'. It is of the generic object type, so you can save whatever state you want, and just use casting to get the value back out.
How about using the "Image" property?
Rem form initialization
ImagePlay = Image.FromFile("iconPlay.png")
ImagePause = Image.FromFile("iconPause.png")
Button1.Image = ImagePlay
.
.
.
Rem on button1 click
If Button1.Image = ImagePlay Then
Button1.Image = ImagePause
Else
Button1.Image = ImagePlay
End If