📄 wpw_mfc_control_95.html
字号:
<HTML>
<HR><A NAME=MFC_CONTROL_UPDATE_EDIT>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Update Edit Controls</H4><PRE>
In article <3rsdhv$hjc@morgan.vf.mmc.com> abrahamb@utica.ge.com writes:
>
>Hi,
>
>I have MS Visual C++ 1.51 on Windows for Workgroups 3.11
>
>Here is my problem.
>
>I built a dialog box based on CFormView in Visual C++. I have a few controls
>such as edit boxes and list boxes that are mapped to variables in this dialog
> box.
>I am trying to update the display with changes in these variables through a
> call
>to UpdateData(FALSE) for the dialog box class. This works for the whole dialog
> box and each of the variables collectively. However I can't seem to update an
> individual
>control in the dialog box, such as an edit control. I tried the following
>
>
> pedt = (CEdit *)GetDlgItem(ID);
> pedt->UpdateData(FALSE);
>
>and it doesn't work. Is there a way I can use the data exchange in UpdateData
> to update
>a single control in my CFormView class? Is there any other way of doing this?
This isn't a criticism of you personally, but just a general comment. This
type of question is a PERFECT illustration of my often-stated belief that
you CANNOT write a Windows program using a class library unless you have a
good knowledge of the Windows API. Any Windows API programmer would know
how to do this, but our friend here, who has presumably only learned how
to use MFC, is stuck because he's hit something the class library doesn't
do for him.
The answer is, of course, to say:
SetDlgItemText( ID, "This is the new value" );
Regards,
CHris
--
--------------------------------------------------------------------------
| Chris Marriott, Warrington, UK | Author of SkyMap v2 shareware |
| chris@chrism.demon.co.uk | astronomy program for Windows. |
| For more info, see http://www.winternet.com/~jasc/skymap.html |
| Author member of Association of Shareware Professionals (ASP) |
--------------------------------------------------------------------------
<HR>
In article <3rsdhv$hjc@morgan.vf.mmc.com> abrahamb@utica.ge.com writes:
>
> Hi,
>
> I have MS Visual C++ 1.51 on Windows for Workgroups 3.11
>
> Here is my problem.
>
> I built a dialog box based on CFormView in Visual C++. I have a few controls
> such as edit boxes and list boxes that are mapped to variables in this dialog
> box.
> I am trying to update the display with changes in these variables through a call> to UpdateData(FALSE) for the dialog box class. This works for the whole dialog
> box and each of the variables collectively. However I can't seem to update an
> individual
> control in the dialog box, such as an edit control. I tried the following
>
>
> pedt = (CEdit *)GetDlgItem(ID);
> pedt->UpdateData(FALSE);
>
> and it doesn't work. Is there a way I can use the data exchange in UpdateData
> to update
> a single control in my CFormView class? Is there any other way of doing this?
>
> Any help is appreciated.
>
You could always try the old-fashoined way ie
pedt->SetWindowText( m_string_holding data )
--
No turn left unstoned...
</PRE>
<HR><A NAME=MFC_CONTROL_CProperty_Sheet>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: CProperty Sheet Question</H4><PRE>
I have an application where instead of using the MSVC
CMdiFrameWnd->CMdiChildWnd->CView architecture, I am overriding
OpenDocumentFile and creating a modeless property sheet to display
my document information in. There are a few problems I need to deal with
in this situation:
1) How do I get rid of the standard buttons of the property sheet(OK, CANCEL,
APPLY NOW, and HELP(i think that's the fourth one)). I checked the
source code for CPropertySheet::OnCreate, and the only way I see to do
this is to remove the call to CreateStandarButtons() from the OnCreate
function...is there a nicer way to accomplish this?
2) How do I keep the property sheet from going outside the framewindow?
Since the property sheet is my "view" for this document, I want it to remain
inside the framewindow, and for it to minimize to the bottom of the framewindow
when I click on minimize. How do I accomplish this?
Tnx
Deepak Saxena--inferno@expert.cc.purdue.edu
<HR>
In article <3s1u2u$flr@expert.cc.purdue.edu>,
inferno@expert.cc.purdue.edu (Inferno) wrote:
> I have an application where instead of using the MSVC
>CMdiFrameWnd->CMdiChildWnd->CView architecture, I am overriding
>OpenDocumentFile and creating a modeless property sheet to display
>my document information in. There are a few problems I need to deal with
>in this situation:
>
> 1) How do I get rid of the standard buttons of the property sheet(OK,
CANCEL,
>APPLY NOW, and HELP(i think that's the fourth one)). I checked the
>source code for CPropertySheet::OnCreate, and the only way I see to do
>this is to remove the call to CreateStandarButtons() from the OnCreate
>function...is there a nicer way to accomplish this?
>
The propertysheet should be made mode-less. Then you can make your own
buttons. Those buttons should be put into the dialog-template for each
propertypage you are adding. It is nicer in many ways, but not as clean as one
would like it to be. :-)
Q 2) I don't know.
------------
Nils Andreas Thommesen -- Nils.Thommesen@kvatro.no
Kvatro-Notis AS, Pirsenteret, 7005 Trondheim. Tlf: +47 73 545 722
E.B Schieldropsv. 9-24, 7033 Trondheim. Tlf: +47 73 8888 93
</PRE>
<HR><A NAME=MFC_CONTROL_CEdit_Flash>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a>
<H4>Subject: How to correctly sel and replace text in CEdit?</H4><PRE>
In article <3tuufa$rkm@geraldo.cc.utexas.edu>, e.man@mail.utexas.edu
says...
>
>I cannot seem to set the focus for a edit control in my dialog box
correctly once it loses the focus.
>The situation is when the user presses a button the following is done:
>
>void QEnterFormulaDlg::OnLparen()
>{
> CEdit * edit = (CEdit *) GetDlgItem(IDC_ENTER_FORMULA);
> CString newText;
> edit->GetWindowText(newText);
> SetDlgItemText(IDC_ENTER_FORMULA, newText + '(');
>
> // here's what I have tried so far
>
> GotoDlgCtrl(edit); // this sets focus to text end but
highlights all text before end
>
> // or
>
> SetFocus(edit); // this sets focus at start of text not what I
want
>}
>
>how can I set the focus to the end of the edit text and not have it
highlight the text?
Actually the control is functioning properly as per the UI design specs.
When an edit control gets first acquires focus all the text in the edit
control gets selected. This is done since the general thought is that a
user will be replacing, not adding the the text in the control. This is
the same way edit controls work in many applications.
Now off to your problem: If you are truly wanting to change the way the
standart edit control works you'll have to do it the hard way. Try
sending a EM_SETSEL message to the control, or in your case
CEdit.SetSel(). You can keep the window from flashing by locking the
window before the call and unlocking after the call (LockWindowUpdate());
Ken
(argo@rias.com)
</PRE>
<HR><A NAME=MFC_CONTROL_CEdit_Limit>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a>
<H4>Subject: CEdit wraps string with length > 1024</H4><PRE>
In article <3u0flv$7qb@nsnl.origin.nl>, ivdr@bsonwg.bso.nl says...
>
>I've encountered a problem with the CEdit class of MFC 3.0 (Visual C++
>2.0, Windows NT 3.5).
>
>It seems that a string with a length greater than 1024 characters is
>wrapped automatically in a multiline Edit box (CEdit).
>
>Is there any way to avoid this wrap?
>
<code deleted>
>
This limitation exists for the underlying edit control and has nothing
whatsoever to do with the CEdit MFC class. The only workaround would be
to write (or buy) another multiline edit control which does not have the
1024 character per line limit.
By the way, CString has a contructor that can be used to create a
preinitialized string of a desired length. Your CString code above could
be rewritten as:
CString sText("X", 1024);
Phil Cooper
--
The opinions expressed in this message are my own personal views
and do not reflect the official views of Microsoft Corporation.
</PRE>
<HR><A NAME=MFC_CONTROL_Add_Method>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a>
<H4>Subject: Adding custom methods to a control</H4><PRE>
In article <DB6zHo.Fux@vptt.ch>, luft_w@vptt.ch says...
>
>Can anybody give me an idea how a custom method could be added to a
>control?
>As I see in the cdk, there are only predefined methods available, but I
>need a
>method like MyControl.Print.
>
>Wilfried.
If this is a VBX control, there is no way to create custom methods. The
standard technique is to add an addition property (normally called
"Action") which is gets set to a magic value by the user when he/she
wants to invoke the "method". In other words, the Action property might
understand two values:
1. Print
2. Reset
If you are writing an OLE control, go to ClassWizard's OLE automation
page and hit the button titled "Add Method".
Phil
--
The opinions expressed in this message are my own personal views
and do not reflect the official views of Microsoft Corporation.
</PRE>
<HR><A NAME=MFC_CONTROL_dir_sel>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a>
<H4>Subject: Directory Selector Box</H4><PRE>
>ejy@mtdcr.att.com (Eugene J. Yurek) wrote:
>>
>>I am in need of a directory selector box that functions in much the same way
>>as the commdlg.dll file selection control
>>
>>To the best of my knowledge, there is no way I've found to strip the file
>>selection listbox from the commdlg.dll control.
>Yes, you _can_ just use the commdlg.dll and strip out the unneeded controls.
>Add the dialog template to your project, resize the dialog and make all the
>unwanted controls hidden.
>You will also have to put some character in the filename edit control to trick the
>dialog into closing. Then just strip off the character to get your directory.
>I did this with OWL and it was a trivial 5 line class, MFC should be just as easy.
>Hope this helps.
>- Joseph
MFC is easy too, but documentation is a bit out of date and well hidden (as
usual) :)
-------------------
Kevin Hintergardt
chico@halcyon.com
Welcome to the Information Goat Path
</PRE>
<HR><A NAME=MFC_CONTROL_ToolTips>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Tooltips with MFC 2.5</H4><PRE>
flocs@mailbox.rmplc.co.uk (Richard May) wrote:
>I have both MSVC 1.51 and 2.0 and wonder what is the simplest way to
>implement tooltips with v1.51?
>Has anyone got any ideas?
>Regards,
>Richard
John Alchin posted a response to a similar request. He referred
to a ZIP file at CICA that has all the answers.
The address is:
ftp.cica.indiana.edu/pub/pc/win3/programr
and the file is TTIPS2.ZIP
I just got it, and it works GREAT with MSVC 1.50, so I know it
will work with 1.51.
My thanks to John Alchin AND the authors of this tip for providing
the answer to something I also have been looking for!
Scott Craig
=================================================================
Scott Craig SCraig@ix.netcom.com Scott.Craig@Nashville.Com
Nashville, TN Without racing, why even bother!
=================================================================
</PRE>
<HR><A NAME=MFC_CONTROL_Dyna_color>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a>
<H4>Subject: Dynamic fore and back colors in scrolling Text Box</H4><PRE>
>How do I create a vertically scrolling, noneditable, autoword wraping text
box that I
>can change the colors at run time. The text will never be greater than 32k.
I don't
>care about enabling any clipboard functionality. Using MFC 2.52.
See WM_CTLCOLOR in your documentation.
David
----- Standards are great. Everyone should have one ! (Charles Moore) -----
David Brabant, | E-mail: David.Brabant@csl.sni.be
Siemens Nixdorf (SNI), | X-400: C=BE;A=RTT;P=SCN;O=SNI;OU1=LGG1;OU2=S1
Centre Software de Li鑗e, | S=BRABANT;G=DAVID
2, rue des Fories, | URLs: www.sni.de www.csl.sni.be/~david
4020 Li鑗e (BELGIUM) | Phone: +32 41 201 609 FAX: +32 41 201 642
</PRE>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -