CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2001
    Posts
    26

    using a control in a formless program

    Hi

    I have a VB program that starts from Sub Main and It has not any form but I want to use a control. How can I use this control without any form that i can drop my control on it?


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: using a control in a formless program

    Erm, you can't really.

    You see the events that a control fires are really only wrappers to the windows messages that the contol's window raises and most of the methods are likewise.
    Without a parent window on which the control is places, these WM_PARENTNOTIFY messages will go nowhere.

    If it's not a silly question - why do you want a control but no window? There may be another solution.

    Hope this helps,
    Duncan


    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Mar 2001
    Posts
    26

    Re: using a control in a formless program

    Hi and thanks for your response

    I answer to your question:
    because my control task is establishing a http connection and sending some info to a server but I dont have anything to display and my program starts automatically and must be terminated automatically

    thanks
    Ehsan


  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: using a control in a formless program

    You can create a form and not show it.

    To use the form (if it is called frmConnect, and the HTTP control is called ctlConnect)


    public Sub Main()

    Dim myFrm as frmConnect

    set myFrm = new frmConnect
    With myFrm.ctlConnect
    '\\ do some processing
    End With

    set myFrm = nothing

    End Sub





    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    Mar 2001
    Posts
    26

    Re: using a control in a formless program

    Thanks but I have some probles yet.
    when I destroy the form using

    set xxx = nothing



    the form destroys but I want to terminate the program too. how can I do it?

    Thanks a lot
    Ehsan


  6. #6
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163

    Re: using a control in a formless program

    Use the End Statement after unloading the form in the form_unload event.
    form = Nothing
    End


  7. #7
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: using a control in a formless program

    If program do not terminate after you destroy the form, you have something still loaded. Check for object you dinamically loaded and unload them and set them to nothing. Maybe you do not effectively destroied the form, if you used it to create a control (= unload and destroy the control first).

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  8. #8
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: using a control in a formless program

    I would check for not unloaded object or active references, first

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured