Solved

About Custom controls

Posted on 1998-05-27
13
298 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
  • 4
  • 3
  • 3
  • +3
13 Comments
 

Expert Comment

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

Expert Comment

by:tma050898
Comment Utility
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
Comment Utility
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
 
LVL 3

Expert Comment

by:tma050898
Comment Utility
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
Comment Utility
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
Comment Utility
(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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:mike_marquet
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 20 total points
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

11 Experts available now in Live!

Get 1:1 Help Now