How to change startup form in vc++ MFC

hi friends,
                can anyone tell me how i can change form which starts
first in vc++ mfc,
actuallly i am inserting a form but whenever i run a program it will
start default form and i need
to run my form which i have inserted....

0
10/10/2006 12:00:51 PM
vc.mfc 33608 articles. 0 followers. Follow

15 Replies
973 Views

Similar Articles

[PageSpeed] 12

hardik wrote:
> hi friends,
>                 can anyone tell me how i can change form which starts
> first in vc++ mfc,
> actuallly i am inserting a form but whenever i run a program it will
> start default form and i need
> to run my form which i have inserted....

Is this a dialog based application?  If so, the initial form is 
determined by the code in InitInstance.  You can change that code in 
InitInstance to use your CDialog derived class instead of whatever class 
it is using.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
10/10/2006 12:52:36 PM

> Is this a dialog based application?  If so, the initial form is
> determined by the code in InitInstance.  You can change that code in
> InitInstance to use your CDialog derived class instead of whatever class
> it is using.
>
> --
> Scott McPhillips [VC++ MVP]

yes it is a dialog based  application can you tell me specifically what
should i do as i am beginner in vc++.
i am using mfc application. and i have inserted another form and now i
wants to start that form in startup. in vb i know i can change settings
in project window but in vc++ i was unable to find any thing to change
my startup form.

0
10/10/2006 1:05:36 PM
>                 can anyone tell me how i can change form which starts
> first in vc++ mfc,
> actuallly i am inserting a form but whenever i run a program it will
> start default form and i need
> to run my form which i have inserted....

Are you talking about splash screen or simply a different dialog in a
dialog based application? In MFC, rough equivalent of Form is a dialog.

---
Ajay

0
ajaykalra (6842)
10/10/2006 1:25:14 PM
i am simply talking about another dialog like i have add another dialog
named "abc" then instead of default dialog, "abc" dialog should start
first when i run my program.

no splash screen or something like that.......

0
10/10/2006 2:19:05 PM
> i am simply talking about another dialog like i have add another dialog
> named "abc" then instead of default dialog, "abc" dialog should start
> first when i run my program.
>
> no splash screen or something like that.......

Simply change the IDD of the dialog in your app's InitInstance.

---
Ajay

0
ajaykalra (6842)
10/10/2006 2:46:44 PM
"hardik" <hardikdangar@gmail.com> wrote in message 
news:1160485535.734097.80260@i42g2000cwa.googlegroups.com...
>
> yes it is a dialog based  application can you tell me specifically what
> should i do as i am beginner in vc++.

In your app's InitInstance(), change the dialog that gets shown, e.g.:

BOOL CKillSpamApp::InitInstance()
{
 // Standard initialization
 // If you are not using these features and wish to reduce the size
 //  of your final executable, you should remove from the following
 //  the specific initialization routines you do not need.

#ifdef _AFXDLL
 Enable3dControls();   // Call this when using MFC in a shared DLL
#else
 Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

 CKillSpamDlg dlg;                        // <-- change this to your new 
dialog
 m_pMainWnd = &dlg;
 int nResponse = dlg.DoModal();


-- David 


0
dc2983 (3206)
10/10/2006 2:47:53 PM
Problem still not solved plz help me

what i am doing is step by step....

1) i choose new project and then projects tab in vc++ ide and then i
choose MFC APPWizard(exe) then i am choosing dialog based application
then projects created.

2) now i am adding new form throgh insert menu->new form. i am giving
it name as "form2".

3) now whenever i press ctrl+F5 then project will be compiled and by
default default dialog will open all i need is to open my new form
named "form2" instead of default dialog.

HOW Can i Do this?

i am very new to mfc and i am unable to solve this problem from few
days so plz help me.....

