Solved

Using ocx from a VC console application

Posted on 2002-03-05
9
696 Views
Last Modified: 2008-02-07
Hi,
I'm using a third party .ocx in a VB environment without problem. Now I aim to use it within a Win32 console application (Visual C++ 6). My .ocx has not to interact any way with the user (no windows).
Is there a sample for this?
Best regards
0
Comment
Question by:cbonjovi
9 Comments
 
LVL 6

Expert Comment

by:Triskelion
ID: 6841617
How are you calling to the ocx?
Did you convert it to a class first?

You can create a fake (temporary) GUI just to get the ocx converted, then move it into your console app project.
0
 

Author Comment

by:cbonjovi
ID: 6841738
Ok, this is an idea.
The problem is temporary GUI and console app MUST BE the same .exe.
Could you provide a sample for this?
Thank you very much
Regards,
Christian
0
 

Expert Comment

by:wenderson
ID: 6843511
Win32 console applications are regular Windows applications, so if you want to create a window or a dialog, just call the correct functions, ex.:

#include <windows.h>

int main()
{
  MessageBox(0, "Hello there, GUI world!", "My Console Application", MB_OK);
  return 0;
}

The opposite is also true, you can create an GUI application which creates a console instead of a window.

Wenderson Teixeira
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Accepted Solution

by:
Triskelion earned 30 total points
ID: 6844476
I meant...
  You will only create the the temporary GUI app to make the class wizard allow you to import the ocx into your project.

Once the OCX has been converted to CPP/.h by the class wizard, you can copy the files over to your console app directory and add them to your project.

0
 

Author Comment

by:cbonjovi
ID: 6847257
I see Triskelion,
good idea, but I didn't understand how.
Could you provide an example?
Regards
0
 

Author Comment

by:cbonjovi
ID: 6847262
But at the end,
how to import an activex control in a VisualC++ console application?
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6848156
Yes, after you have created the class from the OCX, copy the .cpp and .h files into your console ap;p project directory.

Select
   project -> Add To Project -> Files
Browse and select the .h and .cpp files you just copied over.

You may need to change the header file name included in  the new .cpp file and remove the #include <stdafx.h>
0
 
LVL 11

Expert Comment

by:griessh
ID: 6955264
Dear cbonjovi

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "Triskelion"

comment(s) as an answer.

=========================================================
You have 20 open questions out of 41 that need your attention! Please take
some time and accept an answer if an expert was able to help you or
provide feedback if needed.
==========================================================

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 6979030
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VS2015 compilation and missing DLLs 9 163
Header of docx file 17 118
How to print into std::string like sprintf using C++11? 12 81
C++ help/ Toy problem 19 30
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question