How to position dynamic CStatic control

I have a sub-classed Edit Control.  Within this sub-classed edit control, I 
would like to optionally display an asterisk in the upper right corner 
(outside the actual edit control).  I am using a dynamically create CStatic, 
but it does not display.  I think the issue is the CRect for the position.

Here is my code for creating the CStatic:

************* snip snip *****************
 CRect windowRect;
 CRect asterRect;

 // -- Get Screen Co-ordinates --
 GetWindowRect(windowRect);

 // -- Create Asterisk Static control --
 asterRect.top = windowRect.top;
 asterRect.bottom = windowRect.bottom;
 asterRect.left = windowRect.right + 12;
 asterRect.right = asterRect.left + 8;

 m_pRedAster = new CStatic;
 if (m_pRedAster)
  {
  if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, asterRect, 
GetParent()))
   {
   m_pRedAster->ShowWindow(SW_NORMAL);
   }
  }
************* snip snip *****************

What is the best way to calculate the position/size of the CStatic 
control?????

-- 
Hank Williams
Quantum Technologies, Inc.
HaWilliams(at)spamcop.net
--


0
Hank
3/14/2005 3:48:48 PM
vc.mfc 33608 articles. 0 followers. Follow

16 Replies
1081 Views

Similar Articles

[PageSpeed] 26

 m_pRedAster->GetClientRect(&rect);
int width = rect.right - rect.left;

and so on. To move it, its CWnd derrived, use MoveWindow.

- Mark R

"Hank Williams" <HaWilliams(at)msn.com> wrote in message 
news:efDuc1KKFHA.1392@TK2MSFTNGP10.phx.gbl...
>I have a sub-classed Edit Control.  Within this sub-classed edit control, I 
>would like to optionally display an asterisk in the upper right corner 
>(outside the actual edit control).  I am using a dynamically create 
>CStatic, but it does not display.  I think the issue is the CRect for the 
>position.
>
> Here is my code for creating the CStatic:
>
> ************* snip snip *****************
> CRect windowRect;
> CRect asterRect;
>
> // -- Get Screen Co-ordinates --
> GetWindowRect(windowRect);
>
> // -- Create Asterisk Static control --
> asterRect.top = windowRect.top;
> asterRect.bottom = windowRect.bottom;
> asterRect.left = windowRect.right + 12;
> asterRect.right = asterRect.left + 8;
>
> m_pRedAster = new CStatic;
> if (m_pRedAster)
>  {
>  if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, asterRect, 
> GetParent()))
>   {
>   m_pRedAster->ShowWindow(SW_NORMAL);
>   }
>  }
> ************* snip snip *****************
>
> What is the best way to calculate the position/size of the CStatic 
> control?????
>
> -- 
> Hank Williams
> Quantum Technologies, Inc.
> HaWilliams(at)spamcop.net
> --
>
> 


0
markyr1 (230)
3/14/2005 4:16:00 PM
If all you want is to show * next to edit control, you can place a
CStatic next to edit control in resource editor itself. Simply change
its text to * or not dynamically using SetWindowText().

-------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
3/14/2005 4:19:01 PM
You are creating control using window rectangle returned with screen 
coordinates that may fall beyond client rectangle created window belongs to.
Use ScreenToClient to recalculate coordinates.
If static control is created as child of an edit control it may be painted 
over.


"Hank Williams" wrote:

> I have a sub-classed Edit Control.  Within this sub-classed edit control, I 
> would like to optionally display an asterisk in the upper right corner 
> (outside the actual edit control).  I am using a dynamically create CStatic, 
> but it does not display.  I think the issue is the CRect for the position.
> 
> Here is my code for creating the CStatic:
> 
> ************* snip snip *****************
>  CRect windowRect;
>  CRect asterRect;
> 
>  // -- Get Screen Co-ordinates --
>  GetWindowRect(windowRect);
> 
>  // -- Create Asterisk Static control --
>  asterRect.top = windowRect.top;
>  asterRect.bottom = windowRect.bottom;
>  asterRect.left = windowRect.right + 12;
>  asterRect.right = asterRect.left + 8;
> 
>  m_pRedAster = new CStatic;
>  if (m_pRedAster)
>   {
>   if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, asterRect, 
> GetParent()))
>    {
>    m_pRedAster->ShowWindow(SW_NORMAL);
>    }
>   }
> ************* snip snip *****************
> 
> What is the best way to calculate the position/size of the CStatic 
> control?????
> 
> -- 
> Hank Williams
> Quantum Technologies, Inc.
> HaWilliams(at)spamcop.net
> --
> 
> 
> 
0
RainMan6256 (150)
3/14/2005 4:21:05 PM
Yes, but how do I calculate the 'top' and 'left' values????

-- 
Hank Williams
Quantum Technologies, Inc.
HaWilliams(at)spamcop.net
--

