Model dialogs / UpdateWindow / UpdateData

1. Can I disable any controlls in dialog window using following code?

	CWnd* pWnd = GetDlgItem(nItem);
	pWnd->EnableWindow(0);

2. would UpdateWindow() / UpdateData() functions require inside
OnCheck*() to update the dialog? I am just enabling / disabling some
other controls (textbox, etc.) in the same dialog box using the above
code.

Thanks.

0
2/14/2007 9:54:46 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
891 Views

Similar Articles

[PageSpeed] 17


"v4vijayakumar" wrote:

> 1. Can I disable any controlls in dialog window using following code?
> 
> 	CWnd* pWnd = GetDlgItem(nItem);
> 	pWnd->EnableWindow(0);
 
Ok, it will do.

> 2. would UpdateWindow() / UpdateData() functions require inside
> OnCheck*() to update the dialog? I am just enabling / disabling some
> other controls (textbox, etc.) in the same dialog box using the above
> code.

The above code does not require any of these functions.


-- 
======
Arman

0
armancho_x1 (249)
2/14/2007 11:59:07 AM
On 14 Feb 2007 01:54:46 -0800, "v4vijayakumar" <vijayakumar.subburaj@gmail.com> wrote:

>1. Can I disable any controlls in dialog window using following code?
>
>	CWnd* pWnd = GetDlgItem(nItem);
>	pWnd->EnableWindow(0);
****
Yes, but why?  It is more reasonable to create a control variable and call the
EnableWindow method on the control variable:
	c_Item.EnableWindow(FALSE);

Note that the argument to EnableWindow is a BOOL, which means you should only ever write
TRUE or FALSE, never 0.  Do not use integer values where BOOL values are specified.  It is
poor style.
*****
>
>2. would UpdateWindow() / UpdateData() functions require inside
>OnCheck*() to update the dialog? I am just enabling / disabling some
>other controls (textbox, etc.) in the same dialog box using the above
>code.
****
What UpdateWindow and UpdateData share in common is the word "Update", and otherwise they
are unrelated concepts.  The only way to use them in the same sentence is when making such
statements about how they are completely unrelated.

OnCheck is a notification handler and would not update anything as such.  However, if you
click a check box and want to enable or disable a control, you would use the OnClick
handler to calll a function that would do all the updating.

Read my essay on dialog control management on my MVP Tips site.  All enabling and
disabling should be done in exactly ONE function, not scattered in a bunch of functions.

UpdateData should be avoided entirely.  My position is that it is poorly designed and
merely confusing; when using it, dialog code is harder to write, harder to debug, harder
to understand and harder to maintain.  See my essay on this topic on my MVP Tips site.

UpdateWindow has nothing to do with control management as such.   It is used in rare
situations where you need to display some contents of a window without having to wait for
the OnPaint handler.  These are usually very rare and exotic conditions.
*****
>
>Thanks.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
2/14/2007 3:33:12 PM
On Feb 14, 8:33 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
> On 14 Feb 2007 01:54:46 -0800, "v4vijayakumar" <vijayakumar.subbu...@gmail.com> wrote:
>
> >1. Can I disable any controlls in dialog window using following code?
>
> >    CWnd* pWnd = GetDlgItem(nItem);
> >    pWnd->EnableWindow(0);
>
> ****
> Yes, but why?  It is more reasonable to create a control variable and call the
> EnableWindow method on the control variable:
>         c_Item.EnableWindow(FALSE);

Yes, right. but, where you get "c_item"? Is this fine?

    GetDlgItem(nItem)->EnableWindow(FALSE);

....
> ... All enabling and
> disabling should be done in exactly ONE function, not scattered in a bunch of functions.

Got it. This could be clean.

> MVP Tips:http://www.flounder.com/mvp_tips.htm

Useful page. thanks.

0
2/14/2007 3:54:44 PM
v4vijayakumar wrote:
>>Yes, but why?  It is more reasonable to create a control variable and call the
>>EnableWindow method on the control variable:
>>        c_Item.EnableWindow(FALSE);
> 
> 
> Yes, right. but, where you get "c_item"? Is this fine?
> 
>     GetDlgItem(nItem)->EnableWindow(FALSE);

Every control can have a control variable associated with it.  They will 
give you much nicer code.

Right click on the control in the dialog editor, select Add Variable. 
Then make sure 'Control Variable' box is checked and type in a name for 
your control variable (such as c_Item).  The control member variable 
will be added to your dialog, and initialized for you.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
2/14/2007 5:13:40 PM
Reply:

Similar Artilces:

place toolbar on a dialog form
Is it possible to use a toolbar on a dialog form? I am trying to place a toolbar in code on a dialog form but it is not getting displayed. My project is not an SDI/MDI project but a dialog one and thus doesn't have a MainFrame class in which a toolbar is coded. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_DLGCBR32.asp Tom "Ayaz" <r_ayaz1@yahoo.com> wrote in message news:eThQNu93FHA.2872@TK2MSFTNGP15.phx.gbl... > Is it possible to use a toolbar on a dialog form? I am trying to place a > toolbar in code on a dial...

Visio 2002 Performance Problems with UML Model
Hi I'm experiencing quite severe problems with a Visio model that I don't suspect is really that large. The file size is approx 7Mb and there are around 200 pages within the model. When I try to add a new diagram to the model it takes almost five minutes. I'm running off a hig spec machine with XP and Task Manager suggests that the processor is 100% occupied throughout these 5 minutes. Any suggestions? Thanks in advance Danny Visio is a serious memory hog. I experienced the same issue you are and, long story short, had to go up to 1 gig of ram to resolve it. Every tim...

Programmatically close dialog app
Hi, I want to programmatically close my dialog-based app from within the app itself. Can anyone tell me how to do this? TIA! Jan Roelof Call the EndDialog( n ) API. HTH -- ============ Frank Hickman NobleSoft, Inc. ============ Replace the _nosp@m_ with @ to reply. <jr_de_pijper@hotmail.com> wrote in message news:vdimrv83s1dcikosilin8jjenr9ce46usr@4ax.com... > Hi, > > I want to programmatically close my dialog-based app from within the > app itself. Can anyone tell me how to do this? > > TIA! > Jan Roelof > AfxGetMainWnd()->PostMessage(WM_SYSCOMMAND,...

Model
:confused: Does anyone know any good ways i can tackle the followin model (view attachment>) or which sheets i should be using, thanks Attachment filename: model.txt Download attachment: http://www.excelforum.com/attachment.php?postid=51642 -- Message posted from http://www.ExcelForum.com If you want help, describe your problem, with data examples. Asking people to open attachments is not a good idea. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "adn4n >...

GetOpenFileName + Using own dialog template
Hi. I have a question: I am using the GetOpenFileName function to display the Windows FileDialog. I want to use the EXPLORER functionality and therefore I declared the flag OFN_EXPLORER in the OPENNAME-structure. Now here is the problem: I want to use my own dialog-template instead of the standard-file-open dialog. So i wrote my own template and set the attribute templateName of the OPENNAME structur to my own template. Furthermore i activated the flag OFN_ENABLETEMPLATE. But when I call the GetOpenFileName function with these properties I get the errorcode CDERR_GENERALCODES and the dialog is...

? Post Window (Dialog) Creation Flag
Hi, I've searched high and low (mostly low) but can't find anything about how to determine if a window (specifically a dialog and it's controls) is completely created. As you know, a window may/will receive all kinds of messages while it's being created. Unfortunately, sometimes we write message handlers that are to be executed AFTER the dialog and all of it's controls are created. For example, moving/sizing controls in a dialog box is done in OnSize as expected. However, WM_SIZE is sent to the window before the controls even exist. To avoid an exception, you have to ...

Dialog box and Pasting
Hi there I have a modeless dialog box in an MFC application. I would like to catch the event of pasting and deal with it on my own but when the user presses the CTRL+V keys to paste (in the dialog box) I do not know how to identify that even and catch it or deal with it. Is there a way of doing this? Can I overwrite some function to do this that will identify the CTRL+V action of the user Thanks in advance Tom. This article might help you some: http://www.codeproject.com/dialog/pretransdialog01.asp Tom Tom "Tom." <anonymous@discussions.microsoft.com> wrote in message news...

modeless dialog and WM_MOUSEMOVE
I am handling WM_MOUSEMOVE on my main view for dragging operation.. my main view also includes modeless dialog box.... if the mouse cursor is over the dialog box, the main View doesn't get WM_MOUSEMOVE message and thus the operation is cancelled until the mouse cursor is again on the main View. How to handle this ? thanx This is the normal behavior. If you want to get mouse notifications even if mouse is not in the window, you can capture the mosue. Look at SetCapture/ReleaseCapture. ---------- Ajay Kalra ajaykalra@yahoo.com WM_MOUSEMOVE, unlike most mouse messages, is not sent to th...

Run Rules Now dialog
Windows XP Pro Office 2003 From the Run Rules Now dialog, is there a way to select all the checkboxes at once instead of having to individually select each one. I have a lot of rules so individually selecting each is painful. Thank you for any feedback. John, you wrote on Fri, 24 Mar 2006 16:25:08 -0800: > From the Run Rules Now dialog, is there a way to select all the checkboxes > at once instead of having to individually select each one. I have a lot of > rules so individually selecting each is painful. There is no way to select all rules at once. -- Best Regards Chr...

Initial Domain Model Using Visio (Agile Data Modeling)
Hi !! We are developing an application for which we are following this article on http://www.agiledata.org/essays/agileDataModeling.html We are designing initial Domain model for system, and than go phase by phase as article suggest. We are trying to design inital domain model using Visio. However which template to pick up in visio? Thanks !! ...

copy dialogs between projects
I have a test project which contains a form which I now want to incorporate into my application. I know how to copy the dialogs class and supporting classes as they are just text files. How do I copy a dialog (within an RC file) to a different project. Thanks Malcolm Clarke I forgot to say I am using Microsoft Visual Studio .NET 2003 ta "Malcolm Clarke" <not4bad@hotmail.com> wrote in message news:u9sIzPCSFHA.2932@TK2MSFTNGP09.phx.gbl... > > I have a test project which contains a form which I now want to incorporate > into my application. I know how to copy the ...

the Problem about calendar show at the day/week/month model
1:I created an appoint. but at the day/week/month model, can not show the subject. if I change the model to"by category" , the subject show again. 2: the reminder can not work normaly at any model. any suggestion be appreciate. Richard rxj88@hotmail.com, you wrote on Thu, 15 Dec 2005 17:34:41 +0800: > 1:I created an appoint. but at the day/week/month model, can not show the > subject. if I change the model to"by category" , > the subject show again. Start Outlook once with the parameter /cleanviews Start | Run | outlook.exe /cleanviews > 2: ...

Failed to customize the dialog box of toolbar #3
I cannot fill the left-hand list box of toolbar's dialog box,and if I delete one button in toolbar,I lost it. It's hard to format code here,are there any tricks? Below is my code: #include<windows.h> #include<commctrl.h> #include"resource.h" #defineID_TOOLBAR20001 staticchar*szAppName="StudyToolbar"; LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM); TBBUTTONtbButtons[]= { {STD_FILENEW,IDM_FILE_NEW,TBSTATE_ENABLED, TBSTYLE_BUTTON|BTNS_SHOWTEXT,0,0},//1 {STD_FILEOPEN,IDM_FILE_OPEN,TBSTATE_ENABLED, TBSTYLE_BUTTON,0,0},//2 {STD_FIL...

Welcome dialog in MFC doc/view?
Hi, Need to add one 'welcome' dialog in an application of MFC doc/view. Need to show the dialog after the application is showed. Where should I put the dialog.DoModal ()? Thank you a lot Best regards, You can post a custom message to the mainframe window in OnCreate of mainframe. In the handler of this message show your dialog. Another option would be to post a message to CWinApp (this will be a message to the thread) and show the dialog in its handler. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Kelvin" <Kelvin_gl@yahoo.com.cn> wrote in message news:#u1zHp9...

Printing a dialog from an SDI based application
In an SDI application that I am developing I am trying to print the contents of a graph hosted in a dialog...my question is can I somehow hook into the default printing support that the SDI app has built in or do I have to come up with a new class to support printing from the dialog??? Dominic Dominic, You can indeed jack into the printing framework. It's as easy as adding an override to OnPrint in your view, and print to the CDC* you get as an in-parameter. A nifty side effect is that you'll get support for the print-preview this way as well. Johan Rosengren Abstrakt Mekanik ...

hide title bar of a dialog box on run time
i have a dialog box, and 2 button on a dialog. i want to add functionality that when i will click button 1 the title bar will disappear, and when i will click second button it will appear(become visible). thanks >i have a dialog box, and 2 button on a dialog. i want to add >functionality that when i will click button 1 the title bar will >disappear, and when i will click second button it will appear(become >visible). The following snippet toggles the caption bar: DWORD CurrentStyles = GetWindowLong( m_hWnd, GWL_STYLE ); SetWindowLong( m_hWnd, GWL_STYLE, CurrentStyles ^ WS...

Dialog Control Help
Hi, Can anyone tell me if there is any way to access a control on a dialog by the string equivalent of the control id ? ie. At the moment, what I have to do something like // read in Control ID from file into str1 str1 = IDC_MY_EDITBOX // read in value from file for control str2 = "this is an edit field" and so my code would do something like .... if (str1 = = "IDC_MY_EDITBOX") GetDlgItem(IDC_MY_EDITBOX)->SetWindowText(str2); .... to populate the field on the dialog. My question is, what would I need to do in order to get a generic bit of code that wo...

Possible chart model?
I want to make a new model of chart, i don´t no is or not possible. I seed that in a company presentation, but maked it with two grups os value and is very dificult to atualized. Imagine the sample below with colums: Ebit 2007 price volume cost expenses EBIT 2008 15 +5 +2 -3 -2 17 but the "price" begin your colum in the top line of "Ebit 2007", the next colum "volume" begin in scale 20, because is 15 + 5 for a price, the next "cost" must the top of the colum at the number 22 and go d...

Add minimize buttn to dialog
Hi, I have a dialog box application. I don't select minimize button in property of dialog. I create my own button at top right on dialog and want to make it behave as minimize button. Can someone tell what code i need to add so that when user click on this button the dialog should be minimize. >I have a dialog box application. I don't select minimize button in property >of dialog. I create my own button at top right on dialog and want to make it >behave as minimize button. >Can someone tell what code i need to add so that when user click on this >button the di...

How to print a dialog?
i generate a dialog based project, and i want to print the main dialog. what should i do? thanks Define what you mean by "print". Generally, printing the contents of a window as a bitmap is pretty useless, although you can look at my class for doing window capture (on my MVP Tips site). I put the window pixels in the clipboard, bcause that's what I want to do, but once you have the bitmap, you can print it. But the result is remarkably ugly. joe On Thu, 28 Oct 2004 06:59:08 -0700, "Mark" <Mark@discussions.microsoft.com> wrote: >i generate a dialog bas...

Incorrect Field Names Appear in PivotTable Field Dialog Box
I have found that items deleted from my source, standard worksheet, are still appearing in the Pivot Table Drop down list. I have applied the sollution in MS202232 but it did not clearup the outdated data. I have refreashed the pivot table before and after runing the MACRO "Delete_Fields" Not sure what else can be done, I continue to search groups and MS. ******** This is the code for the MACRO based MS202232: Sub Delete_Fields() On Error Resume Next For Each pvtfield In Worksheets(PivotTables).PivotTables(PivotTable1).PivotFields For Each pvtitem In pvtfield.PivotItem...

DB Model vs. ER Model
What is the difference between a "Database Model Diagram" and an "ER Source Model" - I mean if every thing is available in a "Database Model Diagram", why do we have a need for an "ER Source Model". Regards, Ali. You can think of the ER Source model as a Logical model rather than a Physical model. Also you can have many ER Source models built into a single Database Model diagram -- -ronnie [MS] This posting is provided "AS IS" with no warranties, and confers no rights. "Ali" <ali_abbas@netlimit.com> wrote in message ne...

Access Visio object model
Hi, I have a .vsd file which i need to parse and get all shapes in it. I tried doing this in the following different ways : 1.Use the Drawing control but my problem is mine is a web application ,since i just want to use it to parse my visio diagram i dont want to create a control on the web page so in the codebehind i tried creating a object of type just to use it to get hold of the object model. drawingControl=new DrawingControlClass(); but this throws exception saying "classid is not registered" so couldn't proceed with this approach.Can anyone throw some insight on this er...

changing the dialog background color #2
Hi, I already sent a question in the forth of January and tried the suggestions I got. I would like to cange the background color. As suggested, I tried to write CWinApp::SetDialogBkColor(RGB(0,0,255),RGB(255,0,0)); in the OnCtlColor function and got an error message saying "'CWinApp::SetDialogBkColor' : cannot access protected member declared in class 'CWinApp'" What is wrong with it? According to another suggestion, I tried to find the function OnEraseBkgnd in the override functions list that appears in the properties of the view class in order to paint t...

Dialog's HWND becoming NULL
I am using visual Studio.Net for a simple MFC application. My application is dialog based. On Some event I want to pop up another dialog. I am instatiating member variable of that dialog and calling DoModal(). But dialogs HWND becomes NULL. It is happening only in this application. I have tried some other sample application and it works. I have set Visible and Popup attributes of dialog. sample code is below void CObexFrameWorkDlg::OnBnClickedRestore() { CFolderDialog folderDialog; folderDialog.DoModal(); } constructor of folder dialog is CFolderDialog ::CFolderDialog (CWnd* p...