0
10/10/2006 5:26:36 PM
hardik wrote:
> Problem still not solved plz help me
>
> what i am doing is step by step....
>
> 1) i choose new project and then projects tab in vc++ ide and then i
> choose MFC APPWizard(exe) then i am choosing dialog based application
> then projects created.
>
> 2) now i am adding new form throgh insert menu->new form. i am giving
> it name as "form2".
>
> 3) now whenever i press ctrl+F5 then project will be compiled and by
> default default dialog will open all i need is to open my new form
> named "form2" instead of default dialog.
>
> HOW Can i Do this?
>
> i am very new to mfc and i am unable to solve this problem from few
> days so plz help me.....

Go to InitInstance of your application. In it, search for DoModal. The
dialog that is being called upon needs to change to your new class,
form2. Post the relevant code from InitInstance  here if you cant get
it.

---
Ajay

0
ajaykalra (6842)
10/10/2006 5:32:35 PM
Here is a initinstance code of my application

now i add another form through insert menu -> form and i give name as
"form2"
so it adds a dialog IDD_FORM2_DIALOG now i need to start
IDD_FORM2_DIALOG
dialog instead of IDD_MULTIFORMS_DIALOG.



BOOL CMultiformsApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	CMultiformsDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

0
10/10/2006 5:58:45 PM
You need to change the following line of code:

   CMultiformsDlg dlg;  // this should change to CForm2 (Your dialog
class)

 It  should become:

   CYourFormClassDlg dlg;

If you dont a dialog class corresponding to Form2, you will need to
create one. You can either use the wizard or do it by hand.


---
Ajay

0
ajaykalra (6842)
10/10/2006 6:11:28 PM

i've write,

Cform2Dlg dlg;
but compiler says it doesnot found any classes

Cform2Dlg dlg is undeclared identifier

how i can correspond my dialog class with form2? plz tell me in detail

 thank you to help me so much and sorrry(for disturbing you too much) i
am very new so i don't understnad those thinks that much but really
thankful to you.


Ajay Kalra wrote:
> You need to change the following line of code:
>
>    CMultiformsDlg dlg;  // this should change to CForm2 (Your dialog
> class)
>
>  It  should become:
>
>    CYourFormClassDlg dlg;
>
 If you dont a dialog class corresponding to Form2, you will need to
 create one. You can either use the wizard or do it by hand.

0
10/10/2006 6:27:55 PM
hardik wrote:
> i've write,
>
> Cform2Dlg dlg;
> but compiler says it doesnot found any classes
>
> Cform2Dlg dlg is undeclared identifier
>
> how i can correspond my dialog class with form2? plz tell me in detail

You need to include the header file(form2dlg.h ?) in your cpp file
where you are using this dialog.

---
Ajay

0
ajaykalra (6842)
10/10/2006 6:30:54 PM
i have found form2.h but i was unable to find form2Dlg.h. i've include
form2.h and try but it didn't work.

perhaps my bad luck is bad.

so thank you too help me.tell me if you have any other method than or
diffrent steps for creating two dialogs and run it.

0
10/10/2006 6:42:42 PM
hardik wrote:
> i have found form2.h but i was unable to find form2Dlg.h. i've include
> form2.h and try but it didn't work.

You need a header file which defines the dialog class that is being
used. You may have given it some other name. If you have not defined
this class, you will need to first define the class. The file name can
be anything but typically its named based on the class with .h
extension.

----
Ajay

0
ajaykalra (6842)
10/10/2006 8:29:25 PM
Hardik,

When you create a class for a dialog resource it always creates a .cpp and 
..h file.  Ajay is referring to the .h file that was created for the dialog. 
It will have the ID for the template.

Tom

"hardik" <hardikdangar@gmail.com> wrote in message 
news:1160505762.221922.218560@h48g2000cwc.googlegroups.com...
>i have found form2.h but i was unable to find form2Dlg.h. i've include
> form2.h and try but it didn't work.
>
> perhaps my bad luck is bad.
>
> so thank you too help me.tell me if you have any other method than or
> diffrent steps for creating two dialogs and run it.
> 


0
tserface (3861)
10/10/2006 8:39:44 PM
Reply:

Similar Artilces:

Validating Data on a Form with a subForm
I have a form with subforms with data validation in the main Form's Before_Update Event. The problem that I am encountering is when the user has not updated all required data but enters the subform the Form Before_Update Event fires and the validation will fail. Is there a way to know what the next object has been selected might be or how I would not perform the Form's validation when the subform has been selected? Any help will be appreciated!!! No. Access saves the main form's record at the point when you move from the main form into the subform. Any record that fails v...

Today's Total Change (but not a Q re mutual fund updates)
In M06, Portfolio Manager, the total shown at the bottom of view as Today's Total Change does not, in fact, reset to $0 at the start of each day. It keeps yesterday's value and, apparently, uses that value as the starting point for the next trading day's gain or loss. Right now, for instance, on Sunday, I'm looking at Friday's gain as Today's Total Change (TTC). If I am correct about this, is there a way to reset TTC to zero at the start of each trading day? Thank you. Dave M. re: "keeps yesterday's value and, apparently, uses that value as the starti...

error when moving through recs on form
I'm getting an error message that appears when scrolling through records on a form I built, but only certain records. This just started happening. I can't figure out what triggers the error, i.e. what field/value causes it (looked for patterns like null values in a field, etc.), and the error itself doesn't make sense to me. The error "The value you entered isn't valid for this field" fires when moving onto certain records. But I'm not entering any data (I understand, for example, that if I entered text into a number field that's the error I would get). T...

How to update one form when closing another ?
I have two forms open. frmPeople has the Focus frmAccount does not. frmAccount has subFormPeopleList I add a new person to frmPeople (which is linked to frmAccount) Question 1: When I close frmPeople I want to update frmAccount so the new person shows in subFormPeopleList Quetion 2: But I'm also wondering if I add code to the "close event" for frmPeople to update frmAccount What will this do if frmAccount is not open? Will it add the person twice? I'm guessing not as updating a form doesn't really add data to the table... right? Thanks for any help. Mel Thanks...

enter data to different tables through one form
i have 5 tables. all of them has pers_no as primary key. they have one to one relation ship through the primary key amongest them. i want to create one form having a text box pers_no where i will enter the data and i want the data to get entered in each table. so how i am not able to do that. i request all you guys to help me. thank you. Sorry for the bad news, but that's not the right way to use Access. You cannot write to 5 tables from one form like that. If you are subclassing, you could create a form for entering the main form info, and then 5 subforms (probably on tab pages) f...

Change background color of inbound email
In Outlook 2007, I have from left to right, Mail - shows all inbound, sent, and mail folders, the next is my inbox, and the third is the actual email being show that is highlighted in my inbox. My problem is that some email when it is displayed can not be seen due to colors. 90 percent of my email is fine, but some email I can not read because of the font color, or the background color. I want to know how do I change the background color, or font color of a displayed email? A quick trick is to click somewhere in that message and then press CTRL+A. The message will then be shown...

Writing a huge file with MFC
Does someone have an MFC (of API) code extract that can write a single huge file to disc? (~700Gb). This is just to see if it can be done :-) I've made a few attempts using WriteFile() and __int64 int's but the problems arise becuase WriteFile() args are all (afaic see) 32 bit ints. So it's iompossible to say "write 750000000000 bytes" in the bytecount arg. Even to do it in chuncks of 2Gb might not be possible as the offset in file pointer args is also 32 bits. Just wondered if anyone out there has managed to do this? Thanks I'm not aware of any restrict...

Lease agreement forms
Is there any template forms I can get for leasing an apartment? I am looking for a roommate, and I need a form for potential roommates to sign and have some sort of lease agreement. I am renting out an extra room in my house. Thanks! Try this here: http://office.microsoft.com/en-us/templates/results.aspx?qu=rental&av=TPL000 And more specifically this one: http://office.microsoft.com/search/redir.aspx?assetid=TC010014651033&QueryID=GtNChmW1K0&respos=5&rt=2&pid=CT101481321033 -- Bob Larson Access World Forums Super Moderator Utter Access VIP Tutorials at http://www.bta...

Startup Maximized
I have the Switchboard showing at startup, I would like it to come up maximized. Any Help would be great. Thanks in advance. What "switchboard" are you referring to? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Mike Busch" <MikeBusch@discussions.microsoft.com> wrote in message news:148AB296-F622-41BB-9F61-CFEE489127A8@microsoft.com... >I have the Switchboard showing at startup, I would like it to >come up > maximized. Any Help would be great. Thanks in advance. ...

How to convert eml file to msg file using vc++
Dear Experts , I am developing an application that need to converts eml file to msg file using VC++ 6.0 Right now i am using redemption.dll for this conversion and it works fine . My problem is when Microsoft OutLook is configured with Exchange then while converting application ask for username / password . But it never ask for login if the account is POP3 . ////////////////////////////////////// CODE : ///////////////////////////////////////////////////////////////////////////////// ::CoInitialize(NULL); Redemption::ISafeMailItemPtr pMailItem("Redemption.SafeMailItem"); ...

Auditing changes to distribution groups
Whenever I add or remove someone from a security group I can find a corresponding eventid between somewhere between # 620-640 with the change. I don't always see this for distribution groups. Sometimes there's no audit logging of these changes. Does anyone know under what event ID and where DL list changes are audit logged? ...

after apply filter show blank form.How to detect 0 records??
hi I Have a form , and the user goes to filter by form and then apply filter. When no rows are returned a blank form is displayed how do I detect this and display a message 'no rows found'? mike Mike, I would like to say add a piece of line to your code... DCount("SomeField","SomeTable") < 0 Then MsgBox Esle run your filter but you didn't post any code. Perhaps that little tidbit I posted is enough to get you started? -- Gina Whipp 2010 Microsoft MVP (Access) "I feel I have been denied critical, need to know, information!&quo...

What converter do I need to change my QPW files to work in Excel 2
I had Quattro Pro (about 2003 -2004) on my computer when my hard drive crashed now I have Excel 2003. What converter do I need to change my QPW files to work in Excel 2003? puzzled Maybe the following will help....depending upon version of QP, I believe. You need the Quattro Pro convertors from MS. http://office.microsoft.com/en-ca/results.aspx?Scope=DC&Query=quattro+pro Then read this from Jim Rech http://snipurl.com/cz3x Gord Dibben Excel MVP On Mon, 12 Dec 2005 06:46:04 -0800, "puzzled" <puzzled @discussions.microsoft.com> wrote: >I had Quattro Pro (about...

Create Table Record on Current of Form
I have a table called LastVisitedRecord. There is but one field in that table called "lvCompanyID". I'd like to use the OnCurrent event of my record form to insert the record id (CompanyID) into a new record in the LastVisitedRecord table. After that, I'd like to use a query I've created qLastVisitedRecord which only shows the top 1 record of the LastVisitedRecord table to query my contact form by default, showing all records, but skipping to the record whose CompanyID field matches the sole record in the query qLastVisitedRecord. Anybody got an idea on how to do this? ...

How do I fill data into mfc combo-box control in VS2008
In VS6.0, I could simply type in strings each seperated by Alt+Enter. In VS2008, I cannot input strings in property frame. How do I do that? -- Daewon YOON Type each of the strings separated by a semi-colon in the Property "Data". - Shoaib "TheOne" <daewon.yoon@gmail.com> wrote in message news:559afad2-d866-4798-bb0f-f5d59e3887c1@w8g2000prd.googlegroups.com... > In VS6.0, I could simply type in strings each seperated by Alt+Enter. > > In VS2008, I cannot input strings in property frame. How do I do that? > > -- > Daewon YOON > "The...

If conditions for Data Entry Form
I have a excel database that I track multiple entries based on customer ID #s. Depending on the ID # depends on what sheet the data goes on. Each sheet is set up the same way, in a couple of the columns I have the vlookup formula that looks up the ID # that is typed in and if it is listed on the appointment sheet, that sheet tracks all the appointments, the vlookup (in column A of all the sheets) will display the appointment date (if one exist) otherwise it would be blank. What I need to know is two things: First is it possible to have the form put the new data on the proper s...

Exchange 2003 SP1 and OWA changes
I am yet to confirm the following in the lab but it appears to be correct. I have been using a single exchange 2003 server without sp1 in a mixed mode with exchange 5.5 in the lab and found that for users to access OWA one of the following conditions must be met along with the users mailbox residing on the 2003 server 1. One of their email domains must be present in the default recipient policy. 2. If none of their email address domains are present in the default policy then a new virtual directory for mailboxes must be present and assocciated with the smtp domain from a recipient po...

How to freeze a form?
Greeting, I have a form that contains many txtbox and combo boxes. In this form there is a commend button to open another form. The problem is, the user can click on the back form (main form) and it come forward and the other form goes back. What I want to do is, once the user open the sub form, the user can not click on the backward form (main form) unless he closes the foreword form. How can I do that? thanks "ghost" <ghost@discussions.microsoft.com> wrote in message news:F1F79916-B8F4-41BE-BD3B-B57F90B513CB@microsoft.com... > Greeting, > I have a form that cont...

Tabs in forms 09-25-07
I have an input form, pretty standard - main form, subform. First time through tab order is correct. Second and consequent time through it skips the first tab stop in the subform. I have never had this happen on a form. Don't know where to look for the answer. I have checked the tab order and it looks fine. I have checked the properties and the tab order numbers are correct. Can anyone shed light on this? Thanks, -- Taylor ...

Images on Forms
Does anyone know if an image can be added to a form? For example, we'd like to put an image of our 3-party supplier items on their records in the product catalog. I'm currently going down the path of the IFRAME and linking to the supplier website, but I'd like something cleaner. I'm on 3.0 currently but will be upgrading to 4.0 soon, so if it can be in 4.0 I can wait. Thanks. -- BC My suggestion would be to add you image as a note from the related record and retrieve it at-runtime using client side script (web service call) or any custom aspx page from a menu entry...

sending this information on a form to somewhere secure such as an email account
Hi. I just wanted to make a log book where staff record times that the log in and out of work. I was wondering if anyone knows how to sen off the current time, member of staff (with their own password)t somewhere secure where staff cant get at it...like the managers emai account (if you have any other suggestions, for alternatives to a email account LMK). thanx for your time -- Message posted from http://www.ExcelForum.com ...

Customer Level Prices Changing After Additional Items Added to A Sale
Hello Ladies & Gents, Here's something wierd I have come across. If you define price levels for an item and then on the POS select a customer with a corresponding level and ring up that item, the item will show up with the level price and the bold font. However, if you ring up additional items that don't have price levels defined, the the price of the first item goes back to regular and the font changes back to normal! However, if you ring up all your items first and then select the customer, then items with price levels will be adjusted accordingly. Obviously, this is not...

Modifying Forms
Is there a way to relabel the label colors on the Appointment form? Do you mean to modify them or what? Modifying the label names is very easy. Right click on an appointment->Label->Edit Label. I presume you are using Outlook 2002 or 2003, correct? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Cindy MIkeworth asked: | Is there a way to relabel the label col...

3.0 Lastname change ???
I made a new user and then changed the way it show lastname name to name lastname. How can I get the first user to be in this format ? Jack Can I just change the full name for the user en the table for systemusers ??? There hasn't been created other things than this user in the system ? "Jack" <jackdSPAM@jackd.dk> skrev i en meddelelse news:OUjgKfOeGHA.3388@TK2MSFTNGP05.phx.gbl... >I made a new user and then changed the way it show lastname name to name >lastname. > > How can I get the first user to be in this format ? > > Jack > You can...

internet options change and ie 8
i have ie 8 and have noticed that my internet options icon changes and im wondering what that means. the icon is a globe type image and then for some reason not of my doing (as far as i know) it changes and has a white square in front of the globe and the square has a check mark on it. its probably not a big deal but im just curious what it is doing and what it means. thank you in advance. kf. "kf" <kf@discussions.microsoft.com> wrote in message news:4F1B7252-67A7-4BEF-8BB6-983C8B8C2026@microsoft.com... > i have ie 8 and have noticed that my internet o...