0

Hi there. I am just learning vc++ and it's all new to me, so I need a bit of help.
This could be a daft question, but where do i put my user code to initialize a USB port?

I can see where the button click functions are, but where does init code go?, i.e. a function that runs once when the windows application is first started up, without clicking any buttons?

|Thanks very much for any help!!

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by mike_2000_17
0

Well, there are several places to put it, depending on what you want. I am not an expert with VC++, so the names I give my not apply directly (they would apply directly to Borland C++Builder and VCL) but usually they correspond well. Usually there are callback functions, like OnClick() for the button click, but for initialization and finalization, such as OnCreate() (at creation of the window / application), OnShow() (at appearance of the window), OnDestroy() or OnRelease() (at destruction of window / application), OnHide() (at the disappearance of the window).

Otherwise, there are also the actual constructor/destructor of the custom Form classes that VC++ would generate (I assume). Or even deeper, you can put it in the WinMain function that you can find somewhere in the project's source file, but I wouldn't recommend that, it's too far deep and could have some nasty consequences.

Hopefully somebody here with more knowledge of VC++ can tell you more exactly where to find these places to put init code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.