|
-
Apr 30th, 2001, 11:05 AM
#1
Thread Starter
Frenzied Member
Windows app
I have a question..and it's kind of stupid but, i am just starting out. How do you make a windows app? I have the windows.h header file and i dont know a lot about C++. I am using a program called Dev-C++. If you want it, it's 7.56 MB at www.bloodshed.net. So, how do you print words and input things in a windows app? could someone please help me? does anyone know a good C++ code web site that i could go to that teaches me C++ for Win32 apps? thanks.
-
Apr 30th, 2001, 11:28 AM
#2
PowerPoster
that is not good
I have used dev-C++ for about a month. it is very good compiler because it is free. When you go the
File>New
Select "Windows Application" or something like that. It will automatically put the code for you. New you just run the program and you will see an empty gray window. If you want to learn more windows programming then this site would be really helpful:
www.winprog.org
If you don't know how to program in dos then I suggest that don't move on to windows programming. You must understand to concepts of:
pointers
refrences
classes
windows API
and some basics of C++ such as looping switching, etc., I have been programming in windows for just one week but I have spent about a month in DOS programming. If you have any other question then just reply to this thread again. And also stick to this forum. It would be really helpful.
Good Luck!!
-
Apr 30th, 2001, 01:22 PM
#3
Frenzied Member
As abdul said you must understand to concepts of:
pointers
refrences
classes
windows API
first and then try
http://www.winprog.org
Code for basic windows app
Code:
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
#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;
}
-
Apr 30th, 2001, 03:54 PM
#4
Also, just some advice. While it's quite lengthly to type up a windows program, and it makes since to simply copy and paste the window creation code, it's a good idea, when learning C++, NOT to do this. You shuld type be familiar and type up the code so you know and understand it. Once you can do this, then it's okay to copy and paste.
-
Apr 30th, 2001, 04:44 PM
#5
Monday Morning Lunatic
Hey Vlatko, can you fix your code? I don't want to have to correct your message loop each time
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 30th, 2001, 04:51 PM
#6
Frenzied Member
Hey,parksie i knew you were going to say that. Well ok. SomethinCool, replace the
Code:
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
with
Code:
int i;
while(i = GetMessage(&msg, NULL, 0, 0)) {
if(i == -1) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
-
Apr 30th, 2001, 04:54 PM
#7
Monday Morning Lunatic
Originally posted by Vlatko
Hey,parksie i knew you were going to say that. Well ok.
I love being predictable...Nothing personal you understand 
I used to do it that way until I read through the PSDK and it said specifically not to do that So I'm just following their advice.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 30th, 2001, 05:11 PM
#8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|