CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009
    Posts
    1

    Question button programming questions...

    Ok, I know that might be something easy, but that's my first time with Visual Studio C++ (2008) and I'm a bit lost here.

    I'm working with a Windows Form (CLR) and there I have the button: Connect.
    If the user press it, then the program should call the function connectsock(), to do the socket connection.

    The program creates this Form1.h and myprogram.cpp. If I press the button twice in the form interface, its code is automatically generated, right?

    So now comes my question:

    where should I call the function connectsock()?
    I thought I should call the fuction in myprogramm.cpp, and maybe put a condition: if(button1-> enabled) then call connectsock(). But it doesnt recognize the button1, although form1.h is included here.

    If I try to call it direct from the button1_Click function, then it doenst work either. And actually I think it would make more sense to call it from the .cpp file, cause afterwards I will use there the result from it.

    Can anybody tell my how to do this?

    Thanks in advance!

  2. #2
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: button programming questions...

    You are supposed to call connectsock in the event handler of your button (most probably in CPP file). There is no need to check for button enable state, since user has clicked when it is enabled and thus program control reaches at that point.

    Make sure that 'button1' is correct variable name.

    You should ask CLI/CLI/MC++ related questions in appropriate forum. This is core VC++ forum, where you may not get proper answes.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

Tags for this Thread

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