"Mark Randall" <markyr@REMOVETHISgoogle.ANDTHIScom> wrote in message 
news:etZgfELKFHA.244@TK2MSFTNGP12.phx.gbl...
> m_pRedAster->GetClientRect(&rect);
> int width = rect.right - rect.left;
>
> and so on. To move it, its CWnd derrived, use MoveWindow.
>
> - Mark R
>
> "Hank Williams" <HaWilliams(at)msn.com> wrote in message 
> news:efDuc1KKFHA.1392@TK2MSFTNGP10.phx.gbl...
>>I have a sub-classed Edit Control.  Within this sub-classed edit control, 
>>I would like to optionally display an asterisk in the upper right corner 
>>(outside the actual edit control).  I am using a dynamically create 
>>CStatic, but it does not display.  I think the issue is the CRect for the 
>>position.
>>
>> Here is my code for creating the CStatic:
>>
>> ************* snip snip *****************
>> CRect windowRect;
>> CRect asterRect;
>>
>> // -- Get Screen Co-ordinates --
>> GetWindowRect(windowRect);
>>
>> // -- Create Asterisk Static control --
>> asterRect.top = windowRect.top;
>> asterRect.bottom = windowRect.bottom;
>> asterRect.left = windowRect.right + 12;
>> asterRect.right = asterRect.left + 8;
>>
>> m_pRedAster = new CStatic;
>> if (m_pRedAster)
>>  {
>>  if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, asterRect, 
>> GetParent()))
>>   {
>>   m_pRedAster->ShowWindow(SW_NORMAL);
>>   }
>>  }
>> ************* snip snip *****************
>>
>> What is the best way to calculate the position/size of the CStatic 
>> control?????
>>
>> -- 
>> Hank Williams
>> Quantum Technologies, Inc.
>> HaWilliams(at)spamcop.net
>> --
>>
>>
>
> 


0
Hank
3/14/2005 4:30:43 PM
Yes, but I am fairly lazy.  I do not want to go through 200 dialogs and add 
a CStatic (With Resource Id) for each field on each dialog.

It can be calculated from within the subclassed Edit controls.

-- 

Hank Williams
Quantum Technologies, Inc.
HaWilliams(at)spamcop.net
--

"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
news:1110817141.216587.223770@g14g2000cwa.googlegroups.com...
> If all you want is to show * next to edit control, you can place a
> CStatic next to edit control in resource editor itself. Simply change
> its text to * or not dynamically using SetWindowText().
>
> -------
> Ajay Kalra
> ajaykalra@yahoo.com
> 


0
Hank
3/14/2005 4:32:27 PM
Where would I use 'ScreenToClient'??
1) After GetWindowRect before 'asterRect' calcs?
2) After 'asterRect' calcs????

-- 

Hank Williams
Quantum Technologies, Inc.
HaWilliams(at)spamcop.net
--

"RainMan" <RainMan@online.nospam> wrote in message 
news:309BF267-67EA-47A0-86DD-7CF8686F6902@microsoft.com...
> You are creating control using window rectangle returned with screen
> coordinates that may fall beyond client rectangle created window belongs 
> to.
> Use ScreenToClient to recalculate coordinates.
> If static control is created as child of an edit control it may be painted
> over.
>
>
> "Hank Williams" wrote:
>
>> I have a sub-classed Edit Control.  Within this sub-classed edit control, 
>> I
>> would like to optionally display an asterisk in the upper right corner
>> (outside the actual edit control).  I am using a dynamically create 
>> CStatic,
>> but it does not display.  I think the issue is the CRect for the 
>> position.
>>
>> Here is my code for creating the CStatic:
>>
>> ************* snip snip *****************
>>  CRect windowRect;
>>  CRect asterRect;
>>
>>  // -- Get Screen Co-ordinates --
>>  GetWindowRect(windowRect);
>>
>>  // -- Create Asterisk Static control --
>>  asterRect.top = windowRect.top;
>>  asterRect.bottom = windowRect.bottom;
>>  asterRect.left = windowRect.right + 12;
>>  asterRect.right = asterRect.left + 8;
>>
>>  m_pRedAster = new CStatic;
>>  if (m_pRedAster)
>>   {
>>   if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, 
>> asterRect,
>> GetParent()))
>>    {
>>    m_pRedAster->ShowWindow(SW_NORMAL);
>>    }
>>   }
>> ************* snip snip *****************
>>
>> What is the best way to calculate the position/size of the CStatic
>> control?????
>>
>> -- 
>> Hank Williams
>> Quantum Technologies, Inc.
>> HaWilliams(at)spamcop.net
>> --
>>
>>
>> 


0
Hank
3/14/2005 4:35:00 PM
It does not matter as long as ScreenToClient is called before Create.

"Hank Williams" wrote:

> Where would I use 'ScreenToClient'??
> 1) After GetWindowRect before 'asterRect' calcs?
> 2) After 'asterRect' calcs????
> 
> -- 
> 
> Hank Williams
> Quantum Technologies, Inc.
> HaWilliams(at)spamcop.net
> --
> 
> "RainMan" <RainMan@online.nospam> wrote in message 
> news:309BF267-67EA-47A0-86DD-7CF8686F6902@microsoft.com...
> > You are creating control using window rectangle returned with screen
> > coordinates that may fall beyond client rectangle created window belongs 
> > to.
> > Use ScreenToClient to recalculate coordinates.
> > If static control is created as child of an edit control it may be painted
> > over.
> >
> >
> > "Hank Williams" wrote:
> >
> >> I have a sub-classed Edit Control.  Within this sub-classed edit control, 
> >> I
> >> would like to optionally display an asterisk in the upper right corner
> >> (outside the actual edit control).  I am using a dynamically create 
> >> CStatic,
> >> but it does not display.  I think the issue is the CRect for the 
> >> position.
> >>
> >> Here is my code for creating the CStatic:
> >>
> >> ************* snip snip *****************
> >>  CRect windowRect;
> >>  CRect asterRect;
> >>
> >>  // -- Get Screen Co-ordinates --
> >>  GetWindowRect(windowRect);
> >>
> >>  // -- Create Asterisk Static control --
> >>  asterRect.top = windowRect.top;
> >>  asterRect.bottom = windowRect.bottom;
> >>  asterRect.left = windowRect.right + 12;
> >>  asterRect.right = asterRect.left + 8;
> >>
> >>  m_pRedAster = new CStatic;
> >>  if (m_pRedAster)
> >>   {
> >>   if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, 
> >> asterRect,
> >> GetParent()))
> >>    {
> >>    m_pRedAster->ShowWindow(SW_NORMAL);
> >>    }
> >>   }
> >> ************* snip snip *****************
> >>
> >> What is the best way to calculate the position/size of the CStatic
> >> control?????
> >>
> >> -- 
> >> Hank Williams
> >> Quantum Technologies, Inc.
> >> HaWilliams(at)spamcop.net
> >> --
> >>
> >>
> >> 
> 
> 
> 
0
RainMan6256 (150)
3/14/2005 4:49:04 PM
If you are fairly lazy, why do you expect assistance in being lazy here?

- Mark R

"Hank Williams" <HaWilliams(at)msn.com> wrote:
> Yes, but I am fairly lazy.  I do not want to go through 200 dialogs and 
> add a CStatic (With Resource Id) for each field on each dialog.
>
> It can be calculated from within the subclassed Edit controls.
>
> -- 
>
> Hank Williams
> Quantum Technologies, Inc.
> HaWilliams(at)spamcop.net 


0
markyr1 (230)
3/14/2005 5:01:45 PM
10-4.  Thanks.

-- 

Hank Williams
Quantum Technologies, Inc.
HaWilliams(at)spamcop.net
--

"RainMan" <RainMan@online.nospam> wrote in message 
news:C7D20BF5-6395-4EBF-83CF-356C86006DB5@microsoft.com...
> It does not matter as long as ScreenToClient is called before Create.
>
> "Hank Williams" wrote:
>
>> Where would I use 'ScreenToClient'??
>> 1) After GetWindowRect before 'asterRect' calcs?
>> 2) After 'asterRect' calcs????
>>
>> -- 
>>
>> Hank Williams
>> Quantum Technologies, Inc.
>> HaWilliams(at)spamcop.net
>> --
>>
>> "RainMan" <RainMan@online.nospam> wrote in message
>> news:309BF267-67EA-47A0-86DD-7CF8686F6902@microsoft.com...
>> > You are creating control using window rectangle returned with screen
>> > coordinates that may fall beyond client rectangle created window 
>> > belongs
>> > to.
>> > Use ScreenToClient to recalculate coordinates.
>> > If static control is created as child of an edit control it may be 
>> > painted
>> > over.
>> >
>> >
>> > "Hank Williams" wrote:
>> >
>> >> I have a sub-classed Edit Control.  Within this sub-classed edit 
>> >> control,
>> >> I
>> >> would like to optionally display an asterisk in the upper right corner
>> >> (outside the actual edit control).  I am using a dynamically create
>> >> CStatic,
>> >> but it does not display.  I think the issue is the CRect for the
>> >> position.
>> >>
>> >> Here is my code for creating the CStatic:
>> >>
>> >> ************* snip snip *****************
>> >>  CRect windowRect;
>> >>  CRect asterRect;
>> >>
>> >>  // -- Get Screen Co-ordinates --
>> >>  GetWindowRect(windowRect);
>> >>
>> >>  // -- Create Asterisk Static control --
>> >>  asterRect.top = windowRect.top;
>> >>  asterRect.bottom = windowRect.bottom;
>> >>  asterRect.left = windowRect.right + 12;
>> >>  asterRect.right = asterRect.left + 8;
>> >>
>> >>  m_pRedAster = new CStatic;
>> >>  if (m_pRedAster)
>> >>   {
>> >>   if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT,
>> >> asterRect,
>> >> GetParent()))
>> >>    {
>> >>    m_pRedAster->ShowWindow(SW_NORMAL);
>> >>    }
>> >>   }
>> >> ************* snip snip *****************
>> >>
>> >> What is the best way to calculate the position/size of the CStatic
>> >> control?????
>> >>
>> >> -- 
>> >> Hank Williams
>> >> Quantum Technologies, Inc.
>> >> HaWilliams(at)spamcop.net
>> >> --
>> >>
>> >>
>> >>
>>
>>
>> 


0
Hank
3/14/2005 5:24:49 PM
Probably the wrong approach. Why create it dynamically? I would just hide it or show it as
needed using ShowWindow(SW_HIDE) or ShowWindow(SW_SHOW). Forget using a CRect as you are
doing, since numbers like +8 and +12 are largely nonsensical (they only work for the
display you are on, with the display driver, the current font set, etc.)
				joe

On Mon, 14 Mar 2005 10:48:48 -0500, "Hank Williams" <HaWilliams(at)msn.com> wrote:

>I have a sub-classed Edit Control.  Within this sub-classed edit control, I 
>would like to optionally display an asterisk in the upper right corner 
>(outside the actual edit control).  I am using a dynamically create CStatic, 
>but it does not display.  I think the issue is the CRect for the position.
>
>Here is my code for creating the CStatic:
>
>************* snip snip *****************
> CRect windowRect;
> CRect asterRect;
>
> // -- Get Screen Co-ordinates --
> GetWindowRect(windowRect);
>
> // -- Create Asterisk Static control --
> asterRect.top = windowRect.top;
> asterRect.bottom = windowRect.bottom;
> asterRect.left = windowRect.right + 12;
> asterRect.right = asterRect.left + 8;
>
> m_pRedAster = new CStatic;
> if (m_pRedAster)
>  {
>  if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, asterRect, 
>GetParent()))
>   {
>   m_pRedAster->ShowWindow(SW_NORMAL);
>   }
>  }
>************* snip snip *****************
>
>What is the best way to calculate the position/size of the CStatic 
>control?????
>
>-- 
>Hank Williams
>Quantum Technologies, Inc.
>HaWilliams(at)spamcop.net

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
3/14/2005 5:50:44 PM
I see no GetTextExtent here that suggests how wide the window should be. 

The geometry is fairly simple; the top left of the static is the top right of the edit,
the height of the static is the height of the edit, the width is based on GetTextExtent,
and you might have to fudge various values with multiples of
::GetSystemMetrics(SM_CXBORDER) to adjust for borders and other phenomena.
				joe

On Mon, 14 Mar 2005 08:49:04 -0800, "RainMan" <RainMan@online.nospam> wrote:

>It does not matter as long as ScreenToClient is called before Create.
>
>"Hank Williams" wrote:
>
>> Where would I use 'ScreenToClient'??
>> 1) After GetWindowRect before 'asterRect' calcs?
>> 2) After 'asterRect' calcs????
>> 
>> -- 
>> 
>> Hank Williams
>> Quantum Technologies, Inc.
>> HaWilliams(at)spamcop.net
>> --
>> 
>> "RainMan" <RainMan@online.nospam> wrote in message 
>> news:309BF267-67EA-47A0-86DD-7CF8686F6902@microsoft.com...
>> > You are creating control using window rectangle returned with screen
>> > coordinates that may fall beyond client rectangle created window belongs 
>> > to.
>> > Use ScreenToClient to recalculate coordinates.
>> > If static control is created as child of an edit control it may be painted
>> > over.
>> >
>> >
>> > "Hank Williams" wrote:
>> >
>> >> I have a sub-classed Edit Control.  Within this sub-classed edit control, 
>> >> I
>> >> would like to optionally display an asterisk in the upper right corner
>> >> (outside the actual edit control).  I am using a dynamically create 
>> >> CStatic,
>> >> but it does not display.  I think the issue is the CRect for the 
>> >> position.
>> >>
>> >> Here is my code for creating the CStatic:
>> >>
>> >> ************* snip snip *****************
>> >>  CRect windowRect;
>> >>  CRect asterRect;
>> >>
>> >>  // -- Get Screen Co-ordinates --
>> >>  GetWindowRect(windowRect);
>> >>
>> >>  // -- Create Asterisk Static control --
>> >>  asterRect.top = windowRect.top;
>> >>  asterRect.bottom = windowRect.bottom;
>> >>  asterRect.left = windowRect.right + 12;
>> >>  asterRect.right = asterRect.left + 8;
>> >>
>> >>  m_pRedAster = new CStatic;
>> >>  if (m_pRedAster)
>> >>   {
>> >>   if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, 
>> >> asterRect,
>> >> GetParent()))
>> >>    {
>> >>    m_pRedAster->ShowWindow(SW_NORMAL);
>> >>    }
>> >>   }
>> >> ************* snip snip *****************
>> >>
>> >> What is the best way to calculate the position/size of the CStatic
>> >> control?????
>> >>
>> >> -- 
>> >> Hank Williams
>> >> Quantum Technologies, Inc.
>> >> HaWilliams(at)spamcop.net
>> >> --
>> >>
>> >>
>> >> 
>> 
>> 
>> 

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
3/14/2005 5:53:33 PM
Thanks for replying.  I do not want to add a CStatic for each CEdit or 
CComboBox on each of the dialogs (there are approx 200 dialogs w/ varying 
number of controls).  Approx 15% of them need to have the 'asterisk' which 
is determined at runtime.

I will be ading the items mentioned in your earlier reply for adjusting for 
border, etc.

Thanks again.
-- 

Hank Williams
Quantum Technologies, Inc.
HaWilliams(at)spamcop.net
--

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:ckjb319eh6915qpsvv32cnnvkfjgodhvrs@4ax.com...
> Probably the wrong approach. Why create it dynamically? I would just hide 
> it or show it as
> needed using ShowWindow(SW_HIDE) or ShowWindow(SW_SHOW). Forget using a 
> CRect as you are
> doing, since numbers like +8 and +12 are largely nonsensical (they only 
> work for the
> display you are on, with the display driver, the current font set, etc.)
> joe
>
> On Mon, 14 Mar 2005 10:48:48 -0500, "Hank Williams" 
> <HaWilliams(at)msn.com> wrote:
>
>>I have a sub-classed Edit Control.  Within this sub-classed edit control, 
>>I
>>would like to optionally display an asterisk in the upper right corner
>>(outside the actual edit control).  I am using a dynamically create 
>>CStatic,
>>but it does not display.  I think the issue is the CRect for the position.
>>
>>Here is my code for creating the CStatic:
>>
>>************* snip snip *****************
>> CRect windowRect;
>> CRect asterRect;
>>
>> // -- Get Screen Co-ordinates --
>> GetWindowRect(windowRect);
>>
>> // -- Create Asterisk Static control --
>> asterRect.top = windowRect.top;
>> asterRect.bottom = windowRect.bottom;
>> asterRect.left = windowRect.right + 12;
>> asterRect.right = asterRect.left + 8;
>>
>> m_pRedAster = new CStatic;
>> if (m_pRedAster)
>>  {
>>  if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, asterRect,
>>GetParent()))
>>   {
>>   m_pRedAster->ShowWindow(SW_NORMAL);
>>   }
>>  }
>>************* snip snip *****************
>>
>>What is the best way to calculate the position/size of the CStatic
>>control?????
>>
>>-- 
>>Hank Williams
>>Quantum Technologies, Inc.
>>HaWilliams(at)spamcop.net
>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 


0
Hank
3/14/2005 6:37:25 PM
Are these to mark required fields?

If I were you I would say its time for an outlook change and potentially 
paint them a different background colour etc.

- Mark R

"Hank Williams" <HaWilliams(at)msn.com> wrote in message 
news:uIvMtTMKFHA.3336@TK2MSFTNGP10.phx.gbl...
> Thanks for replying.  I do not want to add a CStatic for each CEdit or 
> CComboBox on each of the dialogs (there are approx 200 dialogs w/ varying 
> number of controls).  Approx 15% of them need to have the 'asterisk' which 
> is determined at runtime.
>
> I will be ading the items mentioned in your earlier reply for adjusting 
> for border, etc.
>
> Thanks again.
> -- 
>
> Hank Williams
> Quantum Technologies, Inc.
> HaWilliams(at)spamcop.net
> --
>
> "Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
> news:ckjb319eh6915qpsvv32cnnvkfjgodhvrs@4ax.com...
>> Probably the wrong approach. Why create it dynamically? I would just hide 
>> it or show it as
>> needed using ShowWindow(SW_HIDE) or ShowWindow(SW_SHOW). Forget using a 
>> CRect as you are
>> doing, since numbers like +8 and +12 are largely nonsensical (they only 
>> work for the
>> display you are on, with the display driver, the current font set, etc.)
>> joe
>>
>> On Mon, 14 Mar 2005 10:48:48 -0500, "Hank Williams" 
>> <HaWilliams(at)msn.com> wrote:
>>
>>>I have a sub-classed Edit Control.  Within this sub-classed edit control, 
>>>I
>>>would like to optionally display an asterisk in the upper right corner
>>>(outside the actual edit control).  I am using a dynamically create 
>>>CStatic,
>>>but it does not display.  I think the issue is the CRect for the 
>>>position.
>>>
>>>Here is my code for creating the CStatic:
>>>
>>>************* snip snip *****************
>>> CRect windowRect;
>>> CRect asterRect;
>>>
>>> // -- Get Screen Co-ordinates --
>>> GetWindowRect(windowRect);
>>>
>>> // -- Create Asterisk Static control --
>>> asterRect.top = windowRect.top;
>>> asterRect.bottom = windowRect.bottom;
>>> asterRect.left = windowRect.right + 12;
>>> asterRect.right = asterRect.left + 8;
>>>
>>> m_pRedAster = new CStatic;
>>> if (m_pRedAster)
>>>  {
>>>  if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, 
>>> asterRect,
>>>GetParent()))
>>>   {
>>>   m_pRedAster->ShowWindow(SW_NORMAL);
>>>   }
>>>  }
>>>************* snip snip *****************
>>>
>>>What is the best way to calculate the position/size of the CStatic
>>>control?????
>>>
>>>-- 
>>>Hank Williams
>>>Quantum Technologies, Inc.
>>>HaWilliams(at)spamcop.net
>>
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>
> 


0
markyr1 (230)
3/14/2005 6:52:27 PM
As a matter of fact, yes.

I have found any colour we would use would be liked by some users, but 
others would complain.

It seems, most users do not mind a 'small red asterisk' in the upper right 
corner of the field.

-- 

Hank Williams
Quantum Technologies, Inc.
HaWilliams(at)spamcop.net
--

