Results 1 to 14 of 14

Thread: Handle ?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 1999
    Location
    Reno, NV
    Posts
    57
    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


  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3
    Guest

    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.

  4. #4
    Guest
    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

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  6. #6
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ....

    Two Gurus fighting ??

    Anyway, as I said, I am Kedaman's side.

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 1999
    Location
    Reno, NV
    Posts
    57

    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

  8. #8
    Guest
    Two Gurus fighting ??
    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.

  9. #9

    Thread Starter
    Member
    Join Date
    Apr 1999
    Location
    Reno, NV
    Posts
    57
    Hey

    So Handles are mostly for APIs? or only for APIs?

    -William

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  11. #11

    Thread Starter
    Member
    Join Date
    Apr 1999
    Location
    Reno, NV
    Posts
    57
    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


  12. #12
    Guest
    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.

  13. #13

    Thread Starter
    Member
    Join Date
    Apr 1999
    Location
    Reno, NV
    Posts
    57
    OK. That helps, sorry if I am a little slow.

    Thanks, you guys are Great!!

    -William

  14. #14
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width