|
What would you like to know?
RageInTheMachine9532
|
|
|
|
|
I am currently using the vb.net module included in the above article. The code works really well. I am trying to add to this project a new class “CurrentWindowWithKeyboardFocus” , which will include variables and functions that will determine
Handle to window with keyboard focus
window x position
window y position
window width
window height
What I am confused about is how I can get the handle of the window that has the keyboard focus. Is it a handle to a process??
I have attached a preliminary copy of my new class. I am looking for recommendations?? Should the class inherit from "System.Windows.Forms.Control"??
Thanks for your time and attention.
Public Class CurrentWindowWithKeyboardFocus
Inherits System.Windows.Forms.Control
Public CurrentWindow As Control
Private CWXPosition As Integer
Private CWYPosition As Integer
Private CWWidth As Integer
Private CWHeight As Integer
Private CWHandle As IntPtr
Public Sub New()
'gets the handle to the window
CWHandle = HandleOfCurrentWindow()
'gets the x postion of the window
CWXPosition = XPositionOfCurrentWindow(CWHandle)
'gets the y position of the window
CWYPosition = YPositionOfCurrentWindow(CWHandle)
'gets the width of the window
CWWidth = WidthOfCurrentWindow(CWHandle)
'gets the height of the window
CWHeight = HeightOfCurrentWindow(CWHandle)
End Sub
Public Function HandleOfCurrentWindow()
Dim WindowHandle As Integer
Dim p As Process
p = Process.GetCurrentProcess
WindowHandle = Process.GetCurrentProcess.Handle.ToInt32
'get handle of current window
'return handle
Return WindowHandle
End Function
Public Function XPositionOfCurrentWindow(ByRef intptr)
Dim xpos
'get x position of current window
'return integer
Return xpos
End Function
Public Function YPositionOfCurrentWindow(ByRef intptr)
Dim Ypos
'get y position of current window
'return integer
Return Ypos
End Function
Public Function WidthOfCurrentWindow(ByRef intptr)
Dim Width
'get width of current window
'return integer
Return Width
End Function
Public Function HeightOfCurrentWindow(ByRef intptr)
Dim Height
'get width of current window
'return integer
Return Height
End Function
End Class
|
|
|
|
|
matthew kelly wrote:
Public Function HandleOfCurrentWindow()
Dim WindowHandle As Integer
Dim p As Process
p = Process.GetCurrentProcess
WindowHandle = Process.GetCurrentProcess.Handle.ToInt32
'get handle of current window
'return handle
Return WindowHandle
End Function
Well, first of all, your not getting the Window handle of the CurrentProcess. Your actually returning the handle to the Process itself, not it's Window. You have to use the MainWindowHandle propery of the process:
Dim WindowHandle as IntPtr
p = Process.GetCurrentProcess
WindowHandle = Process.GetCurrentProcess.MainWindowHandle()
Now, after you get that, you can't use it in .NET to get the parameters of the window you want. .NET doesn't expose such functionality. But! You can use that window handle to get the parameters using the Win32 API. But! Some of the values you get back will probably surprise you!
Send me an email address to send you the sample I wrote. It's a little too big to post here!
All you have to do is click on other windows, like the VS IDE to see some interesting Normal Position values. Try it with an IE window too.
RageInTheMachine9532
|
|
|
|
|
VS.NET already has lots of keyboard stuff in it. But be carefull I spent lotsa time trying to get shifted keys to work.
Private Sub Edit_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles Edit.KeyDown
Select Case e.KeyData
Case Keys.End
...
case Keys.Subtract Or Keys.Shift
...
end select
end sub
Just make sure to use Keys.??? or Keys.Shift if its a shifted key.
|
|
|
|
|
hi to all
I have a problem
How can i make or modify a .cpl file Control panel applet.
I want to modify windows control panel applets for this points .
I want to make a timedate.cpl for iranian calendar that name Is 'Shamsi'.
yeah . iranian calendar is solar calendar .
I want to modify the timedate applet that default shows English georgian Calendar to Shamsi calendar.
So thanks .
contact for me by : sa_tabrizi@yahoo.com
|
|
|
|
|
You can't modify an existing .CPL file, but you CAN write Control Panel Applications and Control Panel Extensions. Nearly all of the examples I've ever seen are written entirely in VC++, not VB. You can check out a couple of sites first to see if this is what you really want to do:
This[^] is a framework for VB that you can hang your own code on to make a control panel app. I've never used it so I can't attest to how easy it is to use.
This[^] is the start of the documentation on MSDN for Control Panel Applications. A CPApp is not a stand alone app (.EXE), but an extension to the Shell, this means it's in a .DLL. You'll have to export certain functions like CplApplet. Don't count on any VB examples in here, it's all C++ code.
RageInTheMachine9532
|
|
|
|
|
HI guys I'm working in VB6 and I need some help in creating a user control instance in code. I need to create lets say an X number of checkboxes and arrange them within a form. How do I create them dynaically in code to start with. Ay comments would be greatly appreciated
|
|
|
|
|
It has been a while but I think it is something like this.
dim chkbox as new checkbox
me.controls.add(chkbox)
'or possibly
dim o as object
set o = me.controls.add(chkbox)
Michael
|
|
|
|
|
note it is for vb6.0
dim chkbox as checkbox
set chkbox=controls.add("vb.checkbox","checkbox1")
chkbox.visible=true
chkbox.left=50
chkbox.height=50
chkbox.enabled=true
u can also change name (the second parameter in controls.add method) by concating string
|
|
|
|
|
note it is for vb6.0
dim chkbox as checkbox
set chkbox=controls.add("vb.checkbox","checkbox1")
chkbox.visible=true
chkbox.left=50
chkbox.height=50
chkbox.enabled=true
Note:-
u can also change name (the second parameter in controls.add method) by concating string
|
|
|
|
|
hi,
anyone kindly help me out? i want to load multiple files using richtextbox loadfile option(rtf.LoadFile) and all the contents of the files will come one by one and shown in the richtextbox in lines.there may be informations from the database also.what i'm doing, every time, the last file is loaded and overridden on the previous one.thus the contents of the last file being loaded are shown.i think if i can insert a newline between files being loaded then it will work.but standard newline property like vbcrlf didn't work.kindly help.this is urgent.thank you for reading this problem patiently.
|
|
|
|
|
The reason your text is getting over-written is because LoadFile scraps everything in the control before the new file is loaded.
Your going to need 2 RichTextBoxes, one visible, and one not. What you do is tell the hidden RichTextBox to do the LoadFile, then copy and paste the contents of the hidden RichTextBox to the Visible one. Add your blank line to the end of the visible RichTextBox, start over again.
Here is a little pseudo-code:
' RichTextBox1 is Visible, RichTextBox2 is not.
' And make sure RichTextBox1 is cleared of text first.
RichTextBox1.Visible = True
RichTextBox2.Visible = False
RichTextBox1.Clear()
' Now, for each filename:
' Have the hidden RTB (RichTextBox2) load the file we want
' then, select all the text in it
' then, tell the visible RTB (RichTextBox1) to Append the SelectedText in the hidden RTB
' and then, append a blank line to the bottom of the text.
For Each Filename
RichTextBox2.LoadFile(filename)
RichTextBox2.SelectAll()
RichTextBox1.AppendText(RichTextBox2.SelectedText)
RichTextBox1.AppendText(vbCrLf)
Next
RageInTheMachine9532
|
|
|
|
|
Sir i have a big probloum sir please help me other wise i will be fired... my prob is ...
I m developing project my project is completed running very fine but only 1 problom i have .. my program start and running movie files with using media player property over movie im using scrolling metter using IPLAY SCB files in overlay mode . when play first movie file it playing and overlay scrolling is good and when finish first movie file start 2nd movie file current media player window is gone and IPLAY scrolling file also gone.
i open IPLAY file with shell command like
dim opnfil
opnfil=Shell("fullpath of file ",1)
SO sir how can i handel shell file it should constantly play over movie file some time i want to hide and after some time it should play over movie again. Sir also tell me way how movie files alwayes open in same window, to play movie files using this code ..
mp.AutoStart = True
MP.FileName="Fullpath of file"
Please Sir Help me i will be fired ...I will highly oblized
yours Truly
Mamta Shukla
|
|
|
|
|
Hope I can find an answer here. Other forums dont have.My problem is how to enumerate those in "My Network Places".
The WNetEnum... function doesnt give me these. I tried using all the combination. If someone knows this, please let me know. a snippet is more appreciated. thanks
na
|
|
|
|
|
Those are stored as shortcuts in "C:\Documents and Settings\USERNAME\NetHood".
|
|
|
|
|
Thanks alot! Such a great help!
|
|
|
|
|
If it works, then you're welcome. If it doesn't, then I don't know who posted that with my name.
|
|
|
|
|
|
Hi Guys. I'm working in VB6 and need some help with the monthview control
I want t like have only the dates of a certain day ie.e mondays, tuesdays etc to be enabled and selectable whlst the rest of the days reain unselectable. Any ideas on how to do this .
|
|
|
|
|
I couldn't find a way to limit the selection to weekdays in the default control. I have another idea: if the user selects something from the default control that is not a week day, prohibit that selection and prompt the user to enter another value.
|
|
|
|
|
I was wondering how you would make an application run in the background when minimized to the system tray. I just mean when you pull up the task manager i want it to be running in the process window not the Application window. If it is possible i would like the code for both 6.0 and .NET. Thank You
|
|
|
|
|
Run the "application" as a service and start another application that controls a NotifyIcon that can observe and control the service. There are numerous examples on CP and other places of how to write a service in .NET; for VB6, you might look at the Desaware NT Service Toolkit.
|
|
|
|
|
Sorry for the hasty response earlier -- here is another simpler solution: instead of minimizing the window, make set Visible to false and set ShowInTaskBar to false, as well. It won't show in the task manager (at least not in Win2K/XP) and it won't display in the task bar either.
|
|
|
|
|
this is my first post...
im kinda new to VS.net, so take it easy . i have only worked with the vb console apps to date.
i was just wondering if there is a way to make an array out of a property procedure? i mean, i declare my property procedure named Score, which is a variable to store a test score, as a percentage. I want to have 3 test scores, and make an array so its easier later in the code when working with them. the reason i want a property method is so i can prevent scores > 100 and < 0. before using properties, i simply made a variable array named Score, storing 3 values of test scores. i want to do this exact same thing, but limiting input, using properties.
this is what i have so far:
Property Score() As single
Get
Return tempScore
End Get
Set(ByVal Value As String)
If Value < 0 Then
Console.WriteLine("Score average cannot be less than 0%.")
tempScore = 0
ElseIf Value > 100 Then
Console.WriteLine("Score average cannot be greater than 100%.")
tempScore = 100
Else
tempScore = Value
End If
End Set
End Property
ANY HELP is SINCERLY appreciated.
sorry if its unclear, as im not used to this.
Thank you.
Jordan.
III
|
|
|
|
|
ok.. i guess i got it working. here it is, if anyone cares:
Private tempScore(3) As Integer
Property score(ByVal i As Byte) As String
Get
Return tempScore(i)
End Get
Set(ByVal Value As String)
If Value < 0 Then
Console.WriteLine("Score average cannot be less than 0%.")
tempScore(i) = 0
ElseIf Value > 100 Then
Console.WriteLine("Score average cannot be greater than 100%.")
tempScore(i) = 100
Else
tempScore(i) = Value
End If
End Set
End Property
Jordan.
III
|
|
|
|