|
Hi
If you are using the winsock activex control then you need to build some optimizations around your server and client apps. You will find that if you use the SendData sub routine you will have to send data in packets each around 512 to 2048 bits in size and also delay the packets until the SendComplete() event is called each time.
};
|
|
|
|
|
anybody know how to call a form using keyboard key like F3.
and also how to pass a value from a form to a textbox of other form in vb.net.
|
|
|
|
|
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown<br />
If e.KeyCode = Keys.F3 Then<br />
Dim f As New Form2<br />
f.Show()<br />
e.Handled = True<br />
End If<br />
End Sub
Here Form1 is a form having the KeyDown EventHandler and Form2 is just another form.
This code will not work if your Form1 has controls like Textbox and the TextBox control has focus, because the default value of the KeyPreview of Form is False. In order to make working of F3 even the TextBox has focus, You have to set the KeyPreview property to True.
I think this will solve your problem.
|
|
|
|
|
The following will demonstrate passing a value from one form to another.
I have Form1 class with KeyPreview property set to True and class variable of type Form2 which has a TextBox and a Public Property to get or set the TextBox Text. The Form1 class has three EventHandler which will be helpful for getting the Form2 class TextBox Text.
Add the following to the Form1.
Private f As Form2
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
f = New Form2
AddHandler f.Closing, AddressOf SetTextBox
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.F3 Then
f.Show()
e.Handled = True
End If
End Sub
Private Sub SetTextBox(ByVal sender As Object, ByVal e As CancelEventArgs)
If f.TextBoxText.Trim.Length < 1 Then
MessageBox.Show("Type some text in TextBox")
Else
Me.TextBox1.Text = f.TextBoxText
f.TextBoxText = ""
f.Hide()
End If
e.Cancel = True
End Sub
Add the following to the Form2
Public Property TextBoxText() As String
Get
Return Me.TextBox1.Text
End Get
Set(ByVal Value As String)
Me.TextBox1.Text = Value
End Set
End Property
In the Form1 pressing F3 will open the Form2 and when Form2 is closed the TextBox text of Form2 will be set to Form1 TextBox.
I hope this will do.
|
|
|
|
|
I am trying to get word document title and number of word in the document
Currently, I can only get these properties from opening the document.
Is there any way to get these information without actually opening the word
document.
Shin
|
|
|
|
|
No, there isn't. You have to open the document. From what I can see in the file format, those properties are not stored in the file.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you for your input,
This is the way to get the document property
Is there any way to open the word document silently?
The source code below is not working.
wordApp.Documents.Open strFileName
wordApp.Visible = False
VB6/Windows2000
Shin
|
|
|
|
|
I found a solution. the dll dsofile.dll
was availble for getting office document
properties with out open. I downloaded and
used from kb. Thank you.
Shin
"Microsoft Knowledge Base Article - 224351 "
Dim oFilePropReader As DSOleFile.PropertyReader
Dim oDocProp As DSOleFile.DocumentProperties
Set oFilePropReader = New DSOleFile.PropertyReader
Set oDocProp = oFilePropReader.GetDocumentProperties(strFileName)
Debug.print oDocProp.Title
'display the title of document
set oFilePropReader = nothing
|
|
|
|
|
how to display a word file as another application on a button click event
www
|
|
|
|
|
Use the Process and ProcessStartInfo classes in your button Click event handler to launch the .DOC file:
Dim procStartInfo As New ProcessStartInfo(fullPathToWordDOCFile)
procStartInfo.UseShellExecute = True
Process.Start(procStartInfo)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, I'm a vb6 programmer. I prefer to use vb6 to connect to the database. I like to use DAO when connec to the database in Ms Access. But I need some people help me to do the following thing:
1. Give me a sample code with step by step explaination on using ADO to connect to the database without using using ADO data control.
2. Give me a sample code with step by step explaination on using VB.NET and ADO.NET to connect to the database without using using SqlDataAdapter, OleDbDataAdapter and the other control.
Note: If you can explain each function of these control (such as OleDbDataAdapter, OleDbConnection, OleDbCommand...) and the procedue to use it, it would be better.
Sometime I read from the books in the section of database system but it seem that the books is not explain too much clear.
Please help me!!!
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi,
I'm trying to build a little service that can read mail from my pop3 server and inject then to my exchange server.
I've found a little DLL that can read pop3 mail but I need to rebuild all the message and resend it after via SMTP.
My question, is there already some DLL that can be used to send mail to exchange directly and to retrieve the pop3 mail directly in a good format
Thx
Sybux
|
|
|
|
|
Hi,
Can anyone tell me is this possible.....
I want to fill the DataGrid. I have 5 columns selected in the Query using Joins from 2 Tables.
I want to Fill the Datas in the Grid along with it, add 2 more columns to be added in the Grid, but the 2 added columns should be used as Date Picker.
This is for VB.NET application. and it is a Very urgent task to Complete.
pls help me out in doing this Task.
(Note: I'm NEW to .NET)
Thanx and Regards,
Tthangaraj P.V.
tthangarajpv@yahoo.com
|
|
|
|
|
Hi,
There is a great sample for doing this in MSDN. I am just giving it.
Imports System<br />
Imports System.Data<br />
Imports System.Windows.Forms<br />
Imports System.Drawing<br />
Imports System.ComponentModel<br />
<br />
' This example shows how to create your own column style that<br />
' hosts a control, in this case, a DateTimePicker.<br />
Public Class DataGridTimePickerColumn<br />
Inherits DataGridColumnStyle<br />
Private timePicker As New DateTimePicker()<br />
' The isEditing field tracks whether or not the user is<br />
' editing data with the hosted control.<br />
Private isEditing As Boolean<br />
<br />
Public Sub New()<br />
timePicker.Visible = False<br />
End Sub<br />
<br />
Protected Overrides Sub Abort(ByVal rowNum As Integer)<br />
isEditing = False<br />
RemoveHandler timePicker.ValueChanged, _<br />
AddressOf TimePickerValueChanged<br />
Invalidate()<br />
End Sub<br />
<br />
Protected Overrides Function Commit _<br />
(ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) _<br />
As Boolean<br />
timePicker.Bounds = Rectangle.Empty<br />
<br />
AddHandler timePicker.ValueChanged, _<br />
AddressOf TimePickerValueChanged<br />
<br />
If Not isEditing Then<br />
Return True<br />
End If<br />
isEditing = False<br />
<br />
Try<br />
Dim value As DateTime = timePicker.Value<br />
SetColumnValueAtRow(dataSource, rowNum, value)<br />
Catch<br />
End Try<br />
<br />
Invalidate()<br />
Return True<br />
End Function<br />
<br />
Protected Overloads Overrides Sub Edit( _<br />
ByVal [source] As CurrencyManager, _<br />
ByVal rowNum As Integer, _<br />
ByVal bounds As Rectangle, _<br />
ByVal [readOnly] As Boolean, _<br />
ByVal instantText As String, _<br />
ByVal cellIsVisible As Boolean)<br />
Dim value As DateTime = _<br />
CType(GetColumnValueAtRow([source], rowNum), DateTime)<br />
If cellIsVisible Then<br />
timePicker.Bounds = New Rectangle _<br />
(bounds.X + 2, bounds.Y + 2, bounds.Width - 4, _<br />
bounds.Height - 4)<br />
<br />
timePicker.Value = value<br />
timePicker.Visible = True<br />
AddHandler timePicker.ValueChanged, _<br />
AddressOf TimePickerValueChanged<br />
Else<br />
timePicker.Value = value<br />
timePicker.Visible = False<br />
End If<br />
<br />
If timePicker.Visible Then<br />
DataGridTableStyle.DataGrid.Invalidate(bounds)<br />
End If<br />
End Sub<br />
<br />
Protected Overrides Function GetPreferredSize( _<br />
ByVal g As Graphics, _<br />
ByVal value As Object) As Size<br />
Return New Size(100, timePicker.PreferredHeight + 4)<br />
End Function<br />
<br />
Protected Overrides Function GetMinimumHeight() As Integer<br />
Return timePicker.PreferredHeight + 4<br />
End Function<br />
<br />
<br />
Protected Overrides Function GetPreferredHeight(ByVal g As Graphics, ByVal value As Object) As Integer<br />
Return timePicker.PreferredHeight + 4<br />
End Function<br />
<br />
<br />
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer)<br />
Paint(g, bounds, [source], rowNum, False)<br />
End Sub<br />
<br />
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)<br />
Paint(g, bounds, [source], rowNum, Brushes.Red, Brushes.Blue, alignToRight)<br />
End Sub<br />
<br />
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)<br />
Dim [date] As DateTime = CType(GetColumnValueAtRow([source], rowNum), DateTime)<br />
Dim rect As Rectangle = bounds<br />
g.FillRectangle(backBrush, rect)<br />
rect.Offset(0, 2)<br />
rect.Height -= 2<br />
g.DrawString([date].ToString("d"), Me.DataGridTableStyle.DataGrid.Font, foreBrush, RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))<br />
End Sub<br />
<br />
Protected Overrides Sub SetDataGridInColumn(ByVal value As DataGrid)<br />
MyBase.SetDataGridInColumn(value)<br />
If Not (timePicker.Parent Is Nothing) Then<br />
timePicker.Parent.Controls.Remove(timePicker)<br />
End If<br />
If Not (value Is Nothing) Then<br />
value.Controls.Add(timePicker)<br />
End If<br />
End Sub<br />
<br />
Private Sub TimePickerValueChanged(ByVal sender As Object, ByVal e As EventArgs)<br />
Me.isEditing = True<br />
MyBase.ColumnStartedEditing(timePicker)<br />
End Sub<br />
End Class<br />
<br />
Namespace DataGridColumnStyleExample<br />
Public Class MyForm<br />
Inherits Form<br />
<br />
Private namesDataTable As dataTable<br />
Private myGrid As DataGrid = New DataGrid()<br />
Public Sub New()<br />
<br />
InitForm()<br />
<br />
namesDataTable = New DataTable("NamesTable")<br />
namesDataTable.Columns.Add(New DataColumn("Name"))<br />
Dim dateColumn As DataColumn = _<br />
New DataColumn("Date", GetType(DateTime))<br />
namesDataTable.Columns.Add(dateColumn)<br />
Dim namesDataSet As DataSet = New DataSet()<br />
namesDataSet.Tables.Add(namesDataTable)<br />
myGrid.DataSource = namesDataSet<br />
myGrid.DataMember = "NamesTable"<br />
AddGridStyle()<br />
AddData()<br />
End Sub<br />
<br />
Private Sub AddGridStyle()<br />
Dim myGridStyle As DataGridTableStyle = _<br />
New DataGridTableStyle()<br />
myGridStyle.MappingName = "NamesTable"<br />
<br />
Dim nameColumnStyle As DataGridTextBoxColumn = _<br />
New DataGridTextBoxColumn()<br />
nameColumnStyle.MappingName = "Name"<br />
nameColumnStyle.HeaderText = "Name"<br />
myGridStyle.GridColumnStyles.Add(nameColumnStyle)<br />
<br />
Dim timePickerColumnStyle As DataGridTimePickerColumn = _<br />
New DataGridTimePickerColumn()<br />
timePickerColumnStyle.MappingName = "Date"<br />
timePickerColumnStyle.HeaderText = "Date"<br />
timePickerColumnStyle.Width = 100<br />
myGridStyle.GridColumnStyles.Add(timePickerColumnStyle)<br />
<br />
myGrid.TableStyles.Add(myGridStyle)<br />
End Sub<br />
<br />
Private Sub AddData()<br />
Dim dRow As DataRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 1"<br />
dRow("Date") = New DateTime(2001, 12, 1)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
dRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 2"<br />
dRow("Date") = New DateTime(2001, 12, 4)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
dRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 3"<br />
dRow("Date") = New DateTime(2001, 12, 29)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
dRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 4"<br />
dRow("Date") = New DateTime(2001, 12, 13)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
dRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 5"<br />
dRow("Date") = New DateTime(2001, 12, 21)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
namesDataTable.AcceptChanges()<br />
End Sub<br />
<br />
Private Sub InitForm()<br />
<br />
Me.Size = New Size(500, 500)<br />
myGrid.Size = New Size(350, 250)<br />
myGrid.TabStop = True<br />
myGrid.TabIndex = 1<br />
Me.StartPosition = FormStartPosition.CenterScreen<br />
Me.Controls.Add(myGrid)<br />
End Sub<br />
<br />
<STAThread()> _<br />
Public Shared Sub Main()<br />
Application.Run(New MyForm())<br />
End Sub<br />
End Class
|
|
|
|
|
|
Hi there -
i have to implement a remote control for clients. this control should be able to lock the client-workstation - in simple words: monitor black, keyboard and mouse locked.
I develope the program in VB.net and on the clients a service will run. and within this service, i want to call a function that does the things for me i just talked about.
but i have no idea what function (i think it is a win API function in GDI32) i have to use to do the locking. or has anyone a better idea?
i am open for all suggestions.
thanks a lot for all replies.
happy coding.
tom
|
|
|
|
|
There is no one function that will lock the keyboard and mouse. You have to write code to hook the keyboard and mouse and eat any messages that are sent your way from the keyboard and mouse drivers. Unfortunately, you can't keep the user from using Ctrl-Alt-Del. This key combination cannot be trapped. There is a great article on CodeProject by Michael Kennedy called "Global System Hooks in .NET"
[^] that demonstrats this technique.
Your service must also be set to "Allow interaction with Desktop" so that you can put up a form that covers the entire desktop area and tag that form as TopMost.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thank you very much for your hints.
the article seems to be what i was lookin' for ...
do you have an example how this thing with "allow interaction with desktop" works?
anyway- thanks for your help.
tom
|
|
|
|
|
Easy. When you instlal your service on the client, go into the Services control panel and find your service. Double-Click on it to bring up its properties and click on the LogOn tab. Make sure it is using the Local System Account and click on the Allow Service to interact with desktop checkbox. Click OK and your done.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The hook article is very interesting. but at the moment i'm thinkin' if i could not find an easier solution.
if i put up a form that covers the entire desktop and make it topMost - all i have to do then, is to avoid the user from closing the window by pressing the "x" in the upper right corner or pressing alt+F4. right? maybe i can catch this in a way easier than to hook the keyboard. but then - the user still can press strg+alt+del and kill the form in the taskmanager, can't he?
|
|
|
|
|
tommy_tanaka wrote:
the user still can press strg+alt+del and kill the form in the taskmanager, can't he?
Yep. Locking a machine is not as easy as it would sound. There's really no other way of doing this. There is no function you can call to turn off the keyboard and mouse, simply because there is no practical use for it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
sh*t ... well - what do you think of this idea:
the running service remembers if an form has to be popped up or not. if so, it always checks, if the form is still alive, otherwise it pops it up again.
or better, in the destructor of the form, the object itself checks, if it should popup again or not.
to kill a running service will be much more difficult for an usual user, than just to call strg+alt+delete to kill the form.
what's your thinking about this?
|
|
|
|
|
I've got a question... What's the point behind all of this? Why lock the workstation anyway?
tommy_tanaka wrote:
to kill a running service will be much more difficult for an usual user, than just to call strg+alt+delete to kill the form.
You can't kill just a form. A form is part of an application, or service. And don't put it past any user that they can't figure out what to kill off in the process list, which your service will be apart of...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know an excellent method of locking the computer, although I'm not sure of any API's that might help, if you could purposely lock the machine or BSOD it (Blue Screen Of Death) - would that be helpful? lol. Try this: On Windows 98 goto Start, Run and type con/con and you get a nice BSOD! hehe
Or... alternatively you could try my more serious solution:
- Set the border of the form to 0 so it has no title bar etc...
- Make the form top-most using the SetWindowPos API
- Disable keyboard and mouse input using the BlockInput API (with params TRUE or 1) call this in a 1 milli second timer!
Now the only key combo that works is C.A.D (or S.A.D as you lot call it) I know this is a pain in WinXP but, there is a way around that with a simple registry hack. Change following in the registry (if it doesn't exist - create the keys and the value)
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\
Create a REG_DWORD value under this key called DisableTaskmgr and set it to 1
Because there is no simple way to do this I have come up with a bit of a patchy method but it works. Watch out for that windows key
Oh yeah one last thing make the background color of the form blue so it looks like a BSOD
|
|
|
|
|
Hey got a question,
I'm using a printe document in my program, My printing goes just fine, along with my print preview. My question, is does anybody know how to at runtime, choose to print to a file, like you were to select that on a print dialog? Setting the path and file to create for this Print to File, I've searched all over and, can't seem to find anything on this, also tried a few different things. I want to do this all without user involvment.
Thanks in advance
|
|
|
|
|