Clue Less
Is it possible to access a form object properties using it handle? What would the syntax look like? I’ve never used handles before.
Thanks
-William
Printable View
Clue Less
Is it possible to access a form object properties using it handle? What would the syntax look like? I’ve never used handles before.
Thanks
-William
I doubt it. Although I have myself used handles scarcely, I think the handle of a form will give you access to the window in which it is displayed, like a Window Handle that is used in C++/VC++. This handle will be accessible through the Form.hWnd property.
I think it would be possible to access the properties of a control from its handle.
I have used routines in the past that use API calls with control handles to return specific properties of a control.
The API calls probably exist to access just about any property, the problem is most of them are not well documented.
Yes it is possible but the syntax would look different and we would have to use API functions to do so. e.g
This is how we usually change an object's properties.
This is how we can change an object's properties using API.Code:Private Sub Command1_Click()
Command1.Visible = False
End Sub
Code:Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Sub Command1_Click()
ShowWindow Command1.hwnd, 0
End Sub
I doubt you can access all properties with API, just the ones related to the window
Two Gurus fighting ??
Anyway, as I said, I am Kedaman's side.
Hey
There is no need to take sides!!!!!!!!! We are just helping each other out by bouncing ideas and sharing skills with
fellow VB'ers. I think that any Guru will tell you that no one knows everything and we all have different thinking
process's. That makes each one of us a treasure to the programming world. When I post a question, I don't want
anyone to be afraid to post a response, nor do I want to be cut down for any thoughts that I may have.
So Please, don't divide us. support is much better for all of us.
However I still don't quite get this handle stuff?
Thank's for any input!
-William
I don't think Kedaman was arguing with me. He was pointing out that there are some that cannot be manipulated.Quote:
Two Gurus fighting ??
I have to disagree with you on this. All properties having to do with the Window's appearance (Styles and Extended Styles, colours, font) can be changed, as with many of the behaviour properties. Actually, that's how VB sets properties. When you write Command1.Visible = False, you are really using the ShowWindow API and writing ShowWindow Command1.hWnd, 0. A lot of programming relies on API. When you add a Dialog, you are really using CreateWindowEx or CreateWindow API and creating an instance of the ThunderForm Class. All this can be complicated so VB saves you from having to write it.Quote:
I doubt you can access all properties with API, just the ones related to the window
Hey
So Handles are mostly for APIs? or only for APIs?
-William
CorrectQuote:
I don't think Kedaman was arguing with me. He was pointing out that there are some that cannot be manipulated.
the hwnd is the window handle, sure you can put anything that uses the handle, but it's meant for use with API calls
So I could not manipulated a runtime built form object directly by using its handle? with something like this?
dim f as Form
f = Me.Hdc 'just guessing, I know that this will give me a long int.
f.Caption = "Hello"
Thank's
-William
No you cannot change a property like that. You must use an API function to change it:
Also, the hDC property is a handle to the DC (Device Context) not the Window itself. The hWnd is the handle to the Window.Code:Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Command1_Click()
SetWindowText Me.hwnd, "NewText"
End Sub
OK. That helps, sorry if I am a little slow.
Thanks, you guys are Great!!
-William
I have to apologize for that statement. Actually I didn't think you all would take it so seriously.
And thanks for the discussion.