15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Masked Edit OCX Questions

Lance Lovette -- lovette@iftech.com
Thursday, February 08, 1996

I'm using the MSMask OCX with 4.0 and I've got some questions about it.

1) When I set the mask, either with DDX_OCText or by using the member
   function SetMask I get the following message in the Debug window:

   'First-chance exception in xxx.exe (MSMASK32.OCX): 0xE06D7363: Microsoft C++
    Exception.'

   The exception isn't caught by my catch CException* (I don't expect it to)
   and it doesn't seem to affect anything so I just ignore it.  Does anyone
   else get this or know if it is something I should worry about?

2) I have the OCX in dialogs and in form views.  In running dialogs and
   when run in the Test mode of the dialog editor they look fine.  However when
   they are run in the application, they don't have the 3-D look when on a
   form view.  They all have the same properties so are the dialogs doing
   something the form view is not?

3) I can't seem to get the Format property to work. When I set it to one of
   the selections in the list, such as '$#,##0.00;($#,##0.00)' nothing
   happens.  How do I tell the edit that it is displaying numeric values
   or date/time values so it uses the Format string?

4) I mostly use it for entering currency.  However it is limiting to set the
   mask to ###,###.## so the user can enter currency up to 999,999.99.  I
   would rather be able to enter any currency value keeping the decimal for
   the cents.  A format like [unlimited #].##. Will the control do this?

5) The control has a lose focus event, however the ClassWizard does not know
   about this event so I can't add it to the event sink map.  I don't know
   much yet about OCX's, so I don't even know where to start looking for the
   numeric value associated with the lose focus event.  What is it and how
   would I find it?

Thanks,

Lance Lovette
lovette@iftech.com

+-----------------------------------------------------------------------------+
| Interface Technologies, Inc.
| Software Design & Programmer Training
|
| For a collection of free tutorials covering a variety of programming and   
| computer-related topics such as Visual C++, MFC, and Windows NT check out
| the ITI On-line Training Center at http://www.iftech.com.
+-----------------------------------------------------------------------------+



Mike Blaszczak -- mikeblas@interserv.com
Saturday, February 10, 1996

[Mini-digest: 2 responses]

On Thu, 8 Feb 1996, Lance Lovette  wrote:

>1) When I set the mask, either with DDX_OCText or by using the member
>   function SetMask I get the following message in the Debug window:
>
>   'First-chance exception in xxx.exe (MSMASK32.OCX): 0xE06D7363:
>   Microsoft C++ Exception.'

This isn't a problem.  Read up on the difference between "First-chance 
exceptions" and "Second-chance Exceptions" in MSDN.

>   The exception isn't caught by my catch CException* (I don't expect it to)
>   and it doesn't seem to affect anything so I just ignore it.  Does anyone
>   else get this or know if it is something I should worry about?

Of course not--it's caught by some exception handler in the control.

>2) I have the OCX in dialogs and in form views.  In running dialogs and
>   when run in the Test mode of the dialog editor they look fine.  However > 
  when
>   they are run in the application, they don't have the 3-D look when on a
>   form view.  They all have the same properties so are the dialogs doing
>   something the form view is not?

I'm relatively sure this is handled by an ambient property called 
"Appearence".  MFC doesn't support it inherently, so you need to handle it 
yourself.  This ambient is in the headers but it isn't documented, so maybe 
someone else (like JohnEls, my hero) can make sure I'm getting this the right 
way around.

>5) The control has a lose focus event, however the ClassWizard does not know
>   about this event so I can't add it to the event sink map.  I don't know
>   much yet about OCX's, so I don't even know where to start looking for the
>   numeric value associated with the lose focus event.  What is it and how
>   would I find it?

That's interesting.  I'll look into it.

.B ekiM
--
TCHAR szDisc[]=_T("These words are my own; I don't speak for Ken Berring.");

-----From: "John Elsbree" 

Lance -

I can answer a couple of these.

> 1) When I set the mask, either with DDX_OCText or by using the member
>    function SetMask I get the following message in the Debug window:
>    'First-chance exception in xxx.exe (MSMASK32.OCX): 0xE06D7363: Microsoft 
C++
>     Exception.'

The control is probably throwing and catching an exception, internal to 
itself, and the debugger is just letting you know that this is going on. Don't 
worry about it. There's nothing you could do about it, anyway. 

