Solved

Using ocx from a VC console application

Posted on 2002-03-05
9
686 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now