#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <conio.h>
#define WIN32_LEAN_AND_MEAN
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
BOOL PeekMessage(
LPMSG,
HWND hwnd,
UINT wMsgFilterMin,
UINT wMsgFilterMin,
UINT wRemoveMsg
);
BOOL TranslateMessage(CONST MSG *lpmsg);
LONG DispatchMessage(CONST MSG *lpmsg);
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
typedef struct _WNDCLASSEX {
UINT cbSize;
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
HICON hIconSm;
} WNDCLASSEX;
WNDCLASSEX sampleClass;
sampleClass.cbSize = sizeof(WNDCLASSEX);
sampleClass.style = CS_DBLCLKS | CS_OWNDC |
CS_HREDRAW | CS_VREDRAW;
sampleClass.lpfnWndProc = MsgHandler;
sampleClass.cbClsExtra = 0;
sampleClass.cbWndExtra = 0;
sampleClass.hInstance = hinstance;
sampleClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
sampleClass.hCursor = LoadCursor(NULL, IDC_ARROW);
sampleClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
sampleClass.lpszMenuName = NULL;
sampleClass.lpszClassName = "Sample Class"
sampleClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
RegisterClassEx(&sampleClass);
HWND CreateWindowEx(
DWORD dwExStyle,
LPCTSTR lpClassName,
LPCTSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);
HWND hwnd;
if (!(hwnd = CreateWindowEx(NULL,
"Sample Class",
"Sample Window",
WS_POPUP | WS_VISIBLE,
0,
0,
800,
600,
NULL,
NULL,
hinstance,
NULL)))
LRESULT CALLBACK MsgHandler(
HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam
);
LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
return(DefWindowProc(hwnd, msg, wparam, lparam));
}
return 0;
}
my errors are:
15 redeclaration of `wMsgFilterMin'
14 `wMsgFilterMin' previously declared here
17 conflicting types for `PeekMessageA'
3151 winuser.h previous declaration of `PeekMessageA'
17 [Warning] extern declaration of `PeekMessageA' doesn't match global one
18 conflicting types for `TranslateMessage'
3279 winuser.h previous declaration of `TranslateMessage'
18 [Warning] extern declaration of `TranslateMessage' doesn't match global one
19 conflicting types for `DispatchMessageA'
2864 winuser.h previous declaration of `DispatchMessageA'
19 [Warning] extern declaration of `DispatchMessageA' doesn't match global one
21 `msg' undeclared (first use in this function)
48 `MsgHandler' undeclared (first use in this function)
57 parse error before "sampleClass"
59 [Warning] passing arg 1 of `RegisterClassExA' from incompatible pointer type
74 conflicting types for `CreateWindowExA'
2835 winuser.h previous declaration of `CreateWindowExA'
74 [Warning] extern declaration of `CreateWindowExA' doesn't match global one
89 [Warning] passing arg 1 of `CreateWindowExA' makes integer from pointer without a cast
90 parse error before "__attribute__"
95 `MsgHandler' used prior to declaration
97 conflicting types for `MsgHandler'
95
previous declaration of `MsgHandler'
....................
my errors....
i dont understand the problem.. i have been through this tutorials tons of times seeing whats wrong...
[edited by - TheNerd Tk421 on August 11, 2003 10:36:47 PM]
I am learning windows programming via the tutorials here and ....
Here this is where there tutorials is.. i followed it all they way thruogh.. read everything.. thought i knew how to make a window(after reading this) when i was done and compiled it it wouldnt work...
................................
Can ne 1 please help ... i just went thru it again..I have no clue what i did wrong... i have looked over and over my code and the pages code.. i have found no comparison errors..
I fixed it....
Edited:::::
[edited by - TheNerd Tk421 on August 11, 2003 11:07:07 PM]
I fixed it....
Edited:::::
#include <windows.h>#define WIN32_LEAN_AND_MEAN #define WINDOWNAME "New" HWND hWnd; LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, msg, wParam, lParam);}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int Cmd) { MSG msg; WNDCLASS wClass; wClass.style = CS_HREDRAW|CS_VREDRAW; wClass.lpfnWndProc = WindowProcedure; wClass.cbClsExtra = 0; wClass.cbWndExtra = 0; wClass.hInstance = hInstance; wClass.hIcon = LoadIcon(hInstance,IDI_APPLICATION); wClass.hCursor = LoadCursor(NULL,IDC_ARROW); wClass.hbrBackground = (HBRUSH)(GRAY_BRUSH); wClass.lpszMenuName = NULL; wClass.lpszClassName = WINDOWNAME; RegisterClass(&wClass); hWnd = CreateWindow(WINDOWNAME, WINDOWNAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL); if(hWnd==NULL) return FALSE; else { ShowWindow (hWnd, Cmd); UpdateWindow(hWnd); } while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage (&msg); } return msg.wParam;}
[edited by - TheNerd Tk421 on August 11, 2003 11:07:07 PM]
<< Can ne 1 please help ... i just went thru it again..I have no clue what i did wrong... >>
I think you''re starting too large. If you have Dev C, you should make sure you understand the compiler. Compile some very short DOS window things....write a program to input and add 2 numbers, etc. Slow down, Quake wasn''t written in a day.
Check the documentation for what is required to compile a Win32 app. I don''t have Dev C but I have Visual Studio 6 and here is the bare minimum for a Win32 basic Game Loop, this opens in a Window 640 x 480
GameLoop1.cpp
If this doesn''t compile with zero errors in Dev C, then its probably how you are setting up Dev C to compile. In Visual Studio there are DOS apps which start with main(), and Win32 apps which start with WinMain() and normally have a WinProc() in C/C++.
Write something tiny -- a "hello world" with int main() -- and get it to compile with Dev C
Phil P
I think you''re starting too large. If you have Dev C, you should make sure you understand the compiler. Compile some very short DOS window things....write a program to input and add 2 numbers, etc. Slow down, Quake wasn''t written in a day.
Check the documentation for what is required to compile a Win32 app. I don''t have Dev C but I have Visual Studio 6 and here is the bare minimum for a Win32 basic Game Loop, this opens in a Window 640 x 480
GameLoop1.cpp
If this doesn''t compile with zero errors in Dev C, then its probably how you are setting up Dev C to compile. In Visual Studio there are DOS apps which start with main(), and Win32 apps which start with WinMain() and normally have a WinProc() in C/C++.
Write something tiny -- a "hello world" with int main() -- and get it to compile with Dev C
Phil P
Go to www.gametutorials.com
They have a much much better tutorial on getting started in my opinion. However, some things I see has really wrong in your code:
#define WIN32_LEAN_AND_MEAN should be before your include statement how else would it know?
why do you typedef your own WNDCLASSEX and not use it?
why are your function prototypes inside your WinMain?
The 3rd one is your major problem. Put all prototypes before you do any actual code (after includes) and it should clear up a lot of errors.
They have a much much better tutorial on getting started in my opinion. However, some things I see has really wrong in your code:
#define WIN32_LEAN_AND_MEAN should be before your include statement how else would it know?
why do you typedef your own WNDCLASSEX and not use it?
why are your function prototypes inside your WinMain?
The 3rd one is your major problem. Put all prototypes before you do any actual code (after includes) and it should clear up a lot of errors.
why do you typedef your own WNDCLASSEX and not use it?
why are your function prototypes inside your WinMain?
.........
cuase thats what the tutorial says...
in my opinion gametutorials sux.... it gives the source code away.. i learn nothing from it..
............................
I think you're starting too large. If you have Dev C, you should make sure you understand the compiler. Compile some very short DOS window things....write a program to input and add 2 numbers, etc. Slow down, Quake wasn't written in a day.
Check the documentation for what is required to compile a Win32 app. I don't have Dev C but I have Visual Studio 6 and here is the bare minimum for a Win32 basic Game Loop, this opens in a Window 640 x 480
GameLoop1.cpp
If this doesn't compile with zero errors in Dev C, then its probably how you are setting up Dev C to compile. In Visual Studio there are DOS apps which start with main(), and Win32 apps which start with WinMain() and normally have a WinProc() in C/C++.
Write something tiny -- a "hello world" with int main() -- and get it to compile with Dev C
Phil P
................
i have been through several C++ tutorials... and i felt i was ready for win32 programming... I have been through several win32 tutrials... none compile correctly... i have no clue what is wrong... and ur GameLoop1.cpp dont copile ... i would get Visual Studio .NET or whatever... but i found 1 problem.. $$$$$ ..... I have tried alot on this computer.. i think i have killed it... i cant go through anything i want to do... i think the internet/world hates me... i cant(mabye its just me) compile anything.. except basic C++.. i ant even make a friggin window!!!....
[edited by - TheNerd Tk421 on August 12, 2003 5:07:15 PM]
why are your function prototypes inside your WinMain?
.........
cuase thats what the tutorial says...
in my opinion gametutorials sux.... it gives the source code away.. i learn nothing from it..
............................
I think you're starting too large. If you have Dev C, you should make sure you understand the compiler. Compile some very short DOS window things....write a program to input and add 2 numbers, etc. Slow down, Quake wasn't written in a day.
Check the documentation for what is required to compile a Win32 app. I don't have Dev C but I have Visual Studio 6 and here is the bare minimum for a Win32 basic Game Loop, this opens in a Window 640 x 480
GameLoop1.cpp
If this doesn't compile with zero errors in Dev C, then its probably how you are setting up Dev C to compile. In Visual Studio there are DOS apps which start with main(), and Win32 apps which start with WinMain() and normally have a WinProc() in C/C++.
Write something tiny -- a "hello world" with int main() -- and get it to compile with Dev C
Phil P
................
i have been through several C++ tutorials... and i felt i was ready for win32 programming... I have been through several win32 tutrials... none compile correctly... i have no clue what is wrong... and ur GameLoop1.cpp dont copile ... i would get Visual Studio .NET or whatever... but i found 1 problem.. $$$$$ ..... I have tried alot on this computer.. i think i have killed it... i cant go through anything i want to do... i think the internet/world hates me... i cant(mabye its just me) compile anything.. except basic C++.. i ant even make a friggin window!!!....
[edited by - TheNerd Tk421 on August 12, 2003 5:07:15 PM]
quote:cuase thats what the tutorial says...
You should follow Raloth''s advise and do more console programming before jumping into Win32. You need a very strong grasp of C/C++ before attempting it. If you are just blindly copying code from tutorials then you are not ready. Function prototypes and compiler settings are just basic things you have to know to write any program. Adding the complexity of Windows programming on top of learning the basics just adds unnecessary frustration.
I wasnt "Blindly" copying code... i was reading and going through the full tutorial... and did everything it said... and when it said to compile... i tried to compile... it didnt work
Where would i do this??... ive search tons of places.. NOTHING WORKS
[edited by - TheNerd Tk421 on August 12, 2003 5:30:20 PM]
quote:do more console programming before jumping into Win32.
Where would i do this??... ive search tons of places.. NOTHING WORKS
[edited by - TheNerd Tk421 on August 12, 2003 5:30:20 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement