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!!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.