?
Solved

About Custom controls

Posted on 1998-05-27
13
Medium Priority
?
306 Views
Last Modified: 2013-11-20
I am searching for some basic samples wich use custom controls in MFC.
(I am using Microsoft Visual C++ 5.0)
I have found some samples by Microsoft but these are written for windows 3.0 & 3.1.

Can some one tell me were to found some samples.

Thanks,
Mike
0
Comment
Question by:mike_marquet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +3
13 Comments
 

Expert Comment

by:rosborn051498
ID: 1315526
What do you mean by "custom controls"?  What do you want to do?
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1315527
Mike,

Personally, if I were you I would be inclined to write and use ActiveX controls. However, I'll trust that you have your reasons for wanting "custom controls".

Having said that, Coriolis Group Books has a book called Windows Programming Power with Custom Controls by Paul Cilwa and Jeff Duntemann. It's a couple of years old, however, the code is still perfectly valid.

With everyone moving to ActiveX, I don't think you'll find much more in terms of books on writing custom controls.

Tom

0
 
LVL 3

Expert Comment

by:tma050898
ID: 1315528
BTW, if you are interested in learning ActiveX, Wrox has a great beginner level book calld "Visual C++ Components with MFC Extensions & ActiveX Controls" by Matt Telles. This book will get you up and running very quickly on your first ActiveX controls.

Tom
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:tma050898
ID: 1315529
Mike,

If you want us to help you I would suggest that...

1. You state specifically what it is you need
2. When you reject an proposed answer, you explain why the answer didn't fit your needs

Tom

0
 

Author Comment

by:mike_marquet
ID: 1315530
Ok,

What I really want is a sample application (an example) which use a 'custom control' (insert with the resource workshop). I want to know how I must instanced this control ?
What kind of parameter I must set in the properties of the control in the resource ?
 (Caption,CLASS,Style & ExStyle)
How to proceed with the class that will by used for this new control.
For example, I want that all message for this custom control goes to this class (my class) :

class CIO_LED : public CWnd
 {
  ....
 }

-----------------

This is the InitDialog function off the dialog that has the custom control :
(where m_MyControl is declared in the header like CIO_LED m_MyControl)

void CMyDialog::InitDialog()
 {
  CDiaolg::InitDialog();

  m_MyControl.SubclassDlgItem(ID_CUSTOMCONTROL);
 }
0
 

Expert Comment

by:rosborn051498
ID: 1315531
(Assuming you're using Developer's Studio:)

Here's a quick, possibly incomplete answer:  It will get you started.

Basically, you add an ActiveX control to your project by bringing up a dialog (template) and selecting Project|Add To Project|Components and Controls|Registered ActiveX Controls from menu.  Select a control from the list.  

Dev Studio will create a "wrapper class" for the control, which provides stubs for all the property gets/sets, and methods.  While still viewing your dialog, bring up Class Wizard.  Under Member Variables, be sure your dialog's class is selected under Class Name and select the Control ID of the control you just added.  Click on Add Variable and type in a name for the variable.  Dev Studio will add the member variable to your dialog class's header file (*.h).  All you need to do is use the variable to call the control's member functions.

Also, make sure the call to AfxEnableControlContainer(); is in the InitInstance handler of CTheApp (the main app program).

Basically, you call the get/set properties of the control.  Each control will be different.  You can also bring up custom property sheets for controls during design mode.  Bring up your dialog, right click on a control and select Properties.  Look under the All tab.  You can set properties here as well.

Try this and if you have specific questions (and I'm sure you will) ask them after you experiment a little.





0
 

Author Comment

by:mike_marquet
ID: 1315532
There was propably a mistack.
I doesn't want to use ActiveX control but Custom control. This is a control
avalaible in the resource workshop of Microsoft Visual C++ 5.0.
You can find this control in the 'controls' list of the resource workshop.
The button for this control is a 'HEAD'.

For ActiveX control, I have already created some one.

Thanks,
Mike
0
 

Expert Comment

by:rosborn051498
ID: 1315533
You lost me.  I thought VC++ Version 5.0 ran under Developer Studio, which integrates resource workshop.  I can't find a 'controls' list, other than as I described in previous comment.  Maybe there's a difference between VC++ 5.0 pro version and standard version?  Anyway, good luck.
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1315534
Ok, Now I'm totally lost. Do you want to write a custom control or simply use one??? If you want to simply use a control, which one? I have no idea what you are asking!!!
0
 

Expert Comment

by:Beatachon
ID: 1315535
I'm lost too, I'm afraid. I got the impression that you want to just make a plain beginning "backdrop" so to speak in the resource workshop (Like a button or window) and the alter it program-wise at run time with special message handling, look and feel, etc. Is this what you want?
0
 

Author Comment

by:mike_marquet
ID: 1315536
My English is not so perfect !
When you go to the resource workshop, you can drag for example a Edit Control to
your Dialog (or a Static control, ...).Whis this floating toolbar, you can insert in your dialog :
- Group box
- Static control
- Edit control
- List control
- button control
- radio button
- combo box
- list box
- slider control
- ...
AND custom control

When you insert some control in the dialog it appers like a grayed rectangle and when
you look in the properties of this control you can see this :

Custom Control Properties
ID .....................                 Caption
Visible         Group              Class
Disabled      Tab Stop           Style
Help ID                               ExStyle

How must I proceed to use this control ????


Thanks for answer
Mike
0
 

Expert Comment

by:mmachie
ID: 1315537
try www.codeguru.com and look in the controls area and then look for datetimepicker.  one of these uses the custom control to create the datetime picker.
good luck,

mikem
0
 

Accepted Solution

by:
ajh020797 earned 60 total points
ID: 1315538
The custom control option is for when you have created your
own windows classes and registered them.

You would register your own window class in the initinstance
giving it a name.  From then on whenever a window is created
which contains a custom control with that class name, your
window class will be used.

Each window class has a number of styles and a windows procedure.

You could just create custom controls from the window classes
already in existance such as EDIT, LISTBOX etc.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

765 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