|
how to use vb.net changing the registry of HKEY_CURRENT_USER "Control panel\colors" for each color?
Thank you.
Beginner
|
|
|
|
|
All of the values in that key are merely strings that represent RGB values to build a color. The first number in each string is the Red component, in the range 0 to 255. The second number is Green and the thrid number is Blue. ALl you have to do is build a string with those numbers and update the value in the registry.
You can learn more about using the Registry and RegistryKey classes here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you very much.
if i use this function to run that always hava an error message:
RegCreateKeyEx(HKEY_CURRENT_USER, "Control Panel\Colors", 0, vbNullString, _
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, vbNullString, hKey, 0)
error message:
Additional information: Error: PInvoke item (field,method) must be Static.
how to fix the problems? or use the different the funcutions?
Thanks.
-- modified at 14:22 Monday 18th September, 2006
Beginner
|
|
|
|
|
Why are you P/Invoking Win32 functions when the Registry and RegistryKey classes already do all this for you?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you very much...
I use this two lines coding that works very well.
regKey = Registry.CurrentUser.OpenSubKey("Control Panel\Colors", True)
regKey.SetValue(StrSysColor(i), colorStr)
Beginner
|
|
|
|
|
Not sure if this is best forum but...
I am trying to convert somebody elses old C component into a VB.NET version and in the process add some more functionality. Silly me... I don't know any C at all but having an educated guess. This following bit has me stumped. Can anybody help with the conversion.
<br />
protected void onMenuItemClick(Object sender, EventArgs e) {<br />
MenuItem item = (MenuItem)sender;<br />
if (MRUItemClicked != null) {<br />
string fileName = (string)_itemMap[item];<br />
MRUItemClicked(this, new MRUItemClickedEventArgs(fileName));<br />
}<br />
}<br />
Cheers
Tim
|
|
|
|
|
This is obviously not C code, do you mean C# ? This code is C#.
This is an event handler for a menu item click. It converts the senser to a MenuItem, which is what it is. MRUItemClicked is obviously a member variable, null is called Nothing from memory in VB land.
_itemMap is obviously a dictionary/hash table member variable.
MRUItemClicked appears to be a delegate.
Which of those things do you not understand ? Do you know what a delegate is ? I assume you have _itemMap set up from converting the rest of the code ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Probably this:
Protected Sub onMenuItemClick(ByVal sender As Object, ByVal e As EventArgs)<br />
Dim item As MenuItem = CType(sender,MenuItem)<br />
If (Not (MRUItemClicked) Is Nothing) Then<br />
Dim fileName As String = CType(_itemMap(item),String)<br />
MRUItemClicked(Me, New MRUItemClickedEventArgs(fileName))<br />
End If<br />
End Sub
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
dr1='8/16/06'
dr2='11:45'
finalstring = dr1 & " " & dr2
How to convert this string to date? Tried::
DateTime.Parse(finalDateString)
Resulting in error - String was not recognized as a valid DateTime.
Thanks.
-- modified at 10:03 Monday 18th September, 2006
|
|
|
|
|
What is the date 8/16/20? Did you try 8/16/2006?
|
|
|
|
|
Sorry - that was a typo - corrected it!
But bascially want to convert STRING to DATE!
Thanks.
|
|
|
|
|
It doesn't recognise the string as a date because it expects the format of the current culture. Specify the culture you want to use in the call to Parse.
---
b { font-weight: normal; }
|
|
|
|
|
|
Hi
I design a component and I want to add prperty that suport Collection Editor by my own properties.
How should I implemet this property?
Thanks
Qofrani
|
|
|
|
|
Hi
I solved my problem by myself but I have another one.
When I set my control properties every thing is ok but after I run my project I lose my colllection properties value.
How can I solve this problem please help me.
Here is my code :
<br />
Imports System<br />
Imports System.ComponentModel<br />
Imports System.Drawing<br />
Imports System.Drawing.Design<br />
Imports System.ComponentModel.TypeConverter<br />
<br />
'My properties class<br />
Public Class ToolBoxItem<br />
<br />
#Region "Properies"<br />
<br />
Private m_IName As String<br />
<br />
Private m_Value As Integer<br />
<br />
Public Property IName() As String<br />
Get<br />
<br />
Return m_IName<br />
<br />
End Get<br />
Set(ByVal Value As String)<br />
<br />
m_IName = Value<br />
<br />
End Set<br />
End Property<br />
<br />
Public Property Value() As Integer<br />
Get<br />
<br />
Return m_Value<br />
<br />
End Get<br />
Set(ByVal Value As Integer)<br />
<br />
m_Value = Value<br />
<br />
End Set<br />
End Property<br />
<br />
#End Region<br />
<br />
End Class<br />
<br />
<br />
'My collection class<br />
Public Class ToolBoxItemCollection<br />
<br />
Inherits CollectionBase<br />
<br />
Public Sub Add(ByVal MyItem As ToolBoxItem)<br />
<br />
list.Add(MyItem)<br />
<br />
End Sub<br />
<br />
Public Sub Remove(ByVal index As Integer)<br />
<br />
If index > Count - 1 Or index < 0 Then<br />
<br />
System.Windows.Forms.MessageBox.Show("Index not valid!")<br />
<br />
Else<br />
<br />
List.RemoveAt(index)<br />
<br />
End If<br />
<br />
End Sub<br />
<br />
<br />
Public ReadOnly Property Item(ByVal index As Integer) As ToolBoxItem<br />
Get<br />
<br />
Return CType(List.Item(index), ToolBoxItem)<br />
<br />
End Get<br />
<br />
End Property<br />
<br />
End Class<br />
<br />
'My control class<br />
Public Class ToolBox<br />
<br />
Inherits GroupBox<br />
<br />
Private m_Items As ToolBoxItemCollection<br />
<br />
Private m_Count, m_ItemWidth, m_ItemHeight As Integer<br />
<br />
<br />
Public Property Items() As ToolBoxItemCollection<br />
Get<br />
<br />
Return m_Items<br />
<br />
End Get<br />
Set(ByVal Value As ToolBoxItemCollection)<br />
<br />
m_Items = Value<br />
<br />
End Set<br />
End Property<br />
<br />
<br />
Public Property Items(ByVal Index As Integer) As ToolBoxItem<br />
Get<br />
Return m_Items.Item(Index)<br />
<br />
End Get<br />
Set(ByVal Value As ToolBoxItem)<br />
<br />
m_Items.Add(Value)<br />
<br />
End Set<br />
End Property<br />
<br />
Public Sub New()<br />
<br />
MyBase.New()<br />
<br />
Me.Dock = DockStyle.Right<br />
<br />
Me.BackColor = SystemColors.ControlDarkDark<br />
<br />
Me.Text = ""<br />
<br />
Me.Width = 100<br />
<br />
If m_Items Is Nothing Then<br />
<br />
m_Items = New ToolBoxItemCollection<br />
<br />
End If<br />
<br />
End Sub<br />
<br />
<br />
End Class<br />
<br />
Thanks
Qofrani
|
|
|
|
|
I've got what I'm sure is a trivial question. I want to draw a graph in Visual Basic on an object on a form.
I would like to know what is the best object to use. I tried a panel as my first choice but in the properties I couldn't find something which would override the OnDraw and let me draw my own things.
There must be a standard way to do this, but I don't use VB much so I'm not familiar with it.
Thanks,
Ilan
|
|
|
|
|
A Panel can be used, or a PictureBox. Either is good. You override the Paint method of the control you use. For example:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles PictureBox1.Paint
Dim g As Graphics = e.Graphics
' do your painting for the control
End Sub
Another way to do it, would be to draw to a Bitmap image and just set the PictureBox Image or Panel BackgroundImage property to the Bitmap you've drawn on.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I was about to ask you where to put that private sub, when I looked again at the properties and again found nothing. Then I double clicked on the pane and voila, the paint proceedure appeared!
Sometimes things are so easy that I miss the truely obvious.
Your Dim g as graphics would have been my next question, but you answered it. My only mistake was to put a semicolon at the end of the statement (habit is a hard thing to break).
Thanks,
Ilan
|
|
|
|
|
If you switch to code view, just above the window you'll find two dropdown boxes next to each other. Pick the control you want to handle an event for in the left side box, then pick the event/method/property you want to handle/override in the right side box. This will automatically create an empty event handler in your code, complete with the correct event header.
You can also do the same thing with the Property window. Near the top of that window there is a small button with a little yellow lightning bolt in it. If it doesn't show up, click on the control you want in the designer, or pick it from the dropdown list just above the Properties window. When you click on that lightning bolt, the Properties window will switch to showing all the events exposed by that control. Find the event you want, then double-click in the white box to it's right and it'll create an empty event handler for you.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Great! I found it in the code view. Now that I know where it exists I'm in business.
I don't see the lighting in the properties page. I'm used to using it all the time in c++, but I don't see it in Visual Basic. In fact, since I'm used to it in c++, this was the place I was looking.
Never mind, so long as I know it exists in the code view, I'm in business. It does the dirty work of building the proper templates so they are right the first time around.
Thanks again,
Ilan
|
|
|
|
|
|
I wanted to reinvent the wheel only enough to learn how to do something should I have to do so. Thus I tried Dave's suggestion to get a feel for things.
Enough reinventing the wheel, and I will have a longer look at the ZedGraph. Presently it seems I have NET 1.1 so I can't use the latest version 5.0. (I have Visual Studio 2003 and don't want to update just for this.)
Thanks,
Ilan
|
|
|
|
|
As you are most probably already aware, but I wasn't certain so I thought I would just say, you can download version 4.3.5 from the SourceForge project site[^] which works with .NET 1.1.
|
|
|
|
|
Alex,
I am really impressed. I want to thank you for pointing out the code to me. I was just thinking of making a simple graph with some text and wanted to avoid reinventing the wheel.
This isn't a wheel but the whole automobile! I see I can use it in c++, so I'll use it there as well.
My trivial question in Visual Basic turned out to a super answer.
Ilan
|
|
|
|
|
Hi guys,
I'm currently working on how to lock or at least hide a certain folder,
below are the codes that i'm tryin to use...
renameFileName = (InputBox("Folder Name:", "Unlock", "Cycle #"))
System.IO.Directory.Move(path & "\.{20D04FE0-3AEA-1069-A2D8-08002B30309D}", path & "\" & renameFileName)
thing is, its working on my local folders, but when i used it to a folder on a mapped drive its just renaming it, and i still can access the folder...
if you guys got another approach on how to do this...
tnx in advance.
-::maximus::-
|
|
|
|