Can't disable a button on CDialogBar

Hello
I have a button on CDialogBar. my problem is I can't disable  this
button.
here what I have tried.
m_wndDialogBar.GetDlgItem(IDC_BUTTON)->EnableWindow(FALSE);
I'm using the Doc/View architecture.

Thanks in advance.

0
xcppcoder (17)
3/1/2006 2:53:41 PM
vc.mfc 33608 articles. 0 followers. Follow

7 Replies
1363 Views

Similar Articles

[PageSpeed] 29

Check the return from GetDlgItem() and make sure it is a valid CWnd*.

Also, make sure there is no code in the dialog handler that is reenabling it 
(you may be competeing with another similar call).

Tom

<xcppcoder@gmail.com> wrote in message 
news:1141224821.437297.280720@t39g2000cwt.googlegroups.com...
> Hello
> I have a button on CDialogBar. my problem is I can't disable  this
> button.
> here what I have tried.
> m_wndDialogBar.GetDlgItem(IDC_BUTTON)->EnableWindow(FALSE);
> I'm using the Doc/View architecture.
>
> Thanks in advance.
> 


0
tserface (3861)
3/1/2006 3:33:01 PM
xcppcoder@gmail.com wrote:

> Hello
> I have a button on CDialogBar. my problem is I can't disable  this
> button.
> here what I have tried.
> m_wndDialogBar.GetDlgItem(IDC_BUTTON)->EnableWindow(FALSE);
> I'm using the Doc/View architecture.
> 
> Thanks in advance.
>

xcppcoder:

When something doesn't work you have to say what happened, e.g.

Won't compile (show error message)
Program runs but not with desired effect
Access Violation (where)
Assertion (where)
Other (what)

Otherwise the answer is just: You did something wrong.

David Wilkinson



0
no-reply8010 (1791)
3/1/2006 3:49:43 PM
I think Toms second suggestion may prove useful. The framework keeps the 
button enabled because of Update command UI logic. To get around this I 
usually put the UpdateUI handler in the CMainFrame, then either enable or 
not based upon a public boolean. Then you set the boolean in your code.

<xcppcoder@gmail.com> wrote in message 
news:1141224821.437297.280720@t39g2000cwt.googlegroups.com...
> Hello
> I have a button on CDialogBar. my problem is I can't disable  this
> button.
> here what I have tried.
> m_wndDialogBar.GetDlgItem(IDC_BUTTON)->EnableWindow(FALSE);
> I'm using the Doc/View architecture.
>
> Thanks in advance.
> 


0
kma3184 (100)
3/1/2006 3:52:28 PM
the return from GetDlgItem() is valid pointer and i was able to change
the button text.
I'm sure that I didn't call the CWnd::EnableWindow(TRUE) in any part on
the application.
I'm using two views in the application.
What functions that can call the EnableWindow implicitly?

0
xcppcoder (17)
3/1/2006 3:57:09 PM
You need to have a command UI handler to do the buttons.  Maybe this article 
will help some:

http://www.codeguru.com/cpp/w-d/dislog/dialogbars/article.php/c1871/

http://support.microsoft.com/kb/q152376/

Tom

<xcppcoder@gmail.com> wrote in message 
news:1141228629.080531.193620@p10g2000cwp.googlegroups.com...
> the return from GetDlgItem() is valid pointer and i was able to change
> the button text.
> I'm sure that I didn't call the CWnd::EnableWindow(TRUE) in any part on
> the application.
> I'm using two views in the application.
> What functions that can call the EnableWindow implicitly?
> 


0
tserface (3861)
3/1/2006 9:15:15 PM
I added manually a command UI handler for the button, and It works.
Thank you

0
xcppcoder (17)
3/3/2006 3:53:11 PM
Great!  Glad you got it to work.

Tom

<xcppcoder@gmail.com> wrote in message 
news:1141401191.669658.32800@i39g2000cwa.googlegroups.com...
>I added manually a command UI handler for the button, and It works.
> Thank you
> 


0
tserface (3861)
3/3/2006 3:55:58 PM
Reply:

Similar Artilces:

Excel startup with buttons
I was wondering if it is possible to have a blank screen displayed when a user opens up excel, and have them select a button to take them to a particular worksheet in the excel workbook. I have figured out how to use code in visual basic to create the buttons, but when I open the workbook, it displays the "button screen" overtop of whatever the last page was when the workbook was last used. I'd rather not have any of the worksheets visible behind the button choosing screen. Any suggestions? -- alanad ------------------------------------------------------------------------ a...

Reminder OKonly button when spreadsheet opens
My secretary is asking if there's a way to remind her to change th header in a spreadsheet weekly. I was thinking either a reminde (Okonly) when the workbook opens, or a button that brings up the forma so she can change it weekly? Found help on displaying paths in footers, but this is changing th date on the header for printing. Thanks for any help! krislyn;) US -- Message posted from http://www.ExcelForum.com You could insert a formula into a cell that displays on every Monday: =IF(WEEKDAY(TODAY())=2,"Update Header!","") The "2" represents Monday. 1=...

How to disable compiler warnings?
foo.h contains #pragma warning(disable: 4514) #pragma warning(disable: 4100) #pragma warning(disable: 4512) #pragma warning(disable: 4511) #pragma warning(disable: 4663) #pragma warning(disable: 4018) #pragma warning(disable: 4146) #pragma warning(disable: 4244) #include <string> and generates many many of the above warning. According to the docs, #pragma warning (disable: xxx) turns of warnings. (?) John Smith wrote: > foo.h contains > > #pragma warning(disable: 4514) > #pragma warning(disable: 4100) > #pragma warning(disable: 4512) > #pragma warning(disable: ...

Disabled accounts quandry
Hi All I have a scenario where I've got hundreds of disabled accounts that have never been logged into. I think they've come across from the NT4/ Exchange 5.5 migration. At first it would seem a simple act and low risk act to delete them. However, I believe they exist because they are mailbox enabled and various people have various permissions to access these mailboxes. I have no doubt there are some truly dead accounts. Any idea how I can figure this out (unfortunately, a few system wide programs login to each account via MAPI so no details that way) Am I missing something o...

Disable preview pane for message folders?
Hi, In Outlook express I can disable the Preview Pane for any message folder so I can "look inside" a message in- non-html format-by rt. clicking and , then Properties>Details>Message Source.Now in Outlook XP (Win 2000), I can disable the Preview Panes, but I can't "look inside" messages like I do in Outlook Express (6). I can only read it or delete it. Is this a limitation of Outlook and is there a fix? I'm concerned, because some new viruses activate on Preview alone.Thanks. Peter Cowie PS I have the latest Office XP patches. I use the Chilton Preview P...

Running Check box code after Command button Click
Private Sub CommandButton1_Click() Call CheckBox2_Click End Sub I have code like the following and it works almost like I want it to, but when I check the checkbox it will activate the Form worksheet I have. I do not want anything to happen until after the command button is pressed. What can I add or remove to this code to allow this to happen? Thanks! Option Explicit Private Sub CommandButton1_Click() Call CheckBox2_Click End Sub Private Sub CheckBox2_Click() Sheets("Form").Activate ActiveSheet.Range("Address").Select If Selection.Interior.Pattern = xlNone ...

Disable Price Locking When Quote Converted to an Order
When an order is created for a quote the price is locked so cannot be changed (unlike when creating an order direct). We only use Quotes and Orders to monitor correspondence not as a the primary sales order mechanism so we need teh flexibilty of making changes after the order is created. Does anybody know how this can be disabled? thanks Scott ...

disable blinking cursor and selected text in edit box
Hi! I'm using mfc to create a dialog with an edit box in it, to which I write text after an event occurs. Everything works the way I want, except that the text comes out highlighted and the cursor is blinking irritatingly at the end of the line. I looked everywhere on the web to find a way to disable these two but couldn't find a way. Can someone tell me how to disable the cursor and to not have selected text printed in the edit box? thanks, Craig To disable blinking cursor, On the EN_SETFOCUS handler, try m_Edit.HideCaret() ; Here's the remarks from MSDN: Although the caret is...

Update Form with Command Button
I have a report which is created using criteria entered into a form. There is already a button on the form which opens the report. If someone does not tab out of a particular box then sometimes the the control isn't updated and the report doesn't get the proper criteria. I can use the button to update all of the individual controls before creating the form, but can I use the button to update the entire form instead? RMires, Just do a... Refresh DoCmd.OpenReport... etc... -- hth Al Campagna Microsoft Access MVP 2006-2009 http://ho...

Reverse a Macro
Thanks for considering this problem! Is there a quick and simple way to reverse the events performed by macro. Hopfully there is a type of "back button" process, short of writing th macro in reverse which can be very time consuming on complicate macros. Thanks.... -- spydo ----------------------------------------------------------------------- spydor's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2843 View this thread: http://www.excelforum.com/showthread.php?threadid=49746 As far as I know there's no simple way to reverse the actions of a ma...

Disable Slide Show button in Windows Photo Gallery
Hello there :) I am currently running Vista Business 64 on my home computer. I do alot of photography, and use Windows Photo Gallery to preview / browse all of my pictures. For my needs, Windows Photo Gallery is perfect EXCEPT for the Slide Show button. I'm constantly finding that I accidentally click the slide show button, and because I'm dealing with RAW files (around 16-20 megs) the slide show locks my computer up for about 5 minutes. Ending the process takes just as long to recover. Does anyone know of a way to disable the functionality of this button? I'm ex...

publisher art cd's and the art & photo's button
I do not know how to locate the Art & Photo's button to access graphics. I do not know how to open the two Art CD's that are provided with the pro publisher deluxe 21. thank you sue sue stu <sue stu@discussions.microsoft.com> was very recently heard to utter: > I do not know how to locate the Art & Photo's button to access > graphics. > > I do not know how to open the two Art CD's that are provided with the > pro publisher deluxe 21. There is no such Microsoft product as Pro Publisher Deluxe 21. Microsoft Publisher (standard) is included with...

SystemMailbox disabled????
We have 9 info stores in 2 storage groups and I just noticed in AD, under Exchange System Objects that the SystemMailbox account for every info store except ONE is *DISABLED*. I assume this shouldn't be that way...what kind of problems might this cause? What all is the SystemMailbox account used for? Before re-enabling them I'd like to find out a little more info. -- Brian Spooner, MCSE Network Engineer They are DISABLED by default. I'd leave them alone, as they are used for system purposes and you don't ordinarily need to muck about with them. -- Neil Hobson Exchange...

Disabled "Switch Row/Column" when creating chart from a pivot tabl
I have a pivot table where there are week numbers and three different data values pr week. This I want to graph so that the weeks are on the X-axis, the values on the Y-axis and a legend telling which of the three datasets are which. When I create a Line graph the weeks are put as a legend and the X-axis have the three different datasets grouped. This is not what I want. When I go into "the "Select data..." dialog box all the options are disabled. Why is this and how can I get the graph to show the way I want? You will need to pivot your pivot table to move the row fiel...

Recording a command button name
I have an application where the user is prompted to save when they leave the the data entry form either by previewing a report of the data or by closing the form completely. There are two buttons a user can use to do this cmdPreview or cmdClose. I use a module to promt the user for svae. What I would like to do is differentiate to the module which button was clicked. Is there a way to do this? thanks You could take a look at Screen.ActiveControl.Name -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele (no e-mails, please!) "E" <...

tool bar button
Hi all, Could someone tell me how I could assign a function which is loaded with an add-in (*.xla) to a tool bar button. The function is to paste a date-time stamp value. The idea is that the function will be always available, via the tool bar button, in any workbook I do open. I cant figure out how to do this, while in Word it is quit simple via the "Normal.dot" template. Thx, for any help on this one. Ludovic Here is the macro. Sub NOWTIME() ActiveCell.Value = Format(Now(), "dd mmm yyyy h:mm:ss AM/PM") End Sub Store it in a module in a new workbook. A...

Back Button on asp.net pages
I'm building a site and there is a series of asp.net pages with forms on them. My client would like back buttons placed on each page. Currently I just have some javascript code sending you back to the last page. When I click it I get a "Page has expired" error. I'm just wondering if there's any way around having to click refresh, So that when you click back it automatically loads up the page with your fields filled in and everything. Any help would be great, thanks. Will Hi, ask this question at "microsoft.public.dotnet.framework.aspnet" newsgroup or...

"Totals" button in query
While trying to figure out a vacationing coworker's query, I find that he's got a "Total" row in the quey grid, and I discovered that by clicking on what looks like the greek letter sigma on the toolbar, that it toggles this row on/off. Suboptions are Group By, Sum, Avg, etc. but I can't tell from executing the query that they do anything. All his "Total" values are "Group By." Thanks for any insight. A "Totals" query is a Select query that is doing some aggregate calculations on the data selected: Sum/Average/Count the number of rec...

Send To/Mail Recipient, Send button does not work.
I am stumped. I am using Outlook 2003 on a Windows XP Pro machine. When I right-click a file and select "send to - mail recipient", everything functions normally. A message window pops up with the file I right-clicked attached and a breif message automatically inserted in the body of the e-mail. However, when I add any valid e-mail address and click send, nothing happens. When I hover the mouse over the send button, it highlights like it should, and when I click it, it depresses like it shoud, but nothing happens. The window stays open, and the message never gets sent. Sending a mess...

Mouse Cursor disabled
I am trying to bring up Windoes XP home on my old Compaq 100, which came with Win 98. It loads, but the mouse cursor is not usable--it jumps erracticly and does not allow me to click on anything. Also, when I try to bring up the programs screen, it comes up, but then quickly reverts to a basically blank screen. Help would be appreciated. open your mouse and check the rollers for lint balls. and other dirt. "Bonnell-frost" wrote: > I am trying to bring up Windoes XP home on my old Compaq 100, which came with > Win 98. It loads, but the mouse cursor is not us...

Out of Office reply on a disabled account
All, We have set Out of Office Reply on a mailbox. This is an Exchange 2007 Mailbox. Our AD is Windows 2003 and Exchange is 2007 SP1 Roll up 9.0. After we disable the account in AD, the Out of Office stops working on this mailbox. Is this a default behaviour. Can this be changed in an Exchange organization. Any article from MS on this ? -- Haroon Malik ...

programtically change an Embedded picture of a command button
I'd like to prgramatically change the Embeded picture of a command button. I don't want to use a linked picture because the application is portable and I don't want to have to copy the image along with the .mdb Anyone have sample code for this? Have an invisible CommandButton of the same size with the required image embedded, then use the PictureData property. Me.cmd1.PictureData = Me.cmd2.PictureData should do it. -Jon "TADropik" <tom@sportmutt.com> wrote in message news:0BBECB0B-06BB-42D4-8FA4-7B0565E84E7E@microsoft.com... > I'd like t...

Hide ISV/Test/Both information buttons
Hi, Can I remove or hide the "ISV/Test/Both" information buttons so these are not displayed to the users (it is annoying and the purpose of these buttons is not clear even when considering using an ISV (we don't have an ISV software at the moment). The server is very unstable for components other than the basic customizations so any solution of customization will be better than changing ISV.config (I read about the XML tool for download). Thanks ...

disable the grouping facility
just bought a new machine - it has outlook 2007 preloaded. I have hundreds of sub folders in .pst files and want to globally disable the grouping feature for these messages and any new folders that I might create in the future. However, when looking in the microsoft library for how to do this, it talks about the Office Customization Tool (OCT). I don't have that in outlook or in Microsoft Office Tools. It is a real bugbear and when it should be a simple matter to sort out! Change the default messages view; View-> Current View-> Define Views...-> select Messages-...

Min Max buttons of Excel Worksheet
Hello, I recently recieved an Excel file from someone where the Min, Max & Close buttons of the Excel Worksheet are disabled. Also you cant move the Worksheet window around. How is that done ? How can they be enabled ? I know VBA coding & there are no Modules or code in the worksheet. Is this just a setting ? Any help would be greatly appreciated. Thank you, Jeff Hi Jrff The workbook is protected I think Tools>Protection.....Protect workbook (Select Windows) -- Regards Ron de Bruin http://www.rondebruin.nl "Jeff" <Jeff@discussions.microsoft.com> wro...