Yes i have Simon and i have seen a lot of examples however they all seem to stop at VB 2008, I have tried the example but the problem i have is still there. It seems that on the mouse down button it fires the mousedown event, while holding the the button and now move the mouse the mousemove event is not triggered untill the mouse button has been released. Is there any way to tell the event to end and contine looking for other events?? is this a limitation of 2010 Express version??
You need to implement a mouse move event on the control not the form
Private Sub Control_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label2.MouseMove
If Moving Then
Dim ctrl As Control = CType(sender, Control)
' Move the control according to mouse movement
ctrl.Left = (ctrl.Left + e.X) - cursorX
ctrl.Top = (ctrl.Top + e.Y) - CursorY
' Ensure moved control stays on top of anything it is dragged on to
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
I find I need an old vb program on win7 but got out of doing stuff like this. Despite the fact that some ways of doing things was dropped in modern windows I am guessing there is a replacement. I know send keys was considered un reliable but the problem was finding what window was the focus. Chances are the window is called something else. A good example is the program I need this for when the window is open there is no title to be seen. all my research says that vb6 is an unreliable or troublesome install on win 7. I have the source for an old vb program and have been advised to find a net replacement. And was wondering how others handled the same problems. For instance the converter by microsoft. Does it work. And how much should I expect to be converted and how much should I expect to hand code.
here is what I am talking about.
<prelang= "vb"><pre>VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1995
ClientLeft = 60
ClientTop = 345
ClientWidth = 4185
LinkTopic = "Form1"
ScaleHeight = 1995
ScaleWidth = 4185
StartUpPosition = 3 'Windows Default
Begin VB.Timer Timer1
Left = 540
Top = 930
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Sub Form_Load()
Timer1.Interval = 100
Private Sub Timer1_Timer()
Static lHwnd As Long
Dim lCurHwnd As Long
Dim sText As String * 255
lCurHwnd = GetForegroundWindow
If lCurHwnd = lHwnd Then Exit Sub
lHwnd = lCurHwnd
If lHwnd <> hwnd Then
Caption = "ActiveWidow: " & Left$(sText, GetWindowText(lHwnd, ByVal sText, 255))
Caption = "ActiveWindow: Form1"
thank you for your answer.if I don't know the .net I am probally going to get into trouble. Yes that looks like what I am trying to work with. Though the coding there looks a lot better then what I came up with. Let me explain the problems I am having and maybe as coders you can tell me how I should handle it. I have a program I need to find the active window on. one of the problems I think is the program takes over my comp. and by that I mean I can not easly run any other program while this program is running. but a lot of my input is repetitive meaning I have to hit the same set of keys over and over.
sometimes for as long as an hour. I have found some stuff will run as long as it is in the background.My idea was a simple script to find the active window and handle then senkeys to send the keystrokes to it. But heres my glitch. I can not get the script to stay open long enough to read the info and everyone tells me I should never use sendkeys for this. the only advise I get is find another way besides send keys.but no search or no one has sugested another way. I tried stuff like autoit but failed on all attempts. Is there a better way? or maybe a progam I could use?
I think if you simply want to find the active window, then you should should run the script as a function (within a common module) rather than in a timer (in a form) or at the very least disable the timer once you have found the active window.
The sample code you provided lives in the TIMER's event routine within the FORM.
This would also mean if you have several forms then they are all running concurrently.
And this is why your system is becoming unresponsive?
For what you want to do, I dont think the sendkeys is the problem, its probably the timer which runs every so often... (100 milliseconds i think you had it at).
If everyone tells you you shouldn't use sendkeys to do what you want, then more than likely they are right! After all so many people cannot be wrong?
Maybe you could use API functions to attain the results you want?
Im not sure but it cannot be too difficult for you to find the answer in the documentation on MSDN.
I have seen several posts on this websites forum which deal with finding the active window.
Maybe surfing through those threads/posts would give you a better resolution to your issue.
The VB6 code migration wizard no longer exists in Visual Studio 2010 and above. If you've got VB6 code to convert, you'll either need to use Visual Studio 2008 to do a conversion, the quality of which depends entirely on your VB6 code. The more PInvoke stuff you have in it, they worse the conversion will be.
Keep in mind that the conversion utility will not rewrite your code to what you can do by hand today under .NET. It will convert the project so that it has a decent chance of at least compiling. VB6 did so many things poorly that it's sometimes just impossible for it to figure out what you were doing and rewrite appropriately.
Microsoft Visual Basic 2008, Professional Edition
I've run into a problem I can't figure out. I'm using VB 2008. I found the following sample code and was attempting to use it but am not understanding how to setup the query, I bolded it below.
I understand I need to go in and set up my own customer query in my database in order to use it like the example below.
Q) Do I setup the query on my table adapter or on the original table in the database (Maybe even some good info on how to setup these queries)?
Q)If I'm understanding this, once I setup the query correctly I should just have to put in a variable and it fill find all row(s) with that parameter that I can delete?
Q) When using the @XXXX in the query, do I have to then use that as my variable to pass the data I'm looking for or can I use and variable?
' Locate the row to delete.
Dim oldRegionRow As NorthwindDataSet.RegionRow
oldRegionRow = NorthwindDataSet._Region.FindByRegionID(5)
' Delete the row from the dataset
' Delete the row from the database
I was able to setup the following query on my database but per the example, I'm not sure I did it correctly:
SELECT Gene, FindMethod, TDiscovery, TReplicate, AA_A, AA_T, AA_G, AA_C, ImageFileName, Description, SpxReplicationItem, IconFileName, Complete, Image, Icon, Type,
UniqueID, Chromosome, Rarity, ParentGene, Name
WHERE (Gene = @genename)