Changing layout to a CDialog

Hi to all. I'm trying to develop a CDialog subclass with to possible 
associated resource IDs, is it possible? I tried this code:

CMyDialog dlg;
dlg.Create(IDD_LAYOUT1); //create the dialog with first layout
//...
dlg.SetDlgCtrlID(IDD_LAYOUT2); //I want to change the layout, without to 
destroy the window and recreate it!
dlg.UpdateData(FALSE);

but nothing happens. What is wrong?
Thanks in advance
Bye
Andrea




0
Acaccia
10/5/2005 2:22:01 PM
vc.mfc 33608 articles. 0 followers. Follow

9 Replies
992 Views

Similar Articles

[PageSpeed] 0

Perhaps the CDialogTemplate class might be useful for what you are trying to 
do?

-- 
Regards,
Nish [VC++ MVP]


"Acaccia" <andrea.cacciarru@~NOSPAM~email.it> wrote in message
news:di0ni7$ous$1@mammooth.localnet...
> Hi to all. I'm trying to develop a CDialog subclass with to possible
> associated resource IDs, is it possible? I tried this code:
>
> CMyDialog dlg;
> dlg.Create(IDD_LAYOUT1); //create the dialog with first layout
> //...
> dlg.SetDlgCtrlID(IDD_LAYOUT2); //I want to change the layout, without to
> destroy the window and recreate it!
> dlg.UpdateData(FALSE);
>
> but nothing happens. What is wrong?
> Thanks in advance
> Bye
> Andrea
>
>
>
>



0
nish (347)
10/5/2005 3:38:23 PM
"Nishant Sivakumar" <nish@nospam.asianetindia.com> ha scritto nel messaggio 
news:ub1yuKcyFHA.3756@tk2msftngp13.phx.gbl...
> Perhaps the CDialogTemplate class might be useful for what you are trying 
> to do?
>

I have already tried to use this (undocumented) MFC class, but it works only 
if I change the template dialog in the constructor.
I should to change a CPropertyPage layout:

 void CMyPropertyPage::SetTemplateDialog() {
 m_Template.Load (MAKEINTRESOURCE (IDD_LAYOUT2));
 m_psp.pResource = (LPCDLGTEMPLATE)m_Template.m_hTemplate;
 m_psp.dwFlags |= PSP_DLGINDIRECT;
}

where  m_Template is a CDialogTemplate member.
But nothing happens... :o(
I have created a CMyPropertyPage that receives the resource IDD  in the 
constructor and set it to the super class CPropertyPage.
A generic CPropertyPage call the Create function when it is added to the 
CPropertySheet object, by AddPage method, so if I do:

CMyPropertyPage* pmyPage = new CMyPropertyPage(IDD_LAYOUT1);
//...
pmyPage->SetTemplateDialog(); //change to IDD_LAYOUT2
mySheet.AddPage(pmyPage); //create page with IDD_LAYOUT2

it works fine. But if I do

CMyPropertyPage* pmyPage = new CMyPropertyPage(IDD_LAYOUT1);
//...
mySheet.AddPage(pmyPage); //create page with IDD_LAYOUT1
pmyPage.SetTemplateDialog();  //change to IDD_LAYOUT2

seem does not work. Why?
Andrea





0
Acaccia
10/5/2005 4:26:00 PM
> Hi to all. I'm trying to develop a CDialog subclass with to possible 
> associated resource IDs, is it possible?
Not really. At least not easy enough to be worth the trouble.
Basically you have to distroy all the kids in the original dialog, resize the 
dialog, change the flags and font, then recreate all the new kids.
Basically everything changes except for the dialog handle and the class.
Kind of useless for so much work.

-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
0
10/6/2005 6:21:27 AM
"Mihai N." <nmihai_year_2000@yahoo.com> ha scritto nel messaggio 
news:Xns96E6ED9AD5934MihaiN@207.46.248.16...
>> Hi to all. I'm trying to develop a CDialog subclass with to possible
>> associated resource IDs, is it possible?
> Not really. At least not easy enough to be worth the trouble.
> Basically you have to distroy all the kids in the original dialog, resize 
> the
> dialog, change the flags and font, then recreate all the new kids.
> Basically everything changes except for the dialog handle and the class.
> Kind of useless for so much work.

No, I don't want to destroy anything about my Dialog... I only want to 
change the layout and my CDialog derived class can manage (have an handle) 
of all buttons, edit boxes etc. that is a set union of all layouts 
(otherwise the same button in the dialog can be displayed in many ways for 
different layouts).
Maybe I ask too much to mfc ...
thanks for your answer...

Bye Andrea




0
Acaccia
10/6/2005 3:02:01 PM
"Acaccia" <andrea.cacciarru@~NOSPAM~email.it> wrote in message 
news:di3e8p$ina$1@mammooth.localnet...
>
> "Mihai N." <nmihai_year_2000@yahoo.com> ha scritto nel messaggio 
> news:Xns96E6ED9AD5934MihaiN@207.46.248.16...
>>> Hi to all. I'm trying to develop a CDialog subclass with to possible
>>> associated resource IDs, is it possible?
>> Not really. At least not easy enough to be worth the trouble.
>> Basically you have to distroy all the kids in the original dialog, resize 
>> the
>> dialog, change the flags and font, then recreate all the new kids.
>> Basically everything changes except for the dialog handle and the class.
>> Kind of useless for so much work.
>
> No, I don't want to destroy anything about my Dialog... I only want to 
> change the layout and my CDialog derived class can manage (have an handle) 
> of all buttons, edit boxes etc. that is a set union of all layouts 
> (otherwise the same button in the dialog can be displayed in many ways for 
> different layouts).
> Maybe I ask too much to mfc ...
> thanks for your answer...
>
> Bye Andrea
>
Okay, if I understand correctly...

Create one dialog with all the controls for all the views you can think of 
in it.
Add a method to your dialog that you will call (before it is displayed) to 
indicate which "type" of dialog will be displayed.
In OnInitDialog, based on this flag that was set, hide/show all the controls 
on the dialog accordingly.
In OnSize (or maybe OnSizing) using SetWindowPos(...) and based on the flag 
for the "type" of dialog, move and resize all the visible controls to your 
liking.

There are plenty of examples on Hiding/Showing controls and reflowing the 
controls for resizing dialogs at CodeProject.com and other places.  I 
suggest you check them out. 


0
10/6/2005 6:23:35 PM
> Create one dialog with all the controls for all the views you can think of 
> in it.
> Add a method to your dialog that you will call (before it is displayed) to 
> indicate which "type" of dialog will be displayed.
> In OnInitDialog, based on this flag that was set, hide/show all the 
controls 
> on the dialog accordingly.
> In OnSize (or maybe OnSizing) using SetWindowPos(...) and based on the flag 
> for the "type" of dialog, move and resize all the visible controls to your 
> liking.
> 
> There are plenty of examples on Hiding/Showing controls and reflowing the 
> controls for resizing dialogs at CodeProject.com and other places.  I 
> suggest you check them out. 
This is a total disaster for localization.
Nobody will be able to resize this, ever :-)
And English is also a mess to maintain.

Then hiding a control and showing another is the same think as distroying it 
and creating another (from functional point of view), because the ID of the 
controls changes.

=============================
In fact, what are you trying to do?
In general, all runtime, code-controled changes in dialog layout (size, 
position, visibility) are a mess for localization, and bad 
internationalization practice.


-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
0
10/7/2005 6:23:39 AM
"leov SpamMeNot" <lviolette.SpamMeNot@orrtax.com> ha scritto nel messaggio 
news:eZJDGNqyFHA.2848@TK2MSFTNGP15.phx.gbl...
> In OnSize (or maybe OnSizing) using SetWindowPos(...) and based on the 
> flag for the "type" of dialog, move and resize all the visible controls to 
> your liking.

Ok, maybe this is a working solution, but it is not what I really want to 
do. I want to change layout without to recalculate any size or hide/show any 
control by the value of a flag, but I want to change layout simply using 
another resource ID.
This probably, is not possible with mfc.
Thanks for your time
Andrea


0
Acaccia
10/7/2005 2:56:01 PM
"Mihai N." <nmihai_year_2000@yahoo.com> ha scritto nel messaggio 
news:Xns96E7EDFA62D6EMihaiN@207.46.248.16...
> This is a total disaster for localization.
> Nobody will be able to resize this, ever :-)
> And English is also a mess to maintain.

Well, this is another problem.
Can you give me any good idea to support localization changing the control 
size?
Suppose that I can have only buttons and static controls in my dialog.
Thanks for your time, bye Andrea 


0
Acaccia
10/7/2005 3:00:21 PM
Well, this is probably not a good solution either, but maybe you could use 
PropertySheet/Page and hide the Next/Prev buttons.
Good luck.
Leo.
"Acaccia" <andrea.cacciarru@~NOSPAM~email.it> wrote in message 
news:di628k$7nk$1@mammooth.localnet...
>
> "leov SpamMeNot" <lviolette.SpamMeNot@orrtax.com> ha scritto nel messaggio 
> news:eZJDGNqyFHA.2848@TK2MSFTNGP15.phx.gbl...
>> In OnSize (or maybe OnSizing) using SetWindowPos(...) and based on the 
>> flag for the "type" of dialog, move and resize all the visible controls 
>> to your liking.
>
> Ok, maybe this is a working solution, but it is not what I really want to 
> do. I want to change layout without to recalculate any size or hide/show 
> any control by the value of a flag, but I want to change layout simply 
> using another resource ID.
> This probably, is not possible with mfc.
> Thanks for your time
> Andrea
>
> 


0
10/7/2005 5:10:59 PM
Reply:

Similar Artilces:

CDialog::DoModal()
Which function I should call to show my dialog *not* as modal? I'm writing plugin for one app, and my plugin got access violation when I try to show it as modal. I would like to try to show my dialog as modeless, but it is not perfect solution. Error occures here (dlgcode.cpp, CDialog::DoModal()) in VERIFY() : if (m_nFlags & WF_CONTINUEMODAL) { // enter modal loop DWORD dwFlags = MLF_SHOWONIDLE; if (GetStyle() & DS_NOIDLEMSG) dwFlags |= MLF_NOIDLEMSG; VERIFY(RunModalLoop(dwFlags) == m_nModalResult); } Petar, Use Create instead of DoM...

Auto change formula in cells when source is changed
Good day experts; If specific cells have the same formula for example: C1 = Product( A1;B1) C16 = Product(A16;B16) C17= Product(A17;B17) And so on ... What formula should i write in C16, C17, ... so that: when the formula in the source cell, C1, is changed the formulas in C16, C17, ... would automatically change accordingly. I tried "=C1" it does not work Thanks in advance Carlo carlo wrote: > Good day experts; > > If specific cells have the same formula for example: > C1 = Product( A1;B1) > C16 = Product(A16;B16) > C17= Product(A17;B17) > And so on ... ...

Changing a text field to a date field
Hi I know this is a problem for lots of people but I still cant find an answer. I have imported a text file into excel with a number field that displays credit card expiry dates as a 4 digit number. example 0408 so month + year. I have converted the number field to a text field so it doesnt drop off the first zero and now I need to convert it to a date field. Any nice easy simple ideas. Any help would be much appreaciated. Or direction to a question the same. Perhaps =DATE(100+RIGHT(A1,2),LEFT(A1,2),1) format as date -- daddylonglegs --------------------------------------------...

Problem changing wallpaper on Vista
I am trying to change the wallpaper on Vista. I have a sub that works on XP with .jpg and .bmp images... Private Sub SetActiveDesktopWallpaper(ByVal sFileName As String, ByVal lStyle As Long, ByVal fForce As Boolean) Dim ad As ActiveDesktop Dim co As COMPONENTSOPT Dim wpo As WALLPAPEROPT Set ad = New ActiveDesktop 'check if AD is enabled co.dwSize = Len(co) ad.GetDesktopItemOptions co, 0& With wpo .dwSize = Len(wpo) .dwStyle = lStyle End With With ad ' set wallpaper style... .SetWallpaperOpt...

Statment of changes in financial position
i will be a demo of GP 10 on Weds for a customer who has a requirement for a statement of changes in financial position. Is there any reason that this would be a problem in FRx as long as i know what GL accounts make up each row? Their sales and receivables are going to be maintained in another systmer - with that system providing a journal entry either weekly or monthly. THanks! Andrea: How did this come out for you, also have you done a Schedule of Changes Report?? Pretty standard non-profit reports. "Andrea Smiley" wrote: > i will be a demo of GP 10 on Weds for a cus...

Corporate Name Change
How does one change the name of a stock (and symbol) when a company (such as AOL) decides to do so Wade: Select AOL from your portfolio, right click and choose "see details" You can rename it and change the symbol there. Kevin "Wade" <anonymous@discussions.microsoft.com> wrote in message news:023701c395d4$c6129da0$a401280a@phx.gbl... > How does one change the name of a stock (and symbol) when > a company (such as AOL) decides to do so Thanks ... I get an error stating the ticker is already in use. How can I get around this (is there a global ticker li...

changing sort order
I have followed the TK "How to BCP Data Out and Back into a New Database (875179)" a few times and it seems to work great. However, when bcp'ng the data back in, I do notice some errors as it flashes by in the dos screen, however, NONE of the .err files show any size other than 0k. After logging into Great Plains, I do notice that some information is completely missing. I check the tables and they are empty. I checked the in and out bat files and those tables are exported, then imported, the table is empty and its .err file is also blank. If the .err files do not show...

Changing Exch5.5 GAL columns in Outlook client view
Sorry if the subject line is a bit cryptic; anyway, in the Outlook client, if you display the 'Address Book' you get the following columns - name, business phone, office, title, company, alias, e-mail type, & e-mail address. How do you change it so you show the display name, business, extension, cell phone, & internet email address? Basically, how/where do you change the columnar data the client sees? Thanks, Mike Lawson Mike Goto View | Columns and there u can manage views... KJ "Mike Lawson" wrote: > Sorry if the subject line is a bit cryptic; anyway, i...

Dropdown Size: How do I change?
I have a workbook and after opening it on another computer, all the dropdowns are way too wide. And how can I have them show 20 items rather than the default of 8? Thanks, Craig Right-click the dropdown and you can change the 8 to any other number. To make it less wide, right-click it and drag the right/left border to the size you want. It MAY have something to do with the screen resolution on the other computers...? Bob Umlas "Craig Roberts" <Somewhere @ Lindstrom Minnesota USA> wrote in message news:e4jiOnVPFHA.1268@TK2MSFTNGP14.phx.gbl... >I have a workbook a...

How can I change primary display for presentation on multiple mon.
I want to hit F5 and have my presentation go to a different monitor. I have multiple monitors so my laptop display on a classroom screen. Can I change the default monitor that F5 points to? In article <5A95BBFC-B291-4A05-9E71-3F094B937ABB@microsoft.com>, Shorebilly wrote: > I want to hit F5 and have my presentation go to a different monitor. I have > multiple monitors so my laptop display on a classroom screen. Can I change > the default monitor that F5 points to? In the Slide Show | Set up show dialog, you can choose the monitor you want to display slide s...

HOWTO Make CDialog's with ActiveX in a LIB.
HOWTO Make CDialog's with ActiveX in a LIB. Please help, I'm having a heck of a time trying to get a CDialog derrived class host a single ActiveX control (the CWebBrowser control), from a static LIB. When the OnInitDialog for the class call's CDialog::OnInitDialog it bombs inside the DoDataExchange for the DDX_Control of the control. Specifically at dlgdata.cpp line 43, with the following ASSERT: TRACE(traceAppMsg, 0, "Error: no data exchange control with ID 0x%04X.\n", nIDC); The reason why this ASSERT fails is because the CDialog's "m_pCtrlCont" i...

pointer changes from arrow to plussign
Somehow the pointer arrow in excel has changed from an arrow to a plus sign. How can I change it back to an a n arrow? That would depend upon where you are pointing the cursor. If anywhere on the cells portion of a worksheet, the cursor is a fat white plus sign. If pointing to menus, toolbars, sheet tabs or scrollbars the cursor should be an arrow. Are you saying your cursor "never" changes to an arrow? Gord Dibben Excel MVP On Wed, 14 Apr 2004 19:15:34 -0700, "gmohanco" <anonymous@discussions.microsoft.com> wrote: >Somehow the pointer arrow in excel has c...

changing the message list in outlook 2003
i just upgraded from office 2000 to 2003. in the message look in outlook, it separates the messages by date. is there any way to turn this off, so i just have a long list of messages? Right click on the header in the message list, uncheck "show in groups." --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the SWEN virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Lee Benningfield asked: | i just upgraded from office 2000 to 2003. in the mess...

Cell colour change automatically
Is it possible to create a formula to automatically turn a cell a given colour? Example: - If I type the word "Yes" in a cell I would like the cell to turn red automatically, If I type the word "No" in a cell I would like the cell to turn green automatically. Is this possible? If yes please recreate a formula to assist me. Many thanks -=- dustyv Take a look at "Conditional Formatting" in XL Help. In article <45794F52-0D61-4B8F-8562-A3E9E6F957BE@microsoft.com>, dustyv <dustyv@discussions.microsoft.com> wrote: > Is it possible to create a formul...

Adding Toolbar to CDialog
Hello, I have a CMenu object that is attached to my dialog at the top and I am trying to add a Toolbar under the menu. This is how I am trying to add a toolbar to my dialog box: int CSvg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -1; //This adds CWebBrowser2 object and works OK if ( ! m_explore.Create( NULL, WS_CHILD | WS_VISIBLE, CRect(), this, IDC_EXPLORER3 ) ) return -1; //this does NOT add toolbar and it does NOT work OK if (!m_toolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_DYNAMIC | CBRS_TOP | CBRS_TOOLTIPS | CBR...

how to change the background color of menu bar
I want to change the background color on the menu bar in excel 2003. Can anyone help me. the color is controlled by Windows. On your desktop, Right click and choose Properties Click the Appearance tab and then choose "Advanced" In the "Item" dropdown choose Menu pick your desired color and click OK, OK NOTE: THIS CHANGE WILL AFFECT ALL WINDOWS APPLICATIONS -- swatsp0p ------------------------------------------------------------------------ swatsp0p's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=15101 View this thread: http://www....

Changing cell format
I have a worksheet that is populated with data exported from Access. The data in the Access table was serial numbers with an occasional (rare) alpha character. The column was formatted "Text" in Access. When I exported it to Excel, every value in this field (around 3000 entries), has an apostrophe (') inserted at the frontof the cell. Find and Replace does not see the ' How can I remove this so that I can use Fill>Series to populate the gaps in my data (there are many gaps)? Try copying the ' Access character and pasting it into the Replace menu. It could be...

Changing cell from formula to data.
Is there a way to change a cell from a formula (that is returning data) to the data it is returning. I realy hop it it becuse it would help out a ton. -- Thanks TimM If you select the cell and copy then edit - pastes special - values on the cell you will have the value and not the formula. HTH -- Sincerely, Michael Colvin "TimM" wrote: > Is there a way to change a cell from a formula (that is returning data) to > the data it is returning. I realy hop it it becuse it would help out a ton. > > > -- > Thanks > TimM Hi, Select the cell(s) contain...

CDialog AND Bitmap
Hi, I use Visual C++ 6.0 Enterprise Ed. How do i put a bitmap on a dialog ? How many colors may this bitmap have ? One way: You can add a picture control to the dialog and set a bitmap into it. If VC6 doesn't have a picture control in the toolbox, a static control with the SS_BITMAP style will do it. Any Windows bitmap format will work. Mark -- Mark Salsbery Microsoft MVP - Visual C++ "RAN" <nijenhuis@wish.nl> wrote in message news:1187378199.661511.59240@19g2000hsx.googlegroups.com... > Hi, > > I use Visual C++ 6.0 Enterprise Ed. > How do i put a bi...

Unable to change category group
Hi I'm using Money 2004. I am unable to change the category group for a category called INTEREST which is in under Income. I am getting a message stating "This category is mapped to the capital gains investment category. It's tax line cannot be changed". I dont understand why I cannot change it to "Periodic Income". Please can you advise. Thank you. You can't. See http://money.mvps.org/faq/article/69.aspx -- Regards Bob Peel, Microsoft MVP - Money For UK tips & fixes see http://support.microsoft.com/default.aspx?scid=fh;EN-GB;mny. I do no...

Change date format in several worksheets
I have about 50 worksheets in a workbook and would like to change the date format in all. Is there a way to change all at once or must it be done worksheet by worksheet? Select first worksheet. Right-click on the tab and "select all sheets" to group them. Select data range in activesheet. CRTL + A(twice in XL 2003) will select all cells. Make your Format changes. What is done to one sheet will be done to all. DO NOT FORGET! to right-click on any tab and "ungroup" before making any other changes unless you want to change all sheets. Gord Dibben Excel MVP On Sat...

Can't change default file location
After several repeated attempts I have been unable to change the default file location on the General tab of the Options dialog. I am also unable to get the AutoRecover location to change. I enter a new valid path in each and when I close the Options dialog and re-open, the old path is back. I am using Office 2002 on Windows XP professional. Works fine for me, when you "close the Options dialog box" are you clicking "OK"? If you're closing without doing that then the entries will be ignored. -- Regards; Rob Please reply to the NG, I'm already up to my ...

Usernames not showing up when tracking changes in Excel
One of my users is sharing out an Excel document in their shared documents folder. When he tracks changes, for some users it shows the user's full name, ie John Smith, but for others it shows nothing. This is on an XP Pro operating system on a Novell 6 network. Any help on this would be appreciated. Thanks. >-----Original Message----- >One of my users is sharing out an Excel document in their >shared documents folder. When he tracks changes, for >some users it shows the user's full name, ie John Smith, >but for others it shows nothing. This is on an XP P...

User changes last name
I have a network user with an associated mailbox. The user's name is jsmith and the Exchange alias is jsmith. This user has a new last name now, jjones.The user wants her email address to reflect the new name. She also wants to have any mail that goes to her old address forwarded to the new address. Can I just rename some things or do I have to create another userid and create the new mailbox and import all the email into the new mailbox and forward the old email to the new one. That senario would also cause the user to get a default profile on the desktop which I want to try to av...

change default collate setting
Is there a way to make the default collate setting in Microsoft Excel set to not collate? Currently, our users have to uncheck that box every time they print. TIA XL2K3 ...