|
With dynamically created controls, you have to manually wire up all the events you want to handle using AddHandler and RemoveHandler[^].
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
In an AJAX application there is often a noticeable pause between the time the browser makes a network request and the time the browser receives a response. To let the user know that the network conversation is taking place, the ASP.NET AJAX UpdateProgress control provides immediate feedback by displaying an animated image, ‘loading’ text, or other HTML that disappears once the network response is received.
Is there a way to implement the same concept on windows application using VS2003?
I have tried to use a gif image but when the form is busy(4 exmaple uploading a file) the gif is loosing focus and is not visible during this period.
|
|
|
|
|
samerh wrote: Is there a way to implement the same concept on windows application using VS2003?
Of course, the main thing is, you need to perform your actions on another thread, so your UI remains active.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for your reply, but suppose i dont want to use multi-threading!!!
I want the user to wait until the process ends, but during that time i want to display an image or html that notifies that the form is still active and it is a matter of seconds and the process ends.
|
|
|
|
|
samerh wrote: Thanks for your reply, but suppose i dont want to use multi-threading!!!
You can call Application.DoEvents regularly and hope that it's enough, but if your UI does anything for a long time ( such as waiting for a file to download ), then you have no choice. You can have frozen UI, or you can use threads.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
1) How to get a list of all drive letters and names, including USB-memory sticks, eg. "D: Removable drive"?
Am I right that every drive has an individual ID-number or name? If so, how to get this name/ID from vb.net? I would like to compare if the two USB sticks are the same when used one after the other in the same USB-port.
2) What code snippet would tell my app to make "foo.exe" start on every Windows log in?
3) Is there an API to compress a folder into a zip-file or is the only way to use some 3rd party command line application?
|
|
|
|
|
1 - The System.IO namespace has a class that returns a list of all drives. All drives do have a semi unique ID/name, that would require WMI. They can have a name given to them when formatted, .NET can see that, I suspect most USB drives wouldn't have it.
2 - none, as your app would not be running. Put a shortcut to foo.exe in the run registry key ( I search for runonce, to find it, it's the first one above ), or in the Startup folder of the start menu
3 - are you using .NET 2.0 ? If so, there is zip support in the framework.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
1. Yes, I am using .NET 2.0. How to use this zip support. Could you give me an example code to zip folder and all its subdirectories in "C:\temp\" to folder "D:\here" with the file name "myfold.zip".
2. How to make a registry entry for the startup? Could you give me an example code.
|
|
|
|
|
So, what would be the best way to recognize if the inserted USB memory stick / USB hardrive is the same as the one used before?
|
|
|
|
|
This is used to detect when someone inserts or removes a USB drive, cd or dvd, provising plug and play is still on. It also tells you what kind of drive is used so I hope this can point you in the right direction or at least allows you to snip bits out.
<br />
Private Const GWL_WNDPROC As Long = (-4)<br />
Private Const WM_DEVICECHANGE As Long = &H219<br />
Private Const DBT_DEVNODES_CHANGED As Long = &H7<br />
Private Const DBT_DEVICEARRIVAL As Long = &H8000&<br />
Private Const DBT_DEVICEREMOVECOMPLETE As Long = &H8004&<br />
Private Const DBT_DEVTYP_VOLUME As Long = &H2 ' Logical volume<br />
Private Const DBT_DEVTYP_DEVICEINTERFACE As Long = &H5 ' Device interface class<br />
Private Const DBTF_MEDIA As Long = &H1 ' Media comings and goings<br />
Private Const DBTF_NET As Long = &H2 ' Network volume<br />
<br />
Private Enum DriveType As Integer<br />
DRIVE_UNKNOWN = 0<br />
DRIVE_NO_ROOT_DIR = 1<br />
DRIVE_REMOVABLE = 2<br />
DRIVE_FIXED = 3<br />
DRIVE_REMOTE = 4<br />
DRIVE_CDROM = 5<br />
DRIVE_RAMDISK = 6<br />
End Enum<br />
<br />
Private Structure DEV_BROADCAST_HDR<br />
Public dbch_size As Integer<br />
Public dbch_devicetype As Integer<br />
Public dbch_reserved As Integer<br />
End Structure<br />
<br />
Private Structure DEV_BROADCAST_VOLUME<br />
Public dbcv_size As Integer<br />
Public dbcv_devicetype As Integer<br />
Public dbcv_reserved As Integer<br />
Public dbcv_unitmask As Integer<br />
Public dbcv_Flags As Short<br />
End Structure<br />
<br />
Private Declare Auto Function GetDriveType Lib "kernel32.dll" (ByVal nDrive As String) As DriveType<br />
<br />
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)<br />
If m.Msg = WM_DEVICECHANGE Then<br />
Dim WParam As Int32 = m.WParam.ToInt32()<br />
Dim dInfo As String = ""<br />
<br />
Select Case WParam<br />
Case DBT_DEVICEARRIVAL<br />
dInfo = showInfo(m, WParam)<br />
If Me.advancedMode Then<br />
If MsgBox("New Drive Detected: " & dInfo & vbCrLf & "Would you like to view the images on the drive?", CType(MsgBoxStyle.Question + MsgBoxStyle.YesNo, MsgBoxStyle), "New Drive Detected") = MsgBoxResult.Yes Then<br />
'Me.treeBrowse_ExpTreeNodeSelected(Split$(dInfo, ":")(0) & ":\", )<br />
loadImages(Split$(dInfo, ":")(0) & ":\")<br />
End If<br />
Else<br />
loadImagesUploader(Split$(dInfo, ":")(0) & ":\")<br />
End If<br />
Me.timerRefrshTree.Start()<br />
Case DBT_DEVICEREMOVECOMPLETE<br />
dInfo = showInfo(m, WParam)<br />
If Split$(dInfo, ":")(0) <> "" Then<br />
MsgBox("Drive " & Split$(dInfo, ":")(0) & ":\ Removed", CType(MsgBoxStyle.Information + MsgBoxStyle.OkOnly, MsgBoxStyle), "Device Removal")<br />
Me.timerRefrshTree.Start()<br />
End If<br />
<br />
m.Msg = &H0<br />
End Select<br />
Me.Refresh()<br />
End If<br />
MyBase.WndProc(m)<br />
End Sub<br />
<br />
Private Function showInfo(ByVal m As System.Windows.Forms.Message, ByVal WParam As Int32) As String<br />
Dim infoString As String = ""<br />
Dim Header As DEV_BROADCAST_HDR<br />
Dim HeaderVolume As DEV_BROADCAST_VOLUME<br />
Dim HdrType As Type = GetType(DEV_BROADCAST_HDR)<br />
<br />
Header = CType(Marshal.PtrToStructure(m.LParam, HdrType), DEV_BROADCAST_HDR)<br />
<br />
If Header.dbch_devicetype = DBT_DEVTYP_VOLUME Then<br />
Dim Bits As BitArray<br />
Dim VolumeLetters As New ArrayList<br />
Dim Bit As Boolean<br />
Dim Charcode As Integer = Asc("A"c)<br />
HeaderVolume = CType(Marshal.PtrToStructure(m.LParam, GetType(DEV_BROADCAST_VOLUME)), DEV_BROADCAST_VOLUME)<br />
Bits = New BitArray(BitConverter.GetBytes(HeaderVolume.dbcv_unitmask))<br />
For Each Bit In Bits<br />
If Bit Then<br />
Dim driveLetter As String = Chr(Charcode)<br />
VolumeLetters.Add(Charcode)<br />
Dim thisDrivetype As DriveType<br />
thisDrivetype = GetDriveType(driveLetter & ":\")<br />
If thisDrivetype = DriveType.DRIVE_REMOVABLE Then<br />
infoString = driveLetter & ": Removable Drive"<br />
ElseIf thisDrivetype = DriveType.DRIVE_CDROM Then<br />
infoString = driveLetter & ": CD-ROM"<br />
Else<br />
infoString = driveLetter & ": " & thisDrivetype.ToString<br />
End If<br />
End If<br />
Charcode += 1<br />
Next<br />
End If<br />
<br />
Return infoString<br />
End Function<br />
Daniel
|
|
|
|
|
You can place a shortcut to your app or that exe in the start menu: start->all programs->startup .
or
you can create a value in the registry subkey: HKEY_CURRENTUSER\SOFTWARE\MICROSOFT\WINDOWS\CURRENT VERSION\RUN that references your program.
Posted by The ANZAC
|
|
|
|
|
Has anyone here embarked on this adventure before?
If yes, I would like to hear your experiences since I need to go down that path now.
In any case, can somebody share any tips, tricks or pitfalls related to this type of migration and any pointers as to how the effort estimation might be done?
I am currently evaluating one of the tools that will convert Delphi form files (DFM) to Winforms files. Though there do not seem to be any tools for code conversion.
Thanks
Shreekar
|
|
|
|
|
I would be surprised if such a tool exists, I think you're in rewrite land.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for your reply.
My research also suggests the same thing.
Based on your experience, are there any things that I can do to make my task easier, or some precautions etc.?
Since there does not seem to be much in way of prior experience related to this, I am trying to draw on any parallel or related experiences.
Thanks
Shreekar
|
|
|
|
|
I have no experience, I have never used Delphi, and I refuse to use VB.NET.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I used to work for a company that had all their code in delphi and turbo pascal. The company decided to move to vb.net. SO I have a bit of experience translating delphi to vb.net.
Things that will drive you crazy in vb.net
there are no ; for line delimiters. If you want a line to go to the next line you have to use _ When passing parameters you always have to mark the parameter as byref or byval. You have try catch instead of try except. Any use of pointers is probably not needed anymore. The database stuff is really different and takes some getting used to.
I think the biggest issue is just learning the .net framework. That takes a while. Once you get familiar with it, it doesn't matter if you write the code in vb.net or C# because you know the .net framework. I wrote a little document at one point that talked about common things done in delphi and how to do them in vb.net. I will check to see if I can still find that doc.
Hope that helps.
Ben
|
|
|
|
|
That certainly helps a lot, thanks.
Did you use any tools that could automate atleast some part of the process?
I have come across this[^] tool that converts Delphi forms to Winforms.
That document would be great.
All in all, was that a good/painful experience and did you get the expected benefits in terms of higher maintainability ad improved performance?
I am sorry to raise so many questions, but I am trying to collect as much data as possible.
Thanks
Shreekar
|
|
|
|
|
We did not use any automated tools. In our case the way you do things in .net is different enough that it was probably a good idea to re-write the existing delphi code to better match the new .net structure.
I have looked for that document, it looks like I didn't take a copy of it when I left my previous employer.
It was a good experience to move to .net. Some of the issues we were facing were a lack of people we could hire that had delphi skills. The reality is that there are far more .net programmers out there then delphi. Now that I have been doing .net for 5 or so years, I wouldn't go back to delphi either. I really liked delphi as a product, but it tends to be a little behind the microsoft release. I still remember about 10 years ago where we had to wait almost a year before we could use ado in delphi. Now that delphi has .net that could always perhaps be an option too. Again you don't have a lot of people that will say they know delphi .net
The company I worked for went with vb.net and left delphi behind. I havn't worked there in 2 years, but I would guess most of their delphi code is gone.
The .net framework is great, I think it would be a good move to get on .net
Hope that helps.
Ben
|
|
|
|
|
setup and packaging a windows application using setup wizard or setup project options.
thank u
|
|
|
|
|
I don't see a question ? I mean, it's implicit, but it's kind of rude that you didn't really ask.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
hi,i am David Lau.
now i am doing a windows forms application. Yesterday, the customer gave us the following error. this error can repeat on that pc, but we do not repeat it in our test machine.
why does this error happens? who can help me?
■env:
・Win2000 SP4
・.net framework 1.1
・DB-Microsoft Access 2000
・VB.NET 2003
■Error infomation:
2007-04-13 16:45:02,476 System.Data.OleDb.OleDbException: Unknown
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at MIGRATE.ADP.RunSqlFillDataTbl(String strSql, DataTable& dtTbl)
--- ------- ---
at MIGRATE.ADP.RunSqlFillDataTbl(String strSql, DataTable& dtTbl)
at MIGRATE.frmMigrate.sbInitComboBox()
at MIGRATE.frmMigrate.frmMigrate_Load(Object sender, EventArgs e)
■Comment
(1)on that PC, MS Access is not installed
(2)MADC 2.8 has been installed.
Thanks.
David Lau
stillicel@hotmail.com
-- modified at 1:55 Monday 16th April, 2007
|
|
|
|
|
just update ur clients windows 2000 w/ sp4 or the latest sp release of microsoft.......
start a new beginning in every ending; thats what life for......
|
|
|
|
|
It looks like you trying to execute a Command against the database, but it's failing for an unknown reason. There's probably a couple dozen possibilities for this failure, but without any further information about what going on in the code at the time or what the SQL command is that it's trying to execute, it's just about impossible for anyone to tell you anything helpful.
Access does NOT have to be installed for this to work. You only need the MDAC.
Has the database been compacted and repaired recently?
Is the customer running more than one copy of the application at the same time?
Is the database local to the machine with the problem or is it shared on a network drive?
Does it have a password?
What's the command that's failing?
???
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Dave Kreskowiak:
Thank you for your answer. today i will confirm the MDB file from the customer.
(1)>What's the command that's failing?
the following is the failing SQL:
SELECT ORIGIN_PE_CD,
ORIGIN_PC_CD,
ORIGIN_PC_SH_CD,
ORIGIN_PC_ALSNAME,
ORIGIN_PC_ADDRESS,
ORIGIN_PC_CHFNAME,
BAN34,
BAN35,
DEL_FLG
FROM K_T_PC_INFO
(2)>Does it have a password?
yes. the mdb file has a password. i have seen the log file, connection to that mdb file was successfully built. when excuting any SQL, that error happened.
(3)> Is the database local to the machine with the problem or is it shared on a network drive?
no. the log file tells that MDB file is in the c:\program files\kapp
|
|
|
|