MFC,Well,want,ACTUALLY,create,your,form,Resou
Quick Search for:  in language:    
MFC,Well,want,ACTUALLY,create,your,form,Resou
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 451,578 lines
 Jobs: 558 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for C/ C++.
Url Test
By Richard Creary on 8/27


Nice Console Calc
By Andrew Carter on 8/26


Visual Pi Hex 2
By jo122321323 on 8/26


Cascade Clone v1.0
By Paulo Jorente - aka JungleBoy on 8/26


Bubble Sort Algo
By d1rtyw0rm on 8/26


Copy File I/O
By Olivier Bastien on 8/25


Visual Pi Hex
By jo122321323 on 8/25


Click here to see a screenshot of this code!ShortCutSample
By Massimiliano Tomassetti on 8/25

(Screen Shot)

AnPMoneyManager beta
By Anthony Tristan on 8/24


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

How To MAKE a window, NO MFC

Print
Email
 
VB icon
Submitted on: 8/11/2000 1:22:34 AM
By: Mehdi Hanbali 
Level: Beginner
User Rating: By 15 Users
Compatibility:Microsoft Visual C++

Users have accessed this code 8742 times.
 
(About the author)
 
     Well, want to ACTUALLY create your own form? no MFC or Resources. This is code to actually make a raw form. easy to use. Please gimme feed back.
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

//**************************************
//     
//INCLUDE files for :How To MAKE a windo
//     w, NO MFC
//**************************************
//     
you need to include windows.h, it comes with visual c++
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: How To MAKE a window, NO MFC
// Description:Well, want to ACTUALLY cr
//     eate your own form? no MFC or Resources.
//     This is code to actually make a raw form
//     . easy to use. Please gimme feed back.
// By: Mehdi Hanbali
//
// Inputs:copy and paste the code
//
// Returns:a window
//
// Assumes:since no one really gives goo
//     d explinations. heres one:
1. open visual c++
2. File > new
3. Click Projects tab
4. click Win32 Application and give it a name
5. click finish
6. click the File View Tab on TreeView
7. go to File > new
8. in the first tab Click C++ Source File and name it
9. Copy and paste the code in the new file
10. right click the Header folder and add Windows.h
11. click execute
12. give me feedback and vote -=]
//
// Side Effects:none at all
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/xq/ASP/txtCod
//     eId.686/lngWId.3/qx/vb/scripts/ShowCode.
//     htm//for details.//**************************************
//     

#include <windows.h>
LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
char szWinNamw[] = "MyWin";
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
				LPSTR kposzArgs, int nWinMode)
    {
    	HWND hwnd;
    	MSG msg;
    	WNDCLASSEX wcl;
    	wcl.cbSize = sizeof(WNDCLASSEX);
    	wcl.hInstance = hThisInst;
    	wcl.lpszClassName = "My Window";
    	wcl.lpfnWndProc = WindowFunc;
    	wcl.style = 0;
    	wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    	wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wcl.lpszMenuName = NULL;
    	wcl.cbClsExtra = 0;
    	wcl.cbWndExtra = 0;
    	wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
    	if(!RegisterClassEx(&wcl;)) return 0;
    	hwnd = CreateWindow(
    		"My Window",
    		"Skeleton Window",
    		WS_OVERLAPPEDWINDOW,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		HWND_DESKTOP,
    		NULL,
    		hThisInst,
    		NULL
    		);
    	ShowWindow(hwnd, nWinMode);
    	UpdateWindow(hwnd);
    	while(GetMessage(&msg;, NULL, 0, 0))
        	{
        		TranslateMessage(&msg;);
        		DispatchMessage(&msg;);
        	}
        	return msg.wParam;
    }

LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
8/11/2000 1:28:04 AM:Mehdi Hanbali
i like my example. i think people take 
mfc for advantage and use it too much. 
please vote for me. i need to win 
something ;]
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/6/2000 12:05:48 PM:Gushing Wound
I like it!  I voted!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/8/2000 4:33:07 PM:PsyVision
What the hell lets vote, good code !
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/10/2000 12:08:32 AM:student
Pls donnot take it as offence. I am 
really new to win 32 
programming.
sorry if my comment 
hurts. I dont mean to hurt u. I just 
want to learn. 
certainly the code 
is good. But Is this code the similer 
that we find in win95 programming by 
charls petzold.
I will love to learn 
how it differs from that? 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/13/2000 11:38:49 PM:Mehdi Hanbali
well the way this code differs is by 
the way i've made it shorter. (by the 
way, thanks for the comment, in no way 
am i offended) i took the effort to 
look at the petzold book and found 
similarities. if you would like me to 
point out the differences and how it 
would be used i'd be glad to. just give 
me an email. thanks for the feed back. 
im learning to -=]
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/17/2000 4:10:01 PM:Max Raskin
I think MFC is lowsy, I like better the 
clean Win32 Apps :-)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/18/2000 7:59:46 PM:Mehdi Hanbali
I totally agree with you Max. MFC is 
messy. Besides code looks cooler. -=]
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/19/2000 6:39:59 PM:livinINvb
I'm very new to C++, in Visual C++ 6 
Standard, that code gives me 2 errors. 
What can i do to fix them?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/20/2000 9:33:05 AM:Karlos
Thanks for the code. I had no problems 
with it. Great job!!:) I voted for you.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/21/2000 1:41:34 PM:John Simmons / outlaw programmer
You guys go right ahead and refuse to 
use MFC. While you're fighting the 
windows API, I'll be making money 
because I used the tools that were 
available that helped me get my app 
done sooner and with more features that 
users have come to expect from a 
windows app.
Code like this (that 
doesn't use MFC) has its place, but as 
a replacement for a complete framework, 
it's not viable nor conducive to rapid 
development.
There are times when I 
don't like MFC either, and there's a 
lot of stuff they could have done 
better, but avoiding it for the sake of 
avoiding it is pure folly (unless you 
have a framework with which to replace 
it).
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/27/2000 1:50:19 PM:Ultimatum
All hail Win32 =) MFC/WFC has it place, 
and developing dialog-based 
applications isn't it. =) (Besides, 
trying to script windows using MFC is 
next to impossible.) I guarantee that 
you'll come across many many many 
people who will hate your guts because 
they are hardcore AppWizard users that 
bow to MFC =) I say, forget that. 
Clean, smooth code, no need for 
MFC40.DLL.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/27/2000 6:51:13 PM:Mehdi Hanbali
Argue all you want for MFC. I don't 
care because I don't and will not use 
it. Understanding your code is more 
important and what if you dont have 
access to a compiler with MFC support. 
Also code looks nicer when written 
yourself, i'm sure most will agree.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/6/2000 3:58:58 PM:John Simmons
Well duh Mehdi, if you're using a 
compiler without MFC support, I guess 
you're not gonna be able to use it 
(much less *want* to use it).  besides 
that, you missed my point.
1) Pretty 
code doesn't get the app done any 
sooner.  I personally take great pains 
to format my code so that it's easy to 
read, and it's sometimes heavily 
commented, but that doesn't make the 
app any better or worse (but it does 
make it more easily 
maintainable).
2) I understand the 
code just fine.  After years of using 
MFC, I've grown accustomed to it and 
know how to use it, and even more 
importantly, how and when NOT to use 
it.
-more-
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/6/2000 3:59:29 PM:John Simmons
- continued -
3) You can't rely 
completely on MFC any more than you you 
can completely rely on the Delphi or VB 
visual tools to do the entire job.  
Nothing replaces good old fashioned 
get-yer-hands-dirty code jockeying, but 
if there's a way to eliminate some of 
the tedium of the job, I'll try it out 
at least once.  I value the appwizard 
in VC++ because I can have a 
well-stocked app running in as little 
as 60 seconds.  beyond that, every 
requirement has a different set of 
criteria to be addressed by the 
programmer.
4) Don't get me wrong - 
I don't much like the way MFC is 
written, but nobody has given me 
another tool to work with.  Maybe what 
we need is a team of really sharp 
programs to come up with an alternative 
framework that isn't choked with macros 
and unrealistic inheritance 
restrictions.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/24/2000 5:06:59 PM:A tip for you beginners.
If you search in newsgroups 
in
comp.os.ms-windows.programmer.win32
and sort the longest messages first 
you can get many good samples and learn 
a lot from it. The good thing with 
WinApi programming is that a simple 
copy and paste can make a program 
compile. With MFC or other macro based 
enviroment you can't.
Regards
Andla
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/3/2000 10:31:36 AM:elaias
that was response, not responce
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/3/2000 10:34:53 AM:elaias
In responce to Simmons: I agree with 
you in part. In that mission critical 
apps are easier to code in MFC than 
straight C/API apps. But I disagree in 
that VC++/MFC apps are a proper 
substitution. Have you tried Borland's 
C++ Builder Ent. Ed.? If it's RAD you 
want, this is the environment for you. 
No dialog-based apps, just full-on 
click and drag of components onto your 
Main MDI or SDI forms and _voila_, all 
your GUI worries are over. Not to 
mention that the VCL framework is much 
more finely tuned than the MFC. I mean, 
after all the classes are stripped 
away, what are you left with? The 
WinAPI! The point of this disagreement 
isn't even logical. You guys are 
comparing apples and applefritters. And 
Simmons is also right that in the real 
world, VC++ programmers make more money 
than those who only employ the API. And 
what's stopping a MFC programmer from 
directly accessing the API anyway? I d
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/11/2000 1:25:37 PM:John Simmons
I wasn't saying that the Win API was a 
bad thing, I'm just saying that 
avoiding MFC for the sake of avoiding 
MFC is a generally bad idea.
I 
frequently use the Win API, but for 
sheer speed of development (compared to 
the WIN API), MFC wins hands down.
I 
have no experience with BCB, but I am 
no fan of click-n-drag program 
construction (VB, Delphi, et al).
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/17/2000 10:22:05 AM:elaias
Simmons: I never said click-n-drag 
"program" construction. I simply 
mentioned that your "GUI" worries are 
soon over. Every developer knows that 
an application includes more than an 
interface. I was a diehard VC fan for a 
long time until I had the chance to 
employ the BCB, and I can tell you that 
application creation is much more a 
precise art than the 
compile/view/debug/compile/view process 
that you are left guessing with in the 
VC. With BCB, it's all-out WYSIWYG, and 
this is merely broaching the topic of 
GUI, not to mention it's sheer power to 
create CORBA, COM, XML, or whatever 
business solution you're seeking to 
implement, applications. It's got it 
all!!!
PS - Apps developed with BCB 
tend to be substantially smaller and 
faster than the same apps developed 
with VC.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/29/2000 3:19:07 PM:Adam
That is some really usful code, Thanks..
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/9/2001 12:14:33 AM:Phantam
Those of you who want MFC mise as well 
go look under VISUAL BASIC CAUSE if u 
want rapid development then use a RAD 
development software.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/2/2001 8:44:09 AM:Ian Williams
The code to create a window without Mfc 
etc appears in many books and web 
sites. The code is almost a line by 
line copy of the ones that appear in 
the books and other web sites. As to 
the copyright statment - I think your 
having a laugh!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/10/2001 11:08:44 PM:Mehdi Hanbali
Well Ian, if you weren't so ignorant, I 
never once mentioned I just made this 
code up out of thin air. If you read, 
I'm stating that this a windows 
skeleton application. Tell me, how many 
truely unique ways are there? As for 
the copyright, if you had any mind to 
realize, psc automatically does that 
when you submit code.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/21/2002 2:43:27 PM:eponk
this is a great code for beginner like 
me. It's including what steps todo 
first.
Anyway what's wrong with MFC 
?
   -- Cheers --
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/25/2002 12:43:40 PM:Dennis Koliris
No offence here either, but I wonder 
why the most basic window creation 
which can be found on ALL win32 
tutorials on the internet won the 
competition.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/20/2002 10:41:37 AM:yan
it's right to say, I'm really love to 
wrote in vc++. But, I'm really scare to 
write with API. So, that's mean I have 
no chance in it ? I'm a newbie, please 
you are write more program like this to 
me. Or somebody want to help me, send 
to aan43@yahoo.com.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/1/2002 6:18:36 AM:steve
The Side effects: comment should say 
'creates a window' not 'none at all' :-)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/23/2002 9:38:16 PM:Newbie
Uh...I got some unresolved external 
symbol _main errors...Anyone?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/25/2002 12:35:19 PM:Nathanael
gee, too bad it's not commented hey? 
might be useful to some...ahem NEWBIES. 
such as myself. I like that i found out 
that it doesn't take tonnes of code to 
make a window, but still...i'm not 
voting
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/1/2002 8:38:37 AM:Kurt Joseph Serge
MFC SUC*S...its obviously for lazy 
programmers who want things done fast, 
and not proper.  
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/1/2002 8:40:04 AM:Kurt Joseph Serge
MFC suc*s, its obviously for 
programmers who are lazy, and want 
things done quick, and not correctly.  
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.