Regarding MFC Property sheet - mfc

I have two queries.
Is there any way to disable the traverse to other property pages when I am working on one page in MFC ?
Is there any way to go to the next page of the property sheet on click of a button in the current page in MFC ?

1.
CMyPropertySheet::DisableNextButton()
{
SetWizardButtons(PSWIZB_BACK);
}
CMyPropertySheet::EnableNextButton()
{
SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
}
I'm not sure, if this makes the button invisible. Maybe SetWizardButtons(PSWIZB_DISABLEDFINISH) will also disable the next button, if the finish button isn't yet reached.
2.
CMyPropertySheet::GoToNextPage()
{
PressButton(PSBTN_NEXT);
}

Is there any way to disable the traverse to other property pages when
I am working on one page in MFC ?
respond to the PSN_KILLACTIVE message and return TRUE
MFC equivalent: OnKillActive
Is there any way to go to the next page of the property sheet on click
of a button in the current page in MFC ?
send a PSM_PRESSBUTTON message with wParam as PSBTN_NEXT
MFC equivalent: PressButton, like PressButton(PSBTN_NEXT)

Related

CListCtrl (MFC) selection click passes through to control UNDERNEATH the list

My CListCtrl (Report View, single column) ignores item selection when there's another control behind the CListCtrl. It's as if the click passes through to the control BEHIND the CListCtrl.
Selection is fine if the list item isn't on top of another dialog-box item.
It's baffling because the CListCtrl's z order is ABOVE these other controls. Can anyone suggest something I could try to make the CListCtrl accept a click even when there's another overlapped control? Thanks!
User Spy++ to check the message flow. And to check if another control is above your control! Maybe there is something wrong with you´r z-order even if you think that the control is above. Also check if you overwrote WM_NCHITTEST

How to mark multiple CButtons as clicked in MFC

I have a set of normal CButtons in MFC when a user clickes on one button its appearence should be changed to reflex the idea that it has been clicked sth like in the picture
i tried to change the style of the clicked button using the following code
button->SetButtonStyle(BS_DEFPUSHBUTTON);
Invalidate();
but the problem with this approach is that just one button at time is allowed to be marked so any ideas ? is the only way is to use a bitmap ?
Use CButton::SetState
This page has an example of what you want to do:
http://msdn.microsoft.com/en-us/library/ebw1hfe8(v=vs.90).aspx

Handling WM_KEYDOWN in edit control on modal property sheet

First of all: I'm using C++ and ATL+WTL.
I am trying to handle the WM_KEYDOWN for an edit control that is on a page of a modal property sheet. I'd like to get the VK_NEXT key while VK_CONTROL is down. Without success so far, I only get VK_NEXT if VK_CONTROL is not down. The modal property sheet seems to eat this combination, it is used to cycle through the tabs in a standard property sheet. I have already tried to let the edit control handle WM_GETDLGCODE and return DLGC_WANTALLKEYS but still don't get this combination. However if I use modeless property sheet everything works fine (property sheet does not handle Ctrl+PageDown and edit control receives those keys). In my application I don't want to make a modeless property sheet.
So the questions is: Is there any way to handle those keys (VK_CONTROL + VK_NEXT) in edit control placed on modal property sheet?

Two-state button that mimics a checkbox in MFC

I want to make a button on an MFC tool bar that can be pressed and retain it's state until pressed again (like a check box) but I don't want a tick box. I'd ideally like a button that changes between two icons and uses DDV to change the value of a boolean on being pressed. How would I go about this.
As a side question I could really do with a good book on MFC. I've got Programming Windows with MFC 2nd edition, but was wondering if there was anything that went into a bit more detail?
Use ON_UPDATE_COMMAND_UI to set the state of the button. e.g. a typical handler will look like this:
BEGIN_MESSAGE_MAP(CMyView, CView)
ON_UPDATE_COMMAND_UI(ID_MY_BUTTON, OnUpdateMyButton)
END_MESSAGE_MAP()
...
void CMyView::OnUpdateMyButton(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck( isButtonPressed() );
}
With regard to good MFC documentation I recommend Professional MFC (Mike Blaszczak) - it's a little old but very good.
From the documentation of the CToolBar Class:
To create a check-box button, assign it the style TBBS_CHECKBOX or use a CCmdUI object's SetCheck member function in an ON_UPDATE_COMMAND_UI handler.
Draw a Radio Button on Dialog box.
Select Radio button & go to button Properties page.
Set Push Like property & set as "True"
Add event handler for the same control & take Boolean variable.
Use API -> "CheckDlgButton(IDC_RADIO1, 1);" for set status as per Boolean variable value.
for more details. visit below link.
https://www.codeproject.com/Articles/530/A-Better-Bitmap-Button-Class

How to hide a modal dialogbox in MFC application?

I have a hard time hiding a modal dialog box. What I am doing is - I am trying to design a UI for my own application in MFC, kind of a setup assistant.
In the 1st dialog box I have NEXT button, so when I click that it has to hide the 1st dialog box and move on to the 2nd dialog box, where I have some controls in 2nd dialog box.
How can I achieve that?
I have never tried to hide a Modal dialog...not sure how it can be done.
Anyway, it seems to me you don't need to hide the dialog but destroy the first one and create the second one. You can use EndDialog to terminate a modal dialog.
But MFC has its own mechanism to create your own wizard, have a look at this class CPropertySheet. I am sure you can find thousand of examples, this is one.
Hope it helps.
You can use ShowWindow() function to hide modal
Its default patametet is SW_SHOW which is equal true value 1 and
To hide modal use SW_HIDE value when you click next button
You just use ShowWindow(SW_HIDE) If you make prev button you should use modal pointer
Or next modal should child modal because you cannot have prev modal variable.
I wish you understand me for my english