|
Hi all,
I would like to change the color of a form in VB 6.0. Is there any WIN32 API function or any other Visual Basic function which gets the form handle and changes the color of the form.
Just setting form.backcolor does not help as they do not change the color of other controls and menus. I would like change the default color of the whole form.
Pls reply asap.
Thanks,
Sugan
|
|
|
|
|
V.Sugan wrote: Is there any WIN32 API function or any other Visual Basic function which gets the form handle and changes the color of the form.
No, not the way your describing. You can get the handle of the Form's window from the Form's hWnd property. But, there is no function to change the Form's color using that handle, or anything else. Each element is repsonsible for its own color.
V.Sugan wrote: Just setting form.backcolor does not help as they do not change the color of other controls and menus
Of course not! You have to change the colors of the controls yourself.
The menus on the forms, by design, follow the colors layed out in the Display Control Panel. If you want to change them, you'll have to owner-draw the menus. You can find out more abou this from Google[^].
As for the controls, if you didn't specify a ForeColor or BackColor, they'll use default values. If they don't have BackColor and/or ForeColor properties, they'll use the colors specified in the Desktop Control Panel.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You should be able to chang it in the properties windom
|
|
|
|
|
That will not do what he wants. The properties window just exposes the same properties you get at runtime, but at design time.
He's looking to change the colors of everything in one function call. That just doesn't exist, unless he writes the function to iterate through all his controls to do it for him.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Im using VB 6.0 True DBGrid. I want to change the back color of some rows depending on the condition. For example, if if a row contains value 1 in one of its column then its back color would b red and other rows remain with the same default color.
Thanx
Noshaba Mariam
|
|
|
|
|
The best place to find out about that would be ComponentOne's Support[^] page.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanx for the reply but............
Sorry I couldn't b able to get what I exactly want from the page u suggested.
|
|
|
|
|
So posting a question in their Support Forums doesn't get you what you need?
Do you think you'll get a better response from a forum that doesn't support the product? It's very unlikely, simply because we can't support every control out there. There's thousands of them!
You'd be much better off posting this question in their forums, where people who use the controls, support them, and even write them, tend to congregate.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi All,
I am getting an error: Invalid object 'TABLE NAME' when trying to upload an image to a database.
below are my codes on upload button click event
-----
Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Dim sizeofFile As Integer = fileUpload.PostedFile.ContentLength
objConn = New SqlConnection(dbPath)
cmd = New SqlCommand("insert into UserImage(Bits, Description,UserId, UploadTime, ImageSize, Mime) values " & _
"(@Bits, @Description, @UserId, @UploadTime, @ImageSize, @Mime)", objConn)
Dim p1, p2, p3, p4, p5, p6 As SqlParameter
p1 = cmd.Parameters.Add("@Bits", SqlDbType.Image)
p2 = cmd.Parameters.Add("@Description", SqlDbType.NVarChar)
p3 = cmd.Parameters.Add("@UserId", SqlDbType.Int)
p4 = cmd.Parameters.Add("@UploadTime", SqlDbType.DateTime)
p5 = cmd.Parameters.Add("@ImageSize", SqlDbType.Int)
p6 = cmd.Parameters.Add("@Mime", SqlDbType.NVarChar)
p1.Value = GetImageBits(fileUpload.PostedFile.InputStream, sizeofFile)
p2.Value = "caption"
p3.Value = 1
p4.Value = DateTime.Now
p5.Value = sizeofFile
p6.Value = fileUpload.PostedFile.ContentType
objConn.Open()
Response.Write(cmd.CommandText + " ")
cmd.ExecuteNonQuery()
objConn.Close()
End Sub
Private Function GetImageBits(ByVal fs As Stream, ByVal size As Integer) As Byte()
Dim img(size) As Byte
fs.Read(img, 0, size)
Return img
End Function 'GetImageBits
-----
I thought it could just be the mismatch of table name or column name but its not.
below are my database table query.
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[UserImage]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[UserImage]
GO
CREATE TABLE [dbo].[UserImage] (
[Bits] [image] NULL ,
[Description] [nvarchar] (300) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[UserId] [int] NULL ,
[UploadTime] [datetime] NULL ,
[ImageSize] [int] NULL ,
[Mime] [nvarchar] (300) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
I tried hard but couldnt figure out please help. thanks in forward.
cheers
robin
|
|
|
|
|
foremorecoast1 wrote: objConn = New SqlConnection(dbPath)
What does dbPath contain? Perhaps it is incorrect?
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
(Translation: I'll show you the way, but not write the code for you.)
|
|
|
|
|
AWwwwwwwwwwwwwwwwww.
my bad. hehe it was pointing to wrong database. thanks
very much never thought about that.
cheers
robin
|
|
|
|
|
Hi All,
I have posted this like hundred times and i seem to get no response from any. i am again refining my question hope that makes clear.
I have a data repeater in my webpage. which basically queries 3 tables and combines and repeats accordingly. but what i have in one table is a statatistical data like
id estimated actual year
1 20 18 2003-2004
1 23 21 2003-2004
1 24 14 2005-2006
2 20 24 2003-2004
2 15 29 2003-2004
2 16 14 2004-2005
3
4
7
etc.
missing IDs are present in other TABLES just not in statistical table.
i need to create individual chart for id 1 for year 2003-2004 and year 2005-2006 and so on for id 2 and so forth.
i can create once chart based upon a single table but its like a quering a table and based upon parameter i need to create new dataset and bind it to some web chart control.
the data should be presented something like this in a repeater.
Head information related to ID 1 from table 1
sub head description related to ID 1 from table 2
a chart for ID 1 of year 2003-2004 and a chart for ID 1 of year 2005-2006
(if no data present dont display chart). please note year field is only a string.
so on for other IDs.
Please help how to achieve this or do you know any Software that does this so that i can simply purchase this software.
thanks
Robin
|
|
|
|
|
You were told, back on March 2nd, and beyond, how to do this.
Create a SELECT to return all the UNIQUE ID's in your table. Then, you have to load your data into a DataTable. Create a DataView to filter out the records for a specific ID, one for each ID you retrieve. Then, you create and bind your chart to the data in the DataVIEW, not the table. Repeat this for each ID...
Asking this question 8 more times will not change the answer.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I've got a problem with my custum datagridcolumnstyles. As soon as I sort on a column with a custom column style after I have selected a different row, the code redraws a label(which is the columnstyle in the attached code snippet) the size of the entire grid. Also when changing the readonly status of the datagrid the datagrid seems to "freeze". I am probably missing something, but I am not sure what. Any suggestions? The attached code is converted from C# to vb so there might be some error there.
Thanks
David
Public Class clDTRDataGridLabelColumn
Inherits DataGridColumnStyle
Private lb As New Label
' The isEditing field tracks whether or not the user is
' editing data with the hosted control.
Private isEditing As Boolean
Public Sub New()
lb.Visible = False
lb.Dock = DockStyle.Fill
Me.NullText = ""
'tb.Height = 27
End Sub
Protected Overrides Sub Abort(ByVal rowNum As Integer)
isEditing = False
RemoveHandler lb.TextChanged, _
AddressOf lbtextChanged
Invalidate()
End Sub
Protected Overrides Function Commit _
(ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) _
As Boolean
lb.Bounds = Rectangle.Empty
AddHandler lb.TextChanged, _
AddressOf lbtextChanged
If Not isEditing Then
Return True
End If
isEditing = False
Invalidate()
Return True
End Function
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean, _
ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
Dim value As String
If cellIsVisible Then
lb.Text = value
lb.Visible = True
AddHandler lb.TextChanged, _
AddressOf lbtextChanged
Else
lb.Text = value
lb.Visible = False
End If
If lb.Visible Then
DataGridTableStyle.DataGrid.Invalidate(bounds)
End If
End Sub
Protected Overrides Function GetPreferredSize( _
ByVal g As Graphics, _
ByVal value As Object) As Size
Return New Size(100, lb.PreferredHeight)
End Function
Protected Overrides Function GetMinimumHeight() As Integer
Return lb.PreferredHeight
End Function
Protected Overrides Function GetPreferredHeight(ByVal g As Graphics, ByVal value As Object) As Integer
Return lb.PreferredHeight
End Function
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer)
Paint(g, bounds, [source], rowNum, False)
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal alignToRight As Boolean)
Paint(g, bounds, [source], rowNum, Brushes.Red, Brushes.Blue, alignToRight)
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
Dim str As String
Dim rect As Rectangle = bounds
If Not GetColumnValueAtRow([source], rowNum) Is DBNull.Value Then
str = CType(GetColumnValueAtRow([source], rowNum), String)
Else
str = ""
End If
If rowNum = Me.DataGridTableStyle.DataGrid.CurrentRowIndex Then
backBrush = New SolidBrush(Me.DataGridTableStyle.SelectionBackColor)
End If
g.FillRectangle(backBrush, rect)
rect.Offset(0, 0)
g.DrawString(str, Me.DataGridTableStyle.DataGrid.Font, foreBrush, RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))
Console.WriteLine(bounds.Width & " " & bounds.Height & " " & Me.HeaderText)
End Sub
Protected Overrides Sub SetDataGridInColumn(ByVal value As DataGrid)
MyBase.SetDataGridInColumn(value)
If Not (lb.Parent Is Nothing) Then
lb.Parent.Controls.Remove(lb)
End If
If Not (value Is Nothing) Then
value.Controls.Add(lb)
End If
End Sub
Private Sub lbtextChanged(ByVal sender As Object, ByVal e As EventArgs)
Me.isEditing = True
MyBase.ColumnStartedEditing(lb)
End Sub
End Class
Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
|
|
|
|
|
I am creating a custom winform control that extends the TreeView control.
One property I am adding is a collection.
I have tried to follow some outlines of other controls that allow the editing of the collection at design-time and have those edits persist in your form.
Code to create my collection objects is being added to the form Initialize code. The collection item properties are being set correctly in this code also.
But, code is not being created that adds the collection item to the parent controls collection.
Can someone provide a quick, abbreviated checklist for things that must be done to be sure the designer creates all the code required in the form initialize block?
Thank You,
Any Takers On This Item??????
Rhorc
-- modified at 19:05 Thursday 9th March, 2006
|
|
|
|
|
I have a program that stores passwords and after logging in, I would like to close the main page and show the page that has the passwords. I can show the second page but I cannot get the main page. Can anyone help? Thanks.
|
|
|
|
|
I tested this in VB.Net 2005, but I don’t know if it works in VB.Net 2003
Here, you cannot close the form, but you can hide it like this
Dim frm2 As New frmSecondForm<br />
frm2.Show()<br />
Me.Hide()
For the second form
Me.Hide()<br />
Dim frm1 As New frmFirstForm<br />
frm1.Show()
If you like to disable the main form while you work with the second form. You can use
Dim frm2 As New frmSecondForm<br />
frm2.ShowDialog()
If you use VB.Net 2005
frmSecondForm.Show()<br />
Me.Hide()
For the second form
frmFirstForm.Show()<br />
Me.Hide()
If you like to disable the main form while you work with the second form. You can use
frmSecondForm.ShowDialog()
chatura
|
|
|
|
|
I need to design a simple program. There are two databases on seperate computers and they need to have the same data. I need to have the program keep each database up to date with each other. Any ideas? Thanks in advance.
|
|
|
|
|
Depends which database engine you are using, but I'd look at the native support built into most db's these days to provide this functionality without programming effort. (I'm talking about SQL Server, Oracle etc - not Access.)
You could use log shipping, transactional replication, or a number of other methods - all controlled by the db engine itself. You'll need to look at the db's doc to find out what sort it provides.
...Steve
quod erat demonstrandum
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
Hi, I was wondering if anyone out there might be able to help me with the removal of the selectedindexchanged event from a custom combobox? I have created a custom combobox control and have the keyevents calling a method that will reset the selectedIndex changed event to 0, and then to -1. I do this because visual studio 2003 seems to have problems setting the combobox index to -1. In that method, I need to shut down the index changed event so that the event is activated only once when the index is changed, but I do not know how exactly I can remove the handler/disable the event within a custom control that inherits from the combobox. Anyhelp would be greatly appreciated. Thank you and have a nice day.
Code: -not working
'delegate declaration?
Shadows Event SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
'Handling event
Protected Overrides Sub OnSelectedIndexChanged(ByVal e As System.EventArgs)
MyBase.OnSelectedIndexChanged(e)
End Sub
'Reset Index
Public Sub resetIndex()
RemoveHandler SelectedIndexChanged, AddressOf OnSelectedIndexChanged
Me.SelectedIndex = 0
AddHandler SelectedIndexChanged, AddressOf OnSelectedIndexChanged
Me.SelectedIndex = -1
End Sub
eatwork
eatwork
|
|
|
|
|
I'm done with my browser and things are working very nicely, thanks to a lot of advice from the people here. My next project is a chat system but I'm not sure which approach would be best to take. I want to making the main application, that will nest all these other projects of mine (Browser, chat, ect), as peer-to-peer as possible in order to avoid as much server usage. I know that it will be unavoidable in certain cases but it is my ultimate goal. I've seen many examples on this site on chat systems but I'm not quite sure as to which is best. Any suggestions as to which type of system/approach would be best for this chat project of mine?
Any thoughts would be greatly appreciated.
Thanx
-- modified at 19:46 Tuesday 7th March, 2006
|
|
|
|
|
Hello
Check the path of the file in the OLEDBConnection of your project.
-- modified at 11:59 Tuesday 7th March, 2006
|
|
|
|
|
Hi,
When I lookin under "My Project", Settings, the value for my db connection is as follows:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\dbSpringBook.mdb
Is this not correct for deployment, as the app should find where the .mdb file?
|
|
|
|
|
Ok
I don´t know what you mean by |DataDirectory|
but what you can try is:
Dim DatabasePath as string
DatabasePath=Application.StartupPath & "\dbSpringBook.mdb
"
Then
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabasePath
Put the database in the same path of your executable file.
Hope it helps
-- modified at 12:36 Tuesday 7th March, 2006
|
|
|
|
|
Hi,
I have included the database file in the same path as my executeable, but when I run the Publish Wizard in visual studio, and then execute the setup wizard on another computer, it still cannot find the database file.
Any other suggestions?
|
|
|
|
|