|
-
Jul 28th, 2000, 02:45 AM
#1
Thread Starter
Member
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
-
Jul 28th, 2000, 05:10 AM
#2
Well ....
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.
-
Jul 28th, 2000, 06:32 AM
#3
I think its possible
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.
-
Jul 28th, 2000, 09:20 AM
#4
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.
Code:
Private Sub Command1_Click()
Command1.Visible = False
End Sub
This is how we can change an object's properties using API.
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
-
Jul 28th, 2000, 01:00 PM
#5
transcendental analytic
I doubt you can access all properties with API, just the ones related to the window
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 28th, 2000, 01:06 PM
#6
Well ....
Two Gurus fighting ??
Anyway, as I said, I am Kedaman's side.
-
Jul 28th, 2000, 01:29 PM
#7
Thread Starter
Member
Taking Sides?
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
-
Jul 28th, 2000, 02:02 PM
#8
I don't think Kedaman was arguing with me. He was pointing out that there are some that cannot be manipulated.
I doubt you can access all properties with API, just the ones related to the window
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.
-
Jul 28th, 2000, 02:29 PM
#9
Thread Starter
Member
Hey
So Handles are mostly for APIs? or only for APIs?
-William
-
Jul 28th, 2000, 02:38 PM
#10
transcendental analytic
I don't think Kedaman was arguing with me. He was pointing out that there are some that cannot be manipulated.
Correct
the hwnd is the window handle, sure you can put anything that uses the handle, but it's meant for use with API calls
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 28th, 2000, 03:00 PM
#11
Thread Starter
Member
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
-
Jul 28th, 2000, 03:08 PM
#12
No you cannot change a property like that. You must use an API function to change it:
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
Also, the hDC property is a handle to the DC (Device Context) not the Window itself. The hWnd is the handle to the Window.
-
Jul 28th, 2000, 03:14 PM
#13
Thread Starter
Member
OK. That helps, sorry if I am a little slow.
Thanks, you guys are Great!!
-William
-
Jul 28th, 2000, 09:34 PM
#14
Well ....
I have to apologize for that statement. Actually I didn't think you all would take it so seriously.
And thanks for the discussion.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|