Adding a button to a Wizard

I must be overlooking something really simple, but I just cannot see
it...

I have a wizard project in which I'd like to create a CButton
dynamically for the main "sheet".  The button may exist on all
subsequent pages swapped in, or could be hidden.

I get the button to appear (it gets drawn over a bitmap background),
and it does respond to the enter key (when in focus) as my OnMyButton
method gets called.  However, clicking it with the mouse doesn't get me
anything?

I create the button as follows, for reference:

aRect.SetRect(20,540,80,600);
m_TestSheetBtn.CreateEx( NULL, _T("Button"), _T("Home"),
     WS_CHILD | WS_TABSTOP,
     aRect.left, aRect.top, aRect.Width(), aRect.Height(),
     m_hWnd, 0, 0 );
m_TestSheetBtn.SetFont( GetFont() );
m_TestSheetBtn.SetDlgCtrlID(IDC_SHEETBTNTEST);

m_TestSheetBtn.ShowWindow(TRUE);
m_TestSheetBtn.SetWindowText("<< Home");


Any thoughts where I have screwed up would be appreciated.

Thanks
-Vin

0
9/9/2005 12:07:41 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
419 Views

Similar Articles

[PageSpeed] 49

What you're missing is that you should not be creating controls dynamically.  Just create
it in the dialog editor. You create it at design time on all the pages.  Then add handlers
for it.

Pretty much all the code you wrote is nonsensical.  Why write all that code when it is so
trivial to add the button and its handler?  Then, if you don't need it, you just hide it.
Since a wizard project consists of a sequence of dialogs, you can put anything on them you
want to at design time. Why did you not create it with the designed control ID instead of
assigning it later? You did you define how you have implemented your handler.  All of
these problems (including internationalization--why are you hardiwiring language-specific
words into your source code?) disappear if you just do it at design time.

The problem with the mouse is that you probably have created it in the wrong Z-order so
the mouse clicks are going to some other window which is logically on top of it. This
problem can also be avoided just by creating it as design time.

(There are many valid reasons for creating controls at runtime, but this is not one of
them. I see no reason this could not be done at design time)
				joe

On 9 Sep 2005 05:07:41 -0700, "develop" <develop@iesoft.com> wrote:

>I must be overlooking something really simple, but I just cannot see
>it...
>
>I have a wizard project in which I'd like to create a CButton
>dynamically for the main "sheet".  The button may exist on all
>subsequent pages swapped in, or could be hidden.
>
>I get the button to appear (it gets drawn over a bitmap background),
>and it does respond to the enter key (when in focus) as my OnMyButton
>method gets called.  However, clicking it with the mouse doesn't get me
>anything?
>
>I create the button as follows, for reference:
>
>aRect.SetRect(20,540,80,600);
>m_TestSheetBtn.CreateEx( NULL, _T("Button"), _T("Home"),
>     WS_CHILD | WS_TABSTOP,
>     aRect.left, aRect.top, aRect.Width(), aRect.Height(),
>     m_hWnd, 0, 0 );
>m_TestSheetBtn.SetFont( GetFont() );
>m_TestSheetBtn.SetDlgCtrlID(IDC_SHEETBTNTEST);
>
>m_TestSheetBtn.ShowWindow(TRUE);
>m_TestSheetBtn.SetWindowText("<< Home");
>
>
>Any thoughts where I have screwed up would be appreciated.
>
>Thanks
>-Vin
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/11/2005 5:17:36 AM
I'm not a big fan of creating dynamic controls either!  FWIW, I'm
creating this using a CPropertySheet wizard and hiding the Buttons that
come along (Next, Back, Finish).  I would like to add these in the
dialog editor but the sheet is created dynamically!  :)

Now each of the "pages" swapped in can be edited in the resource
editor.  What I would like to do is to have a button visible when each
page is swapped in (since not the entire sheet is taken up) and *not*
have to create it in each "page".

If adding the button dynamically to the propertysheet is incorrect, how
do I do this correctly then?

Thanks,
-Vin

0
9/12/2005 7:30:24 PM
Since you are hiding all the other buttons on the property sheet, then putting it on each
page seems a minor issue.

Dynamic property sheets are one of the few places you are actually forced to do dynamic
button creation, alas. But I'd check out www.codeproject.com to see if anyone else has a
solution.
				joe

