|
hi all
first of all i must say that im a newbie in c++ (but im fluid in turbo pascal xD)
i just made a new c++ project (visual studio installed templates -> win32 project)with visual studio 2008, added a windows form (visual studio installed templates -> windows form). now i have the form in the solution explorer: headers/MainForm.h and source/MainForm.cpp
now my question is simply how to get this form to be displayed with program startup?
the main code is the unchanged template. i tried the following things:
1.setszWindowClass to "MainForm" just before its used by MyRegisterClass, hoping it would take my form 2. include the MainForm.h somewhere in the main cpp file, but then i get a bunch of errors 3. wrote a "MainForm myForm = new MainForm()" line in the main cpp file, but "MainForm" isn't recognized 4. tried a "using namespace MainForm", but this isn't recognized either 5. searched the msdn and the internet for code examples or tutorials for this, found nothing applyable 6. gone insane after more than4 hours of trying 7. got myself a beer...
ok, the last 2 points werent very constructive ;) anyway, every time i build the project and run the program it displays a standard window/form instead of my custom one.
im out of ideas, how do i get this one working?
thx for answers
Klesk | | kleskomat Tuesday, January 06, 2009 12:51 AM | Hmya, you got what you asked for. Next time, use New Project + CLR + Windows Forms Application. Hans Passant.- Marked As Answer bykleskomat Tuesday, January 06, 2009 1:35 PM
-
| | nobugz Tuesday, January 06, 2009 12:48 PM | Point 1 is a red flag. You are trying to write old style Win32 unmanaged code. That's not going to work in a Windows Forms project. Start all over again, drop a button on the form and press F5. Then pay a visit to your local library to find a book about .NET programming. Hans Passant. | | nobugz Tuesday, January 06, 2009 3:30 AM | created new project, added form and a button to it, result: http://img71.imageshack.us/img71/1387/formthingzu4.jpg same as in my original project. is there no easy-to-go-wayusing the form specified inmyForm.h? i already wrote the code for all functionality behind the form (in this example would be located in myForm.cpp), tested with a plain console project. the only thing i need is to get this form displayed... :( btw: .net is handled next semester in study :) | | kleskomat Tuesday, January 06, 2009 4:10 AM | Hmm, you did more than that. Where did formtest.cpp come from? You are running code that is produced by the Win32 Project wizard. Hard to help you if you don't tell us exactly what you did. I'd recommend you wait until next semester. Hans Passant. | | nobugz Tuesday, January 06, 2009 4:25 AM | but im feeling that im just 1 step away from success^^
here is what i did: 1. file -> new.. -> project... 2. selected C++ --> Win32 --> Win32 Project, entered name formtest, clicked ok 3. in wizard clicked next --> let all settings default (Windows application, all but precompiled header deactivated) --> clicked finish (formtest.cpp is generated, contains main procedure, message processing loop and that stuff) 4. rightclicked on project name (formtest)in solution explorer --> add... --> new item... 5. chose C++ --> UI --> Windows Form --> entered name myForm, clicked add 6. apply to convert project to have common language runtime support (actually dont know what this is...)
myForm.h and myForm.cpp appear... i just added a button to the form and then pressed f5
without adding a form via this way, there is no form to add a button^^
gee, look @ the time, 7:00 ^^, im off for study | | kleskomat Tuesday, January 06, 2009 4:45 AM | Hmya, you got what you asked for. Next time, use New Project + CLR + Windows Forms Application. Hans Passant.- Marked As Answer bykleskomat Tuesday, January 06, 2009 1:35 PM
-
| | nobugz Tuesday, January 06, 2009 12:48 PM | lol i knew it, is was something totally simple ^^ thx, its working. i inserted the previous wrote code and its all done, mission accomplished :)
thanks for your patience
klesk | | kleskomat Tuesday, January 06, 2009 1:40 PM |
|