> 5) The control has a lose focus event, however the ClassWizard does not know
>    about this event so I can't add it to the event sink map.  I don't know
>    much yet about OCX's, so I don't even know where to start looking for the
>    numeric value associated with the lose focus event.  What is it and how
>    would I find it?

The documentation for the Masked Edit control is a little too VB-centric. Some 
of the events it describes (e.g., the LostFocus event) are not actually fired 
by the control; rather, they are generated by VB -- on the control's behalf -- 
when the control is being used in a VB form. You'll never see these events 
when using the control in other containers.

You could find out when the control gains or loses focus by overriding the 
IOleControlSite::OnFocus member function in your container. Unfortunately, 
this probably isn't a very easy function to override in an MFC 4.0 container. 
Sorry. It will be easier in MFC 4.2, I promise.

//mfcTeam.m_johnels;	// does not represent Microsoft



John & Annette Elsbree -- elsbree@msn.com
Tuesday, February 13, 1996

[Mini-digest: 2 responses]

Lance -

I now know the answer to one more of these. 

From: 	owner-mfc-l@netcom.com on behalf of Lance Lovette
3) I can't seem to get the Format property to work. When I set it to one of
   the selections in the list, such as '$#,##0.00;($#,##0.00)' nothing
   happens.  How do I tell the edit that it is displaying numeric values
   or date/time values so it uses the Format string?

I'm going to give you the answer, but you have to promise not to hold me 
personally responsible for the reason... This is going to sound unbelievable, 
but the Format property simply *doesn't do anything* in any container other 
than VB or Access. It seems the Masked Edit control relies on its container to 
do the actual formatting. It queries the container (actually, the client site, 
I believe) to obtain a private, container-specific interface called IVBFormat. 
If it doesn't find the interface, it doesn't format the text. It's that 
simple.

Folks, this is a classic example of a container-specific control that is 
virtually useless when placed in any other environment. If you're writing OLE 
controls of your own, let this be a lesson: in a general-purpose control, 
don't make any assumptions about specific container features that are critical 
to your control's operability.

#if _MFC_VER <= 0x0410
mfcTeam.m_johnels;	// does not represent Microsoft
#endif
-----From: "John Elsbree" 

>>2) I have the OCX in dialogs and in form views.  In running dialogs and
>>   when run in the Test mode of the dialog editor they look fine.  However
>> when
>>   they are run in the application, they don't have the 3-D look when on a
>>   form view.  They all have the same properties so are the dialogs doing
>>   something the form view is not?
>
> I'm relatively sure this is handled by an ambient property called 
> "Appearence".  MFC doesn't support it inherently, so you need to handle it 
> yourself.  This ambient is in the headers but it isn't documented, so maybe 
> someone else (like JohnEls, my hero) can make sure I'm getting this the 
right 
> way around.

No, I don't think that's it. MFC does implement the ambient Appearance 
property for OLE control containers (see COleControlContainer::GetAmbientProp 
in occcont.cpp). I can see no reason that the ambient Appearance property 
would operate differently in a form view than in a dialog, at least within the 
same app.

Lance, I'm unable to assemble a simple repro case for the problem you 
describe. Here's what I did:

1. Create a new project with AppWizard. SDI app, enable OLE control 
containment, change base class of view class from CView to CFormView.

2. Insert Component. Select MS Masked Edit control.

3. Open the form view's dialog resource; drag-n-drop a Masked Edit control 
onto the form.

4. Build and run.

The Masked Edit control I see on my form *does* have the 3D style.

#if _MFC_VER <= 0x0410
mfcTeam.m_johnels;	// does not represent Microsoft
#endif



Mike Blaszczak -- mikeblas@interserv.com
Wednesday, February 14, 1996

On Tue, 13 Feb 96, "John Elsbree"  wrote:
>> I'm relatively sure this is handled by an ambient property called 
>> "Appearence".  MFC doesn't support it inherently, so you need to handle it 
>> yourself.  This ambient is in the headers but it isn't documented, so >> 
maybe 
>> someone else (like JohnEls, my hero) can make sure I'm getting this the 
>> right way around.
>
>No, I don't think that's it. MFC does implement the ambient Appearance 
>property for OLE control containers (see
> OleControlContainer::GetAmbientProp in occcont.cpp).

Jeez, it is--I must've had my thumb on it before.

.B ekiM
--
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");





| Вернуться в корень Архива |