Ive been looking everywhere to find an example to set up my program using a class for my window but cant find any, someone please point me to a link or give me an example.
Ive been looking everywhere to find an example to set up my program using a class for my window but cant find any, someone please point me to a link or give me an example.
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein
The WinAPI has no classes (its "window classes" have nothing to do with C++ classes or OOP).
You can use libraries like MFC or OWL to encapsulate windows as objects. MFC is included in Visual C++, OWL is included in Borland C++ (and I think it has some MFC support as well).
Im know the Win32 API has nothing to do with classes! I want to create a class like CWindow in MFC but i cant find any tutorials on the subject.
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein
Learn C++, OOP, and the Win32 API, then you will have no problem. It's the only way.
Begin read MSDN to learn Win32. And buy a book.
Search for "C++ tutorials" on the internet. And buy a book.
That's wonderful advice, series! I don't think xds4lx need help on buying books..
I KNOW C++ AND I KNOW Win32! but when I make a class for creating my window it doesnt work so thats why im looking for a tutorial!
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein
Ok
The Windows API to register a new window class is:
browse the WNDCLASS structure and you will find its member:Code:ATOM RegisterClass( CONST WNDCLASS *lpWndClass // class data );
give it an unique, for the whole system, name.Code:... LPCTSTR lpszClassName
if you planing to develop whole new window class hierarchy you will need to 'tie' it with the OS.
So you will need an WndProc, in terms of the Windows API, where you will try to route every incoming system event to the particular instance of class (object), derived from your base CWindow.
I can suggest you to use an single WndProc for all instances of your classes, you also will need an way to distinguish between all the instances using the window Handle only(hWnd).
One way is to use the object's 'this' and to put it in some extra window long position(use this member od the WNDCLASS struct):
or to use an global map to keep the relation between them.Code:int cbWndExtra
you shoud put that WndProc in the WINDOWCLASS structure:
when you registering your main class(in terms of the windows API)Code:WNDPROC lpfnWndProc
So it is not a simple task and there are many ways to archieve it.
Damyan
No, you don't, not good enough. Because:xds3lx
I KNOW C++ AND I KNOW Win32!
And if you can't find a tutorial, then it's not a question for this board. The problem with your question is that you have no details at all about your problem, basicly you're just saying: "I have a problem creating a window". We are not here to find tutorials for people, or to make a guess for a possible answer, we're here to help with questions about Win32 programming. You don't even know what the problem is.but when I make a class for creating my window it doesnt work so thats why im looking for a tutorial!
That's exactly what he needs.*Michelle*
That's wonderful advice, series! I don't think xds4lx need help on buying books..
Series, please keep your negative comments to yourself.
xds4lx, can you give an example of what you tried and
what exactly failed to produce the desired results ?
Your post is indeed very general, and I don't know where
to start to help you.
Keep cool people.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
Ok, first of FU series! Ive been coding in C++ for 6 years. And i dont need to know what funtion to call to register a damn window! Ive been programming Win32 for a year ok. My problem is that im trying encapsulate the window creating and it keeps failing. Im basicly trying to create a class that works like CWindow, but I have no idea how to go about this because every idea I have has failed so far.
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein