|
|
I am writing my first code in VB.NET and was doing quite well until now. Can someone please tell me how to implement the following.
Set dwData field to a value.
Set lpData to point to filename string
Set cbData to filename string length (add 1 for trailing zero)
I have read the article Single Instance App with Command-Line Parameters
By Richard Deeming wich gave me some ideas but its not quite doing what I hoped.
Cheers
|
|
|
|
|
smokepipes,
In richards code it is like this:
Line --- mMain.vb -- from TestSingleInstance By Richard Deeming
109 Dim CD As COPYDATASTRUCT
110 With CD
111 .dwData = 0 '<<-- sets "Value to zero"
112 .cbData = B.Length '<<-- sets "filename string length"
113 .lpData = lpB.ToInt32 '<<-- sets "pointer to "filename string" converted to an "integer 32"
114 End With
Adding "1 for trailing zero" to the "filename string length" would cause the function SendCDSToWindow, to fail.
"its not quite doing what I hoped" <<-- What did you hope it would do?
progload
|
|
|
|
|
Thanks for the reply.
What I am trying to do is set up a data stream from another application(Flight Simulator). I have used the findwindow function in the win32 api and now I need to establish the connection to the Simulator to get data from and send data to the Simulator. I dont think that this is generaly what Richards code does but its the closest thing I could find. I have some code in c++ if it helps and I have tried to convert it but c++ doesnt mean a thing to me at the moment. I am still getting to grips with the basics of VB.NET
#include <windows.h>
#include "FlightSimLink.h"
const char* sFSMainClass = "FS98MAIN";
const LET_START_VIDEO_RECORDING = 0x0001B001;
const LET_STOP_VIDEO_RECORDING = 0x0001B002;
const LET_START_VIDEO_PLAYBACK = 0x0001B003;
const LET_STOP_VIDEO_PLAYBACK = 0x0001B004;
const char sFSHandleMagic[] = {'<', 'H', 'A', '>'};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFlightSimLink::CFlightSimLink()
{
}
CFlightSimLink::~CFlightSimLink()
{
}
void CFlightSimLink::Tell(FS_ACTION action, const char* filename)
{
HWND hWnd = FindWindow (sFSMainClass, NULL);
if (!hWnd)
throw "FlightSim is not running";
COPYDATASTRUCT cpdata = {0, 0, 0};
switch (action) {
case FS_START_RECORD:
cpdata.dwData = LET_START_VIDEO_RECORDING;
cpdata.lpData = const_cast<char*>(filename);
cpdata.cbData = strlen (filename) + 1;
break;
case FS_STOP_RECORD:
cpdata.dwData = LET_STOP_VIDEO_RECORDING;
break;
case FS_START_PLAYBACK:
cpdata.dwData = LET_START_VIDEO_PLAYBACK;
cpdata.lpData = const_cast<char*>(filename);
cpdata.cbData = strlen (filename) + 1;
break;
case FS_STOP_PLAYBACK:
cpdata.dwData = LET_START_VIDEO_PLAYBACK;
break;
default:
throw false;
}
SendMessage (hWnd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cpdata);
}
void CFlightSimLink::Tell(FS_ACTION action, HANDLE handle)
{
char MagicName[sizeof (sFSHandleMagic)+8+8+1];
memcpy (MagicName, sFSHandleMagic, sizeof (sFSHandleMagic));
wsprintf (MagicName + sizeof (sFSHandleMagic), "%08.8X%08.8X", (DWORD)handle, GetCurrentProcessId ());
Tell (action, MagicName);
}
I hope this may shed some light on what I am trying to do.
Cheers
|
|
|
|
|
I want to develop a software in VB.NET 2003 (windows form not web form) which check on internet on my website whether new pictures are available on my website & if new pics are available, download them to a specified folder on user comp (eg. c:\pics).
I got an idea of this by simply adding a text file on my website/webserver & whenever i add new pics, i also add its location (http://www...) in that text file (one pic's location on each line). And my program reads that text file to find out whether there are all files located in that text file present on user's comp (c:\pics).
So now anybody, please tell me with coding how can i do this. Tell me how to retrieve that text file & new pics through internet & also how can i read that text file & compare it with pics in user's comp. Please, anybody HELP!
Iftikhar Ali
-- modified at 14:35 Thursday 8th June, 2006
|
|
|
|
|
i a vb express 2005 programming
i want to write a program to read a file and store contents file in a array.
eg :
i have a coba.txt file : abcdefgh
i want to make array baca_coba,
baca_coba(1) = a
baca_coba(2) = b
baca_coba(3) = c
baca_coba(4) = d
baca_coba(5) = e
...
i write program :
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FileName = "F:\sementara\coba.txt"
openFileDialog1.FilterIndex = 1
Dim encoding As System.Text.Encoding = System.Text.Encoding.Default
Dim filen As New StreamReader(openFileDialog1.FileName, encoding)
Dim i As Integer
Dim baca_coba(),baca As string
For i = 1 To 10
baca = Int(filen.Read())
baca_coba(i) = chr(baca)
Next
but my program is error, how to make a program to this problem?
if i have a file with unknown unicode. how to write program to know
what type unicode from that file.
eg : from file baca_coba file above, when i click button, a message show with
information: BigEndian unicode
|
|
|
|
|
Why do you need an array to store each character? Just do:
Dim s as String = filen.ReadToEnd()
You can index the string as if it were a character array.
|
|
|
|
|
i want to add sound file to my application and work in form load how?!
ma_refay
|
|
|
|
|
Put it in resource somekinda res type "Wav" File and extract it when form is loading
Dim S as string
S=strconv(LoadResData(ResouceID,ResourceType In Here EG:"Wav"),vbUnicode)
Get the function SndPlaySound From api viewer.
and At the form_Load
sndplaysound(s,SND_ASYNC or snd_memory);
like that.simple
Kanchana
-- modified at 18:22 Thursday 8th June, 2006
|
|
|
|
|
hi i want to use currencymanger in my project so when i add new product to my dataset and before i update the dataset to databse i can move between theses products i add there for buuton in the form to move first ,last ,next ,previous so when i add new projeect the label that dir what record i have now and all record like this '5 of 17'
the error is when i try to add new product he add it but he edit in the first product in dataset because i don't know to told code to add new item to currency manger when i add new product and set focus on the new poistion
the code i use
" dim cr as currencymanger"
"cr=me.bindingcontext(datasetname,tablename)"
if i try to use the statement "cr.addnew" i have error because i use sqldataadapter to add new rows and add these rows to dataset hthe .net told me that some parameters can't alloe null inc ase of using "cr.addnew"
thanks and sorry for long
ma_refay
|
|
|
|
|
Anyone got a simple way to get the duration(minutes and seconds) of a .MP3 file?
I notice in windows if you open a folder with .MP3 files in it and hit - VIEW - DETAILS, you will see the duration. Anyone know how to pull that into you program much like:
Dim fileData As FileInfo = My.Computer.FileSystem.GetFileInfo(OpenFileDialog1.FileName)
Will give you just the FILENAME
- Coding is fun - plus Skittles and DEW!
DaleG
|
|
|
|
|
Needs:
=========
1 Form
Private Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub Form_Load()
Dim Befehl As String
Dim Datei As String
Dim Laenge As Long
Dim Ret As String * 256
Datei = "D:\ZAPP3.MP3"
Befehl = "Open " & Datei & " alias MediaFile"
mciSendString Befehl, vbNullString, 0, 0&
Befehl = "Set MediaFile time format milliseconds"
mciSendString Befehl, vbNullString, 0, 0&
Befehl = "Status MediaFile length"
mciSendString Befehl, Ret, Len(Ret), 0&
Laenge = CLng(Ret)
Befehl = "Close MediaFile"
mciSendString Befehl, vbNullString, 0, 0&
MsgBox Laenge / 1000 & " Sec"
End Sub
|
|
|
|
|
Sir,
I have a program containing more then 35 textboxes and have 2 pages .Can you please send me code for checking the preview of the page and finally printing the page.
Thanks and regards
Amaneet Brar
|
|
|
|
|
Hi,
I am using dtpicker control in my VB application. I don't need to show the full date on calendar view. Is it possible to hide that.
Any luck.
Regards
Rams.
Be simple and Be sample.
|
|
|
|
|
I am using a datagrid on my Windows form to display records stored in a SQL Server database. When the form loads the datagrid is populated with the records. When I select an item in the datagrid the values are displayed in some text boxes. So when i select a different row in the datagrid the text boxes change accordingly. This part is fine.
I then have two buttons, Add and Delete. I use SQL statements to Add and Delete records. The SQL statements are fine and when I check the table in SQL Server the Addition or Deletion has been successful. The problem is refreshing my datagrid. If i close the form and open it again the datagrid reflects the changes, but i want it to refresh without closing and opening the form. The code for the Add button is as follows:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim Command As SqlCommand
Command = New SqlCommand("Insert into FitmentReasons(code,description, active) values ('" & txtCode.Text & "','" & txtDescription.Text & "','1')", gConn)
Command.ExecuteNonQuery()
txtCode.Clear()
txtDescription.Clear()
End Sub
|
|
|
|
|
after adding new record again bind the data to datagrid using select query.
|
|
|
|
|
You need to fill the dataset or datatable again and set the datasource to the datagrid.
|
|
|
|
|
Hai,
I am using grid with 1000 cols and 20 rows. In each column for some cells font is different than default fpnt. But this is giving out of memory error. What is the soulutions.
With regards
|
|
|
|
|
There is a maximum number of cells a MSFlexgrid can display. I cant remember the exact number and google isnt helping at the moment. From what i remember (from the problems we had) 1000 x 20 (and maybe a couple of fixed rows/columns) is probably pretty close to that limit. Try using the MSHFlexgrid instead.
Jon
|
|
|
|
|
hi, can anyone tell me about free ebooks for vb.net.
Himanshu Arora
VSNL
New Delhi
|
|
|
|
|
|
hello every body. I want to convert string to unicode and unicode to string. can you tell me.
|
|
|
|
|
String is first converted into ASCII and then to Unicode by character mapping and visa-versa!
I did the same thing while handling Hindi-fontcode. Hindi-font-Text was first converted into ISCII and then to Unicode & visa-versa. For that I used dlls...
All this thing is based on character mapping...
Padma Gahlot
|
|
|
|
|
|
Hi,
I am writing an addin tat adds a couple of menu items to various CommandBars in Visual Studio 2005. I have all the menu items working fine but I still have a few other things to get sorted out.
I am adding some menu items to the context menu of the Project Folder. I want them all to appear after the Build, Rebuild and Clean menu items. How can I add a seperator before my first menu item and after my last menu item?
I have added a few menu items to the context menu of the code window. How can I fix it so that these menu items are only displayed when the active document is either a .cs or .vb file?
How can I get rid of the icons that are added automatically to my menu items?
Thanks very much,
dlarkin77
|
|
|
|