On 12 Sep 2005 12:30:24 -0700, "develop" <develop@iesoft.com> wrote:

>I'm not a big fan of creating dynamic controls either!  FWIW, I'm
>creating this using a CPropertySheet wizard and hiding the Buttons that
>come along (Next, Back, Finish).  I would like to add these in the
>dialog editor but the sheet is created dynamically!  :)
>
>Now each of the "pages" swapped in can be edited in the resource
>editor.  What I would like to do is to have a button visible when each
>page is swapped in (since not the entire sheet is taken up) and *not*
>have to create it in each "page".
>
>If adding the button dynamically to the propertysheet is incorrect, how
>do I do this correctly then?
>
>Thanks,
>-Vin
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/14/2005 4:34:10 PM
Reply:

Similar Artilces:

Adding a Report to V3
I have created a report using RS, and tried to add the report using the New report in CRM. I get an error that i should contact the System Admin...well i'm logged in as Administrator, i have Local and Domain rights, i'm a DBO...can't think of many more rights that i'll need. Can anyone hazzard a guess at what needs to be done?? Event viewer is giving me no hints at all, as usual!!! Many thanks in advance Ben first thing is to try to download an existing report to an rdl file then upload it again. also what configuration is your crm system? is your web and sql on separat...

query against AD
EXCEL 2003 1. data, import external data, new database query. Is there a way to query a AD ? ...

Delete button is grey
This is a multi-part message in MIME format. ------=_NextPart_000_002B_01C94B2C.0D4D6530 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I've got Outlook 2003. When I view my inbox or any other folder, I = cannot select a message and then click the red x to delete it. I have to = open the message and then delete it. Anyone have any idea how to fix this one? --=20 Thanks, Rob ------=_NextPart_000_002B_01C94B2C.0D4D6530 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOC...

AD Changes And CRM
Hi, I'm currently implimenting CRM for a client who is concerned about any changes that CRM may make to their AD structure. Once CRM has been installled, apart from the following list of actions does anything else cause changes to be made to AD as a result of using CRM v1.2? Creating modifying CRM business units Creating/modifying CRM roles Creating/modifying CRM teams Assigning CRM roles to users kind regards, les greenhalgh No, you have got it covered there. Usually most Network Admins are concerned if the schema is going to be modified, but CRM does not do that so I my experien...

Automatically adding data between two dates.
I need to populate a series of rows between a start date and an end date. I am trying to analyze a group of monthly gas bills (84 in all) that randomly start and end on different dates. To complicate things the duration of the "days billed" change from month-to-month; -Some bills within the same month can span 26 days while others may be 35 days long. What I would like to do is populate a querie that has columns for the meter#, date, and average cost per day. Once populated I could sort out the date(s) that I need to look at. I have the data entered in a table t...

Programmatically triggering a button click
I found this subject within the newsgroup, but it does no longer exists on the server, so I have to repeat the question: How do I programmatically trigger a button click? I tried this, and does not work... this->SendDlgItemMessage(IDC_BTN_EMAIL, BN_CLICKED, 0, (LPARAM)m_btnEmail.m_hWnd); This did no work either: ::SendMessage(this->m_hWnd, WM_COMMAND, BN_CLICKED, (LPARAM)m_btnEmail.m_hWnd); Thank you! Ricardo. Usually your button click starts a routine named OnBTN_EMAIL or some such and all you have to do is call that same routine. Ken "Ricardo Vazquez" <rvazquez@d...

MS Word and Track in CRM button
Sometimes the buttons "Track in CRM" and "Regarding" appear in MS Word. Clicking the track-button causes a crash of MS Word. I like the possibility to track a word document in CRM from Word, but I'm sure this is not standard functionality. (-; What is the cause of this problem and how can it be solved? Any help appreciated. Delta-N B.V. This issue shows up when you are using Word as your email editor for Outlook. What is happening is that the CRM toolbar used for tracking email in CRM is also being displayed by Word. Clicking on this button in Word will not...

'Refresh All' button for interactive spreadsheet not working in Web page
We are able to successfully publish a spreadsheet to the web, but the "Refresh All" button is grayed out. We are able to refresh while working with the spreadsheet in Excel. The data sources are three external text files, all residing on our website in the same folder as the spreaadsheet. What is keeping us from being able to refresh the data on the web? ...

Rules Wizard #45
Hi, I use Outlook's Rules Wizard to eliminate most spam that comes into my inbox, by checking the "with specific words in the recipients address" box, and adding the offending address. But lately I've noticed that mail that is sent (To or CC) to "Spam" or "Webmaster" slips under the radar somehow. Any clues as to how to eliminate these messages?? ...

adding 2nd email address
I am in charge of performing a server migration from exchange 5.5 to exchange 2003. Instead of copying the old data from the old server to the new i decided to start new and make all new users and mailboxes on the new server. I did this for a number of reason the most prevelant being the the username scheme for our organization has changed. We used to use the <first initial><last name> scheme now we use the <first name>.<last name> scheme. All of the users were created with the email address scheme of <first name>.<last name>@mydomain.net. I want...

exchange 2003 rule wizard not working
Hi, I had a email rule set-up which use to forward a copy of some emails I received from selected people in my mailbox to my home email address, and also move it to another folder now since my work has moved to active directory from novel this does not work.. please note it does move it to the other folder just doesnt forward it to a external email address Any ideas why this doesn't work anymore and how it can be resolved. or if there is a setting or something that needs to be changed. Any help would be appreciated annoyed Automatic forwarding and replying to the Internet is disabled b...

Allow user to set and save a default option button.
Win 2000 Prof. SP4 Office 2000 Prof. I have an excel worksheet with 3 option buttons on it. The Excel file will be read-only and distributed to several users using stand alone laptops. By default the first option button is selected on open. That's how the file will be saved. I want different users to be able to change which option button will be selected when the Excel file opens so they don't have to click on a different option button every time if they always want an option selected other than option button 1. I want the Excel file to hold a user selected default for a startup opti...

Adding senders to block list
Under Actions -> Junk Email there is a button to "Add Sender's Domain to Safe Senders Lists" Does anyone know if there is a way to add the senders domain to the blocked senders list. Right now I just go into the blocked senders list and edit the email address to block the domain. Or should this be a suggestion to Microsoft. Thanks ...

Money 06 OEM Cost Basis columns added incorrectly
I use the above ver of Money and enter my own transactions into PortfolioManager. Before last week I had 7 mutual fund accounts there and all was fine. Then I bought some stock from an online broker. I set up the investment account on the Acounts list page and everything looks good...the account register lists proper prices, costs, commissions etc, and the cash transactions register is correct. At least everything makes sense to me... When I goto PortfolioMan, the stock account is listed as it should, but for some reason the 'Cost Basis' column is totaled wrong, which is messin...

Linked Tables
Hello All, Any suggestions would be greatly appreciated. This problem has been bothering me for a week now. I have a make table query which takes data from a linked Excel table and creates a new 'Combine' table. When it creates the Combine table I also add another field called 'Source' to the Combine table. I then have several append queries which I link to additional Excel linked tables. I take this data and add it to the Combine table along with a 'Source' field. I created the source field because I needed to have a field which would tell me which linked tabl...

Wrong result is coming while adding tow figures
Hi all, I wrote the following function . But in some time the result is showing wrong format. When VarSum gets value 185.42 and ValueSum gets -185.42 the result should be 0. VarSum = VarSum + ValueSum 0= 185 + - 185 . But some cases Excel shows the balance as 8.5265128E-14. Please help. I given the function below. Sub CashBookMacrosnew() Dim VarSum As Double Dim ValueSum As Double Dim VarSumOld As Double Dim totalsum As Double lastrow = Range("B" & Rows.Count).End(xlUp).Row currow = ActiveCell.Row pre_row = ActiveCell.Row Col_A = "" ...

Option Button
I've got 5 questions set up in a form in Excel where I want to use the Option Button from the Forms menu. So I set up 5 separate groups so the buttons would behave independently within the groups. However, how do I get rid of the border and the text "Group XX"? I think you'll have to use a bit of VBA. Option Explicit Sub testme() ActiveSheet.GroupBoxes.Visible = False End Sub Change it to True to see them again--nicer for developing. == If you don't use macros, you can select your sheet, then hit alt-F11 (to get to the VBE) then hit ctrl-G (to see the immed...

adding totals... more complex than it sounds..
i have a table, i have a column of cells containing the values 'k' or 's' or 't' or 'r' i then have a column of cells containing a sum of money representing a figure 'k' has achieved on that particular row of cells etc. i need to add the number into a seperate cell that will have the total value of all of 'k' sums of money sorry if thats confusing, its kinda hard to explain Use SUMIF, along the lines of: =SUMIF(your_range_containing_letters,"k",your_range_containing_money) For example, it might look like this: =SUMIF(A1:A100,"...

Toggle buttons dont turn blue??
I made a database for a Home Based Care project in rural South Africa. Now that I am here I installed it onto their computer. Only to find that although everything works, the toggle buttons I used do not turn blue when they are activated on their computer. They do work, but they just dont turn blue. With computer skills as limited as they are here, it would be nice to have clear indications of the choices people make on their form. I use Windows Vista home basic with Access 2003. They have Windows XP with access 2003 from the same group installation as I use. Theirs is a deskto...

How do I bring back the Outlook 2003 startup wizard?
Hi all, I am setting up a PC that will be used by multiple users. They are moving from Outlook Express to Outlook 2003 using a regular POP3 mail server (not Exchange.) I've done this plenty of times before and normally, when a new user runs Outlook for the first time, they get the "Welcome to the Outlook Startup Wizard" screen. It detects the existing Outlook Express message store, asks if they want to import their settings and mail, etc, and all is good! Well, I made the mistake of running Outlook once on the user profile I used to make the default profile on a new PC. ...

Adding working days
Hi All I wish to add Working days to a date: I have the formula: =IF(D3="","",A3+(F3/10)+7) A3 is a date, I wish to add (F3/10)+7 working days to A3, how do I rewrite the formula? Thanks in advance. -- George Gee If you load the Analysis Toolpak Add-in (Tools/Addins...): =IF(D3="","",WORKDAY(A3,F3/10+7)) In article <e$chxFbGEHA.3776@tk2msftngp13.phx.gbl>, "George Gee" <george.nomaps@ntlworld.xom> wrote: > Hi All > > I wish to add Working days to a date: > > I have the formula: > =IF(D3="&qu...

Exchange 2003 in 2003 native AD
Something I just noticed here while working on a few tests with exh2k3 and windows2003. I have a small domain setup with 2 DCs which are also GCs, AD is running in 2003 functional level (as well as 2k3 forest functional). On 'ntserver2' (original, yes?) I have Exchange 2k3 installed, in it's AD users and computers when I click on a user I get all the exchange options for him/her On 'ntserver1' which is just a DC/GC, I go to AD users and computers, click the same user, I get just the general user options (no exchange info). If the servers and AD etc. is being replicated ...

Adding Attachments Shuts Down Outlook 2003
We recently upgraded to Office 2003. When trying to add an attachment to an email message in Outlook 2003, a box pops up indicating there's been an error and options to report it to Microsoft. Outlook closes. Have tried uninstalling and reinstalling with same end result. Anyone else experiencing this and found a solution? -Make sure all your add-ins are Outlook 2003 compatible -Recreate your mail profile in Control Panel-> Mail-> button Show Profiles (recommended after an upgrade) -See if it also happens in safe mode; Start-> Run; "path to outlook.exe" /safe ...

Second server added, send recieve problems
Hi all We are in he process of moving mailboxes to a newly installed machine on site. Both machine run 2003/SP1. We moved one mailbox from server A to server B, but the user cannot receive or send e-mail. All users on the original server can send and receive without any problem. What are we missing? -- Stokes What happens when user tries receive or send? la02 wrote: > Hi all > > We are in he process of moving mailboxes to a newly installed machine on > site. Both machine run 2003/SP1. We moved one mailbox from server A to > server B, but the user cannot receive or send...

button grayed out for Charting
I am trying to use the Chart Wizard or the Chart Toolbar to create a chart. However, both are greyed out. Any idea why or what I should do to fix this? thanks, Ron Usual suspects are protected workbook or worksheet. Shared workbook. rgraham1 wrote: > I am trying to use the Chart Wizard or the Chart Toolbar to create a chart. > However, both are greyed out. > > > > Any idea why or what I should do to fix this? > > thanks, > > Ron > -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info Thanks for the fast reply Andy. I've checked...