Results 1 to 7 of 7

Thread: Creating form with api calls.

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2001
    Posts
    32

    Creating form with api calls.

    Ok, I have some code that will create a form, listbox, and two buttons. I want to be able to upon pressing the OK button the data selected in the listbox must be returned. In the long run, I want this whole thing to work like an msgbox or inputbox, but will use an listbox instead. As of right now, I cannot get the buttons to work. Could you guys take a peek and see what I am doing wrong. Also, do you have any code that will allow me to get the selected data out of the listbox.

    Thanks.

    I have attached to module.

  2. #2
    jim mcnamara
    Guest
    Your code looks like Charles Petzold playing VB.

    Don't subclass the buttons - you've already got the GetMessage function. Test for mouse button activity in there. Just put a bunch of case statements to trap what you need by hWnd of the window (buttons) of interest

    Send WM_GETTEXT to the listbox to return the text. The text has to be returned in a Property statement to the client.

    I don't see any interface definitions or Implements or whatever.
    You need those, as I assume you know.

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2001
    Posts
    32
    If I may ask, who is Charles Petzold? I am not sure of a good way to do this because the only examples I have found always seem to come from the api guide which I already have. I want to learn how to do this not just be able to copy and paste code; so, if anyone has a good site or book to learn how to use apis, then let me know. I will work on your suggestion because I feel like there should be an easier way than what I am current doing. If you or anyone has any code that could aid in learning how to do this, please post it.

  4. #4
    jim mcnamara
    Guest
    Charles Petzold is one of the designers of Windows 16 bit & 32 bit.

    He has several books on programming Windows. Basically, what you are doing is better off done in C. The reason is that a lot of api's you will need are inaccessible from VB. As I understand it, VB.NET gets around those restrictions, so hang in there.
    Most windows internals books are C-based, as are Petzold's.

    Suggestions:

    www.mvps.org --- there is a lot of material at several MVP sites

    www.mvps.org/vb/hardcore ---
    online copy of Hardcore Visual Basic - a must.

    Visual Basic Bible - covers a lot of what you are doing. Monstrous tome.

    Search the vbforum here for: subclassing

    And since Hardcore is a freebie, you really should consider downloading and reading it. It will get you past a lot of problems you are now having.

    When I have some time, I'll get your code going, but I don't have VB on this machine, just C. From the tone of your reply, I'd guess that you really did just cut and paste. Please read Hardcore.

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2001
    Posts
    32
    Thanks. At the time of my post I was still trying to figure out what was even going on and was hoping I could get some help understanding it.

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2001
    Posts
    32
    could I write this in C and use it in VB?

  7. #7
    jim mcnamara
    Guest
    C++ -- Of course, as long as you provide a COM interface for the control.

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