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

    Exclamation Help on c++ Window Form and Handle

    Guys,



    i can just create a new item "Form (.net)" and then how can i show the form in my "Main()" execution? subsequently getting the form handle value...

    Okay, i got the method working however i bump into another problem here. how can i get through the following?

    why is
    Application::Run(myfrm);
    stop my "Main()" from proceeding ?? by right it is just suppose to launch the form and then still proceed to execute the rest of the code right??

    i dont get it please advise?.....

    my purpose here is to get the form launch out and proceed with the rest of the remaining code..



    Please advise.

    Thank You;
    Last edited by codegurugeek; September 14th, 2005 at 04:34 AM.

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Help on c++ Window Form and Handle

    MSDN documentation is not 100% clear about Run method. This methid is synchronous and returns only when form is closed and disposed:
    "The Dispose method of the Form class will be called prior to the return of this method."
    After call to Application::Run method you can only add clean-up code to the Main function, which is executed before application exits. If you want to execute some code when form is active, move it to one of form message handlers, for example, Form_Load.

  3. #3
    Join Date
    Feb 2005
    Posts
    64

    Talking Re: Help on c++ Window Form and Handle

    oh. ya.. that is the point.. instead of calling the application to run... just call out the form to load and then show up would be a definite good idea.. thank you alex f.. let me try it out now.

  4. #4
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Help on c++ Window Form and Handle

    Actually, this is not what I suggest. Don't remove Application::Run call. Move the code which you have now after Application::Run from main function to one of form event handlers.

  5. #5
    Join Date
    Feb 2005
    Posts
    64

    Red face Re: Help on c++ Window Form and Handle

    i dont quite understand your context here. Please elaborate a little further?

    Which form event handler do you mean ?

  6. #6
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Help on c++ Window Form and Handle

    Please show your existing code and describe what do you want to do.

  7. #7
    Join Date
    Feb 2005
    Posts
    64

    Red face Re: Help on c++ Window Form and Handle

    Okay, here is the situation...


    In the Main() , i have this following method issued to preview the video onto a form.
    Declare a form by code and then subsequently getting the form handle in hwnd format.
    ...
    ...
    ...
    SetVideoClippingWindow(mywindhandle);
    Actually, what i was trying to do is to put the video preview onto a form by passing the form handle into the above "SetVideoClippingWindow function..

  8. #8
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Help on c++ Window Form and Handle

    Add Load event handler to the form and move this code to it:

    Code:
    private: System::Void Form1_Load(System::Object *  sender, System::EventArgs *  e)
    {
        SetVideoClippingWindow(get_Handle());
    
    }
    To add Load handler you can double-click form in the designer.

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