From: sriparna4u on
I am learning MFC.I am creating a application where in main
application(main dialog box) there are two buttons and pressing those
two you will get same another dialog box......only difference is one
button in 2nd dialog box wont be displayed in one of those two
cases.....that means if i m pressing button1 and gettng the 2nd dialog
box the button will be there and if i m pressing button2 and gettng
same dialog box without that button....how can i do that???please give
me your valuable suggestion.....

could you please send me mail in sriparna.som(a)sasken.com and
sriparna4u(a)gmail.com....


i am trying with HideButton(nId,TRUE/FALSE) ....is that ok????
From: David Lowndes on
>I am learning MFC.I am creating a application where in main
>application(main dialog box) there are two buttons and pressing those
>two you will get same another dialog box......only difference is one
>button in 2nd dialog box wont be displayed in one of those two
>cases.....that means if i m pressing button1 and gettng the 2nd dialog
>box the button will be there and if i m pressing button2 and gettng
>same dialog box without that button....how can i do that???please give
>me your valuable suggestion.....
>...
>i am trying with HideButton(nId,TRUE/FALSE) ....is that ok????

I assume your button is on the dialog, so CToolBarCtrl::HideButton
isn't of any use. You need to use ShowWindow to hide the button
control, something like this:

CMyDialog::M1()
{
.....
GetDlgItem(IDC_BUTTON1)->ShowWindow( SW_HIDE );


Since you need to control this from the invocation, I suggest that you
add a boolean public member variable to your dialog class and set it
appropriately at the point where you invoke the dialog, then test it
in your dialog's OnInitDialog handler and conditionally hide your
button.

Dave
From: Joseph M. Newcomer on
See below...
On Mon, 02 Jun 2008 08:26:09 +0100, David Lowndes <DavidL(a)example.invalid> wrote:

>>I am learning MFC.I am creating a application where in main
>>application(main dialog box) there are two buttons and pressing those
>>two you will get same another dialog box......only difference is one
>>button in 2nd dialog box wont be displayed in one of those two
>>cases.....that means if i m pressing button1 and gettng the 2nd dialog
>>box the button will be there and if i m pressing button2 and gettng
>>same dialog box without that button....how can i do that???please give
>>me your valuable suggestion.....
>>...
>>i am trying with HideButton(nId,TRUE/FALSE) ....is that ok????
>
>I assume your button is on the dialog, so CToolBarCtrl::HideButton
>isn't of any use. You need to use ShowWindow to hide the button
>control, something like this:
>
>CMyDialog::M1()
>{
>....
> GetDlgItem(IDC_BUTTON1)->ShowWindow( SW_HIDE );
****
There is no reason to use GetDlgItem. Create a control variable for your button; then you
can write

c_MyButton.ShowWindow(show ? SW_SHOW : SW_HIDE);

or something like that.

See my essays on dialog control management and building dialog-based apps on my MVP Tips
site.
joe
>
>
>Since you need to control this from the invocation, I suggest that you
>add a boolean public member variable to your dialog class and set it
>appropriately at the point where you invoke the dialog, then test it
>in your dialog's OnInitDialog handler and conditionally hide your
>button.
>
>Dave
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm