|
I'd suggest that you forget about it for now. I still have no idea what you want. You want to write a control. I have no idea what it does, so all I can tell you is to derive from a base control class. It looks to me like you're a few steps short of knowing enough about software development to be thinking of writing anything.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I would like to know is there a way to have a script that will change the order of registry data?
What I need to have is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage\Bind
Which is REG_EXPAND_SZ type
I need to have \Device\NdisWanIp entry move to the top without modifying any of the other unique data lines.
Is this possible with WMI or any other type of scripting.
|
|
|
|
|
It's a REG_MULTI_SZ, not an expand type.
You'll have to read the string value that's stored into an array of strings, then reorder the array using standard array methods, and write then value back out. The WMI StdRegProv Provider will work with Multi_Sz values.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Trying to see if anyone can convert the code from Robert Rohde from C# into VB.net. This is an awsome kluge for the missing default view property in a file dialog box.
http://www.codeproject.com/cs/miscctrl/FileDialogExtender.asp?msg=1042669#xx1042669xx
Im really weak when it comes to this kind of programming. Looks like it should be fairly easy, and MANY people are looking for this it seems. Anyone feel like taking the adventure? I would love to see this thing work for me as a function or something.
Heck.. I'd settle for someone to walk me through making and calling the .dll too
Kudos to Robert Rohde!
David M. Levine
|
|
|
|
|
You found the easy way to do it. Try converting the code yourself. If you get stuck, search the web for C#/VB.NET translators. They're out there and their as easy to use as copying and psting sections of code, like a subroutine from one language to another.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I keep running into errors due to the preprocessor... namespace vs. class and whatnot.
|
|
|
|
|
I did not extensively test or refine this code. It works on my machine - Win2K NET 2002.
There is minimal error handling. I mostly just translated the original C# code referenced into VB.
This should get you started...
Robert
Extender Class Code:
*****************************************************************************************
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class CFileDialogExtender
Public Enum DialogViewTypes_enum
Icons = 28713
List = 28715
Details = 28716
Thumbnails = 28717
Tiles = 28718
End Enum
Private Const WM_COMMAND As Integer = 273
Private Const WM_ENTERIDLE As Integer = 289
Private m_hwndLastDialog As IntPtr
Private m_DialogViewType As DialogViewTypes_enum
Private m_fEnabled As Boolean
'Declaration for the FindWindowEx API
Private Declare Auto Function FindWindowEx Lib "user32" _
(ByVal hwndParent As IntPtr, _
ByVal hwndChildAfter As IntPtr, _
ByVal lpszClass As String, _
ByVal lpszWindow As String) _
As IntPtr
'Declaration for the SendMessage API. Note last parameter is declared as string
Private Declare Auto Function SendMessage Lib "user32" _
(ByVal hwnd As IntPtr, _
ByVal wMsg As Integer, _
ByVal wparam As Integer, _
ByVal lparam As String) _
As Integer
Public Property DialogViewType() As DialogViewTypes_enum
Get
DialogViewType = m_DialogViewType
End Get
Set(ByVal DialogViewType As DialogViewTypes_enum)
m_DialogViewType = DialogViewType
End Set
End Property
Public Property Enabled() As Boolean
Get
Enabled = m_fEnabled
End Get
Set(ByVal Enabled As Boolean)
m_fEnabled = Enabled
End Set
End Property
Public Sub WndProc(ByRef m As Message)
Dim RetVal As Integer = 0
Dim hwndChildAfter As IntPtr = IntPtr.Zero
If Not m_fEnabled Then
Exit Sub
End If
If (m.Msg = WM_ENTERIDLE) Then
Dim hwndDialog As IntPtr = m.LParam
If (hwndDialog.ToInt32 <> m_hwndLastDialog.ToInt32) Then
'get handle of the listview
Dim hwndListView As IntPtr = FindWindowEx(hwndDialog, hwndChildAfter, "SHELLDLL_DefView", "")
'send message to listview
'This will throw an error if the style is not supported on current OS!
'For example Win2k does not support "Tiles" view
Try
RetVal = SendMessage(hwndListView, WM_COMMAND, m_DialogViewType, 0)
Catch
'Do nothing
End Try
'remember last handle
m_hwndLastDialog = hwndDialog
End If
End If
End Sub
End Class
******************************************************************************************
Typical calling code:
******************************************************************************************
Public Class Form1
Inherits System.Windows.Forms.Form
'The FileDialogExtender object MUST be initialized because it processes messages
'from the forms WndProc override!
Private m_FileDialogExtender As New CFileDialogExtender()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ShowFileDialog()
End Sub
Private Sub ShowFileDialog()
Dim intResult As Integer
m_FileDialogExtender.Enabled = True
m_FileDialogExtender.DialogViewType = CFileDialogExtender.DialogViewTypes_enum.Icons
Dim oFileDialog As New OpenFileDialog()
Try
intResult = oFileDialog.ShowDialog
'If an error occurs it is because style is not supported
Catch
'Reset style to standard listview and show again
m_FileDialogExtender.DialogViewType = CFileDialogExtender.DialogViewTypes_enum.List
oFileDialog = New OpenFileDialog()
intResult = oFileDialog.ShowDialog
End Try
'Process dialog results here
MessageBox.Show(oFileDialog.FileName.ToString)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
m_FileDialogExtender.WndProc(m)
End Sub
End Class
******************************************************************************************
|
|
|
|
|
Absolutly awsome! Everything works like VB should have been in the first place. Thanks to all!
David M. Levine
:->
|
|
|
|
|
Does anyone know of a way to add a suffix to a vb variable based on another variables content?
I have a variable that is global named "LineNumber" and would like to append it to the end of a variable named "Line" in the Dim.
Exaple:
Private LineNumber as integer
private sub AddNumber()
dim Itm as new combobox
end sub
I would like to append the contents of "LineNumber" to the "Itm" name on the Dim statement.
regards
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
jose.hernandez@systems-programmer.com wrote:
know of a way to add a suffix to a vb variable based on another variables content
??? WHAT ???
Are you asking this:
Private LineNumber As Integer = 506
Private Sub AddNumber()
Dim Itm506 As New ComboBox
End Sub
You can't.
What are you really trying to do with this?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to use the contents of LineNumber as the last part of Itm name.... If the contents is 506 then I want my dim statement to say "Dim Itm506 as combobox"
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
First, you can't do that. Second, there is no reason to do this.
You really don't even need to keep an array of ComboBox controls. You can keep track of how many lines of controls your putting into the Panel's Controls collection. When you put a row of controls into the collection, you can set the ComboBox's Tag property to the line number it's on. You can then easily go through the Controls collection, looking for the control type and looking at each controls Tag property, matching it against the line number you need to delete.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave,
How do I tell which control to delete if they all have the same variable names? Below is my code:
Private Sub cmdAddLine_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAddLine.Click, cmdDeleteLine.Click
Panel1.AutoScrollPosition = New System.Drawing.Point(0, 0)
cbItem = New ComboBox
cbItem.BackColor = Color.Wheat
cbItem.Name = "cbitem" & LineNumber
cbItem.Font = New System.Drawing.Font("Comic Sans MS", 9, FontStyle.Regular)
cbItem.Size = New System.Drawing.Size(196, 19)
cbItem.Location = New System.Drawing.Point(0, LineNumber)
cbItem.Items.Add("A)
cbItem.Items.Add("B")
cbDiscount = New ComboBox
cbDiscount.BackColor = Color.Wheat
cbDiscount.Name = "cbDiscount" & LineNumber
cbDiscount.Font = New System.Drawing.Font("Comic Sans MS", 9, FontStyle.Regular)
cbDiscount.Size = New System.Drawing.Size(48, 19)
cbDiscount.Location = New System.Drawing.Point(cbItem.Size.Width + cbItem.Location.X, LineNumber)
cbDiscount.Items.Add("05% ")
cbDiscount.Items.Add("10% ")
cbDiscount.Items.Add("15% ")
cbDiscount.Items.Add("20% ")
cbDiscount.Items.Add("25% ")
cbDiscount.Items.Add("30% ")
cbDiscount.Items.Add("35% ")
cbDiscount.Items.Add("40% ")
cbDiscount.Items.Add("45% ")
cbDiscount.Items.Add("50% ")
txtAmount = New TextBox
txtAmount.BackColor = Color.Wheat
txtAmount.Name = "txtAmount" & LineNumber
txtAmount.Font = New System.Drawing.Font("Comic Sans MS", 9, FontStyle.Regular)
txtAmount.BorderStyle = BorderStyle.Fixed3D
txtAmount.Size = New System.Drawing.Size(56, 19)
txtAmount.Location = New System.Drawing.Point(cbDiscount.Size.Width + cbDiscount.Location.X, LineNumber)
txtQuantity = New TextBox
txtQuantity.BackColor = Color.Wheat
txtQuantity.Name = "txtQuantity" & LineNumber
txtQuantity.Font = New System.Drawing.Font("Comic Sans MS", 9, FontStyle.Regular)
txtQuantity.BorderStyle = BorderStyle.Fixed3D
txtQuantity.Size = New System.Drawing.Size(56, 19)
txtQuantity.Location = New System.Drawing.Point(txtAmount.Size.Width + txtAmount.Location.X, LineNumber)
txtSubTotal = New TextBox
txtSubTotal.BackColor = Color.Wheat
txtSubTotal.Name = "txtSubTotal" & LineNumber
txtSubTotal.Font = New System.Drawing.Font("Comic Sans MS", 9, FontStyle.Regular)
txtSubTotal.BorderStyle = BorderStyle.Fixed3D
txtSubTotal.Size = New System.Drawing.Size(56, 19)
txtSubTotal.Location = New System.Drawing.Point(txtQuantity.Size.Width + txtQuantity.Location.X, LineNumber)
txtTax = New TextBox
txtTax.BackColor = Color.Wheat
txtTax.Name = "txtTax" & LineNumber
txtTax.Font = New System.Drawing.Font("Comic Sans MS", 9, FontStyle.Regular)
txtTax.BorderStyle = BorderStyle.Fixed3D
txtTax.Size = New System.Drawing.Size(56, 19)
txtTax.Location = New System.Drawing.Point(txtSubTotal.Size.Width + txtSubTotal.Location.X, LineNumber)
txtTotal = New TextBox
txtTotal.BackColor = Color.Wheat
txtTotal.Name = "txtTotal" & LineNumber
txtTotal.Font = New System.Drawing.Font("Comic Sans MS", 9, FontStyle.Regular)
txtTotal.BorderStyle = BorderStyle.Fixed3D
txtTotal.Size = New System.Drawing.Size(55, 19)
txtTotal.Location = New System.Drawing.Point(txtTax.Size.Width + txtTax.Location.X, LineNumber)
Panel1.Controls.AddRange(New Control() {cbItem, cbDiscount, txtAmount, txtQuantity, txtSubTotal, txtTax, txtTotal})
cbItem.Focus()
LineNumber += 25
Console.WriteLine(cbItem.Name.ToString & " " & cbDiscount.Name.ToString & " " & txtAmount.Name.ToString & " " & txtQuantity.Name.ToString & " " & txtSubTotal.Name.ToString & " " & txtTax.Name.ToString & " " & txtTotal.Name.ToString)
end sub
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
You're so hooked on variable names... forget about them! They're meaningless in your case.
Think about it... How do programmers create thousands of objects with only a single set of variables? They use arrays, collections, hashes, ...
A single variable, in your case Panel.Controls, can hold a couple thousand controls. All you need is a way to identify the individual controls, not by a variable reference, but by an identifying number, the Tag property of each control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I understand all of what your saying. My question remains the same. How do I detemine which control to delete when the user clicks the delete a line button?
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
How are you letting the user select a line to delete?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Click a Delete Line button.............
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
I take it each line will have one of these buttons next to it? In that case, the button gets the same Tag value as the other controls on the line. When the user clicks on the Delete button, the button handling code checks the Tag property of the button that fired the event, then uses that Tag property to search through the Panel's Controls collection and find the controls that match that Tag ID.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the help....
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
Why not use an array or collection of combo-boxes, assuming that you are trying to keep track of multiple controls.
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
How would I go about naming the Combobox control?
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
jose.hernandez@systems-programmer.com wrote:
How would I go about naming the Combobox control?
You don't name the individual combobox, you create an array and then reference them by the line number. My VB.NET is a little rusty but basically,
<br />
Dim controlArray(3) As ComboBox<br />
<br />
controlArray(0) = New ComboBox<br />
controlArray(1) = New ComboBox<br />
controlArray(2) = New ComboBox
Then
controlArray(LineNumber).Text = "Hello"
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
Not sure that would work forr me. Here's what I'm trying to do:
I have a panel that goes across a form
In this panel I create a couple of combo boxes and some text boxes going across the panel.
Each time I create a line of these combo boxes and text boxes I use the same variable names
This works fine except I cant tell which line my user would like to delete because all of my variable names for the comboboxes and text boxes are the same.
So I chought if I could create a line counter and use it's contents in naming my variables for the comboboxes and text boxes that would help.
Is this possible in VB.Net?
Thanks
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
im assuming your going back in and using code to search for the proper controlls. in wich case just did you try changing the name property?
dim suffix as string
dim mybox as textbox = New textbox
suffix = 554
mybox.name = mybox.name & suffix
|
|
|
|
|
Thanks for the help.........
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|