"Mark Randall" <markyr@REMOVETHISgoogle.ANDTHIScom> wrote in message 
news:OfF36bMKFHA.1392@TK2MSFTNGP10.phx.gbl...
> Are these to mark required fields?
>
> If I were you I would say its time for an outlook change and potentially 
> paint them a different background colour etc.
>
> - Mark R
>
> "Hank Williams" <HaWilliams(at)msn.com> wrote in message 
> news:uIvMtTMKFHA.3336@TK2MSFTNGP10.phx.gbl...
>> Thanks for replying.  I do not want to add a CStatic for each CEdit or 
>> CComboBox on each of the dialogs (there are approx 200 dialogs w/ varying 
>> number of controls).  Approx 15% of them need to have the 'asterisk' 
>> which is determined at runtime.
>>
>> I will be ading the items mentioned in your earlier reply for adjusting 
>> for border, etc.
>>
>> Thanks again.
>> -- 
>>
>> Hank Williams
>> Quantum Technologies, Inc.
>> HaWilliams(at)spamcop.net
>> --
>>
>> "Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>> news:ckjb319eh6915qpsvv32cnnvkfjgodhvrs@4ax.com...
>>> Probably the wrong approach. Why create it dynamically? I would just 
>>> hide it or show it as
>>> needed using ShowWindow(SW_HIDE) or ShowWindow(SW_SHOW). Forget using a 
>>> CRect as you are
>>> doing, since numbers like +8 and +12 are largely nonsensical (they only 
>>> work for the
>>> display you are on, with the display driver, the current font set, etc.)
>>> joe
>>>
>>> On Mon, 14 Mar 2005 10:48:48 -0500, "Hank Williams" 
>>> <HaWilliams(at)msn.com> wrote:
>>>
>>>>I have a sub-classed Edit Control.  Within this sub-classed edit 
>>>>control, I
>>>>would like to optionally display an asterisk in the upper right corner
>>>>(outside the actual edit control).  I am using a dynamically create 
>>>>CStatic,
>>>>but it does not display.  I think the issue is the CRect for the 
>>>>position.
>>>>
>>>>Here is my code for creating the CStatic:
>>>>
>>>>************* snip snip *****************
>>>> CRect windowRect;
>>>> CRect asterRect;
>>>>
>>>> // -- Get Screen Co-ordinates --
>>>> GetWindowRect(windowRect);
>>>>
>>>> // -- Create Asterisk Static control --
>>>> asterRect.top = windowRect.top;
>>>> asterRect.bottom = windowRect.bottom;
>>>> asterRect.left = windowRect.right + 12;
>>>> asterRect.right = asterRect.left + 8;
>>>>
>>>> m_pRedAster = new CStatic;
>>>> if (m_pRedAster)
>>>>  {
>>>>  if (m_pRedAster->Create("*", WS_CHILD | WS_VISIBLE | SS_LEFT, 
>>>> asterRect,
>>>>GetParent()))
>>>>   {
>>>>   m_pRedAster->ShowWindow(SW_NORMAL);
>>>>   }
>>>>  }
>>>>************* snip snip *****************
>>>>
>>>>What is the best way to calculate the position/size of the CStatic
>>>>control?????
>>>>
>>>>-- 
>>>>Hank Williams
>>>>Quantum Technologies, Inc.
>>>>HaWilliams(at)spamcop.net
>>>
>>> Joseph M. Newcomer [MVP]
>>> email: newcomer@flounder.com
>>> Web: http://www.flounder.com
>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>>
>>
>
> 


0
Hank
3/14/2005 6:59:49 PM
Its then a matter of chosing the best trade off between something users 
probably don't prefer, but don't object to - or implimenting a rediculous 
amount of coding.

Only other suggestion I have is that you could create your own CEdit etc and 
trap events in such a way that 'required' woud be shown in say, red, when 
the control was empty, but it would change back to black once the user 
entered input - Just an idea.

Personally, Id be tempted to say bollocks to it and just give them a 
different coloured background.

- Mark R


"Hank Williams" <HaWilliams(at)msn.com> wrote:
> As a matter of fact, yes.
>
> I have found any colour we would use would be liked by some users, but 
> others would complain.
>
> It seems, most users do not mind a 'small red asterisk' in the upper right 
> corner of the field.
>
> -- 
>
> Hank Williams
> Quantum Technologies, Inc.
> HaWilliams(at)spamcop.net


0
markyr1 (230)
3/14/2005 7:08:03 PM
What I'm curious about is why modifying the program to support several hundred controls is
somehow simpler than adding the same number of controls. It could be done fairly quickly
(I've done far more extensive changes in a day or so of editing. Boring, tedious, but
ultimately the right solution). 
				joe

On Mon, 14 Mar 2005 19:08:03 -0000, "Mark Randall" <markyr@REMOVETHISgoogle.ANDTHIScom>
wrote:

>Its then a matter of chosing the best trade off between something users 
>probably don't prefer, but don't object to - or implimenting a rediculous 
>amount of coding.
>
>Only other suggestion I have is that you could create your own CEdit etc and 
>trap events in such a way that 'required' woud be shown in say, red, when 
>the control was empty, but it would change back to black once the user 
>entered input - Just an idea.
>
>Personally, Id be tempted to say bollocks to it and just give them a 
>different coloured background.
>
>- Mark R
>
>
>"Hank Williams" <HaWilliams(at)msn.com> wrote:
>> As a matter of fact, yes.
>>
>> I have found any colour we would use would be liked by some users, but 
>> others would complain.
>>
>> It seems, most users do not mind a 'small red asterisk' in the upper right 
>> corner of the field.
>>
>> -- 
>>
>> Hank Williams
>> Quantum Technologies, Inc.
>> HaWilliams(at)spamcop.net
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
3/15/2005 11:37:18 PM
Reply:

Similar Artilces:

How do I show a negative control as a positive number
I have a calculated control on a report where the value is shown as -45. How can I format this number to show it as 45? Thanks Tony -- Why don't my grey cells communicate with each as fast as they used to? I hate getting old! Message posted via http://www.accessmonster.com "TonyWilliams via AccessMonster.com" <u56994@uwe> wrote in message news:a219779e31378@uwe... > I have a calculated control on a report where the value is shown as -45. How > can I format this number to show it as 45? > Thanks > Tony =Abs([FieldName]) where FieldNa...

A true flicker free and transparent CStatic
Could someone tell me where I can find a very good transparent and flickering free CStatic control. I searched on Codeproject and I found CLabel but it is not flicker free when transparent. Depends on what you mean by flicker free! There really isn't such a thing as a flicker free static control Since the drawing of the static control is in seperate stage than the background of the dialog then there will always be flicker, hence there is no double buffering going on. Take a look at this, CTransparentStatic2 will minimize the flicker. http://www.codeproject.com/useritems/TransparentSt...

CPropertySheet receiving tab from other control on dialog box
Hi All, I currently have a MFC dialog application which has button and radio button controls. It also has a class that I implemented from CPropertySheet. I am not able to tab from the button or the radio button control to my CPropertySheet control. Is there a way to do this? I create the property sheet in the dialog box's OnInitDialog call. Is there a way to put this property sheet into the tab order? Thanks, Greg I think the key is to set the WS_CONTROL flag for the child dialog. See if this will help: http://www.codeguru.com/cpp/w-d/dislog/modelessdialogs/article.php/c1889/ AliR. ...

Dynamic CEdit access
I have a dialog that has a number of CEdit controls on it and am attempting to set the text in the control dynamically but am having a hard getting it to work. I understand that I can get a pointer to the control by using the GetDlgItem function and passing it the ID of the control. My issue is that I don't want to have to hard-code each controls ID and want to be able to somehow build it on the fly. For example, say each of my CEdit controls has an ID like "IDC_EDIT1", IDC_EDIT2, IDC_EDIT3..., and I want to populate each control's text from data returned from the database on...

Movable object along tracks using joystick: model railroad controllers?
I'm curious about this. Does anybody know anything about using .NET with model railroads? Its controlling a moveable object along the tracks using a joystick I am interested in. ...

Newbie Question
Ok, I'm tearing my hair out. I've searched for about 6 hours (and I thought I was pretty good at searching/researching on the 'net before this) and apparently, I'm just blonde and that's that. It seems to me what I'm trying to do would be in a "Welcome to Excel 101" tutorial on the first page... argh! Anyway, I'm trying to get a final sum of two cells. Below, I'll try to give a step by step example of the possible scenarios I'm trying to resolve in one single cell, the sum of two other cells, which may contain double positives, double negatives...

Rich edit control
I am mainly interested in using only the StreamIn() and StreamOut() members of CRichEditCtrl. Can I have this control inside a DLL without the UI? Is it possible to use other member functions also (may be other than the UI related ones)? Any pointers to samples (if available) please? (BTW, why this newsgroup has become silent? why nobody is answering here?) What do you mean by "other than UI related ones". Everything a CRichEditCtrl does is UI releated. In order to use any of it's methods you will have to create the CRichEditCtrl, and that requires a parent window. AliR...

hyperlinks in CRichEdit controls?
Does anyone know of an easy way to place hyperlinks into a CRichEdit control? ...

Controlling page change in a report
I have an Access report that prints the contents of a memo field that can often be very long - sometimes 2 or 3 full pages. My problem is that if one memo finishes at the top of a page and is followed by another long one - one that will go over to the next page - it skips to the top of the next page without beginning the new memo. Is there a property I can set, or some other method, that will cause the new memo to fill up the current page? Thanks in advance, Jerry Natkin Jerry Natkin wrote: >I have an Access report that prints the contents of a memo field that can >often be v...

dynamic quester for survey
Hi all, what is the best way to one shot designed access data for an changable excel quester for surveys? for example: populating data dynamicly to columns with a change of columns and calculated data On May 1, 3:56 pm, thread <yaniv...@gmail.com> wrote: > Hi all, > what is the best way to one shot designed access data for an changable > excel quester for surveys? > for example: > populating data dynamicly to columns with a change of columns and > calculated data find a copy of At Your Survey that you can download from Roger's Access Library... I think it's w...

Macro: Setting a dynamic range for Save as Web Page
Excel 2000. After creating a new worksheet with a macro, I want to save the contents as an HTML page. I'm new to VB, so I've been using the macro recorder, then tweaking the output. Here's the problem. I'm trying to save just a range of cells, from A1 to the xlCellTypeLastCell, containing data pasted in by the macro. If I just record what I'm doing manually, ActiveWorkbook.PublishObjects.Add uses an absolute range, like $A$1:$J$1253. The $A$1 is OK, but the second value will vary from time to time as the dimension of the pasted data changes. So I tried jamming ...

Subclassing a Dialog Control ?
Hi guys, When I put homemade controls in my dialog boxes I usually just use ClassWizard to create a member variable of the control type of my derived class, for example, I create a custom edit box derived from CEdit and ClassWizard recognizes it. Is there a way I can do it without having to have member variables of my derived class, so I can use GetDlgItem() ? I really only want to do this for consistency because for my other controls I don't have dialog member variables (at least not declared explicitly). I think it's called subclassing but am probably wrong. Thanks. "Robe...

VS2005: How to get the Control Events and Messages to show up in Peoperties dialog
In visual studio 2005, I have some dialogs that when (Editing them in VS) I right click on them to bring up their properties dialog, I don't see anything in the Control Events list or the Messages list. This has got to be because the class wizard / attendant (Whatever you now call it in VS2005, was class wizard in VC 6) doesn't contain information about that dialog, or it can't parse it correctly. How can I set it up so that I can see the Control Events list and the Messages list? Thanks! bparsons wrote: > In visual studio 2005, I have some dialogs that when (Editing them in ...

"Office Update ActiveX Control Failed to Load"
I keep getting "Office Update ActiveX Control Failed to Load." I cannot get ActiveX to load for Office update even though I've carefully followed ALL the directions on the MS web site (http://office.microsoft.com/en-us/assistance/HA011357171033.aspx) . Can anyone suggest what I might do next? Thanks and regards, PJF On Sun, 07 Aug 2005 15:37:23 -1000, PJF <pjf10@earthlink.net> wrote: > I keep getting "Office Update ActiveX Control Failed to Load." I cannot > get > ActiveX to load for Office update even though I've carefully followed ALL > t...

Dynamic stacked bar chart?
So far all the examples of dynamic charts I've seen have only had tw colums -1 for chart labels and the other with the data. My data ha week ending dates in column A(chart labels), column B has monday' sales - C has tues' sales....column F has Friday's sales. Also, I onl want to graph the data that is currently available in a data set tha will continue to grow. In the end, each bar should represent a week worth of sales with mon-fri stacked. Any ideas? Thanks for your help in advance. Shaw -- Message posted from http://www.ExcelForum.com Shawn - Well, how did you get t...

How do I control the location of xmlns attributes when serializing
I need to generate an XML document that will be validated against a DTD. Up to this point, I have been using XML Serialization with good results, but there is one item I haven't been able to figure out. The generated XML needs to look something like this: <?xml version="1.0" encoding="utf-8" standalone="no"?> <!DOCTYPE MY_XML_Doc SYSTEM "http://dtd_location.com/abc.dtd"[]> <MY_XML_Doc attr1="val"> <Element1> <SubElement1 xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href=http://compan...

position of cursor wrong when opening new document
when I open a new blank document the cursor is at the very top of the page and the way I use to return it to proper place is to open and close the headers/footers option Maybe you have "Hide White Space" going on? Open your normal.dot(m) template from within Word (differently depending on your version of Word), move your cursor to the tiny space just above the page that's showing (the cursor turns into a sort of waffle iron), and click or double-click (depending on version of Word). (Just to be sure Word understands that you've made a change in the template, ...

Adjusting/positioning swim lanes in a cross-functional flowchart
Grabbing size controls on the title box of a swim lane to adjust swim lane heights snap back to original positions. Selecting the lane displays the directional up/down/left/right control, but the lane snaps back after attempting to move it up or down. I turned off the x-coord protection. I can find no specific topic in help. On Tue, 14 Apr 2009 13:39:03 -0700, DRobb-Plym <DRobb-Plym@discussions.microsoft.com> wrote: >Grabbing size controls on the title box of a swim lane to adjust swim lane >heights snap back to original positions. Selecting the lane displays the >...

Dex.ini and dynamics.set
Well I have been searching most of the morning but I have not been able to find the information that I am looking for, so I will ask the question. During the past two patch installs (GP 10 SP3 and Year End Tax Update) the FORMS.DIC file has become corrupt somewhere along the line, this is the first two times this has happen to me. I want to prevent this from happening again so I started digging, we currently do not pay much attention to the dex.ini file. We have the dynamics.set file pointing to the correct path of the forms.dic and reports.dic files, I noticed that the DEX.ini also has...

Delegate Control
When i try to delegate an exchange permission to a user or a group i get the following error: To fully administer an exchange server, the delegated user or group must also be a member of the local machine administrator group. Currently the user is part of Builtin Administrators, Enterprise Admins, Domain Admins, Domain Users Groups. Do I need to configure something under Domain Controller Security Settings? Yes, add them to the local administrator group... Saludos, Pablo Vernocchi vernocchi@pcoffice.com.ar.delete.this Buenos Aires, Argentina On Tue, 18 Jan 2005 14:55:05 -0800, SY...

CStatic::SetIcon Transparent.
Hi, I am using the API CStatic::SetIcon to associate the icon with the static control. I have placed this control on CDialog, (Dialog background is gradient painted). I want this CStatic control to be transparent (so that the background of CStatic would be gradient, which is of Dialogs background color). However, icon image is transparent. How could I do this ? Any help would be highly appreciated. Thanks, Paresh. Can you paste the code that you have? That should help in identifying the problem. On Apr 22, 11:34 am, Paresh <Par...@discussions.microsoft.com> wrote: > Hi, >...

Re: XP style controls in non-unicode app
I found that if I add the following lines near the bottom of my stdafx.h file I get the new XP style controls in my MFC app: #if defined _M_IX86 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_IA64 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArc...

Lost DateTime Picker Control !?
I created a form using the DateTimePicker Control to write in a field. Then I removed the code of the DateTimePicker Control from the form. When I publish the form to another computer where the DateTimePicker Control is not installed, the form does not work. If I install the DateTimePicker Control the form is working without problems. I want to sent this contact form to other people who does not have this control. In the fact I am not using the DateTimePicker Control but it must be somewhere in the form, but I cannot find it. If I put in the form another DTP Control in the list of the fiel...

Fixed assets, Dynamics GP 10
In our company we have a lot of trucks in our fixed assets module. Our FM wants to know if Dynamics can depreciate them according to our usage, in other words, by hour or by minute, currently the smallest unit of depreciation is a day. My question: Is there 3rd party software available for Dynamics 10 that will enable us to depreciate by hour/minute? All help will be much appreciated. ...

Can I make a single tab disabled instead of the whole tab control?
For example, a tab control has 3 pages(tabs), and what I want to do is to make the first page(tab) disabled. Thanks for any help! The way I handle this in my application is like the following. This does not disable the tab, but it removes the text. Then I have other code in the property sheet that detects if the disabled tab is selected and makes the next tab active instead. // in the property sheet class CTabCtrl* pTab = GetTabControl(); ASSERT (pTab); TC_ITEM ti; char szText[2]; ti.mask = TCIF_TEXT; ti.pszText = szText; ti.cchTextMax = 1; VERIFY( pTab->GetItem( nPage, &ti)); st...