|
-
Nov 16th, 2001, 05:18 PM
#1
Combining Win32 API with OOP
Hi, I'm currently reading a book about creating Windows based applications using API with C++.
And since it's API, it's mainly C, and less C++.
I'd like to build my applications using OOP, but without using MFC.
Where do I start?
Can you give me examples of basic classes used for Windows programming?
Thanks.
-
Nov 17th, 2001, 03:06 AM
#2
Well, you'd have to come up with a basic concept: Do you want to make wrappers around the API (like MFC does), or do you only want some functional object that hide more of the API (a little bit like VB does).
Whatever you do, remember that CALLBACK functions can't be class member functions unless they are static.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 17th, 2001, 08:20 AM
#3
Monday Morning Lunatic
Welcome to the bandwagon Me and Kedaman are working on something similar This is what the new Windows headers look like (I'm regenerating them with templates):
Code:
namespace Win32 {
// Constants
const int WS_OVERLAPPED = 0x00000000L;
const int WS_POPUP = 0x80000000L;
const int WS_CHILD = 0x40000000L;
const int WS_MINIMIZE = 0x20000000L;
const int WS_VISIBLE = 0x10000000L;
const int WS_DISABLED = 0x08000000L;
const int WS_CLIPSIBLINGS = 0x04000000L;
extern "C" long __stdcall SetWindowLongA(HWND hWnd, int nIndex, long dwNewLong);
extern "C" long __stdcall SetWindowLongW(HWND hWnd, int nIndex, long dwNewLong);
template<class chrtyp> inline long __stdcall SetWindowLong(HWND hWnd, int nIndex, long dwNewLong);
inline long __stdcall SetWindowLong<char>(HWND hWnd, int nIndex, long dwNewLong)
{ return SetWindowLongA(hWnd, nIndex, dwNewLong); }
inline long __stdcall SetWindowLong<wchar_t>(HWND hWnd, int nIndex, long dwNewLong)
{ return SetWindowLongW(hWnd, nIndex, dwNewLong); }
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
-
Nov 17th, 2001, 02:46 PM
#4
parksie: how about splitting it up into several namespaces, like
namespace Win32Window
{
CreateWindowA...
...
}
namespace Win32Thread
{
CreateThread...
...
}
You would need to come up with good seperations, but I think it wouldn't be bad.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 17th, 2001, 05:47 PM
#5
Monday Morning Lunatic
Well this is only there to prevent it polluting the :: namespace. These functions won't be used by any programs, since they'd use the abstraction layer (ask Ked, not me, he's the one with the bright idea )
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
-
Nov 18th, 2001, 04:03 AM
#6
Well, if you'd ever need a bigger team, I'd work with you.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 18th, 2001, 10:44 AM
#7
As would I. I cant stand having some random #define changing my custom DLL DrawText Call into DrawTextA....and then it wonders why it cant find a function with the parameters I am passing.
Z.
-
Nov 18th, 2001, 03:00 PM
#8
transcendental analytic
The idea is to use 1) Object Oriented Programming and 2) Generic Programming to build up layers for use in developing device independent applications.
Parksie is working on the mostly functional and parameterized namespace, which I will be building up several interfaces in a parameterized nested class hierarchy for use as "pseudo-polymorphism" in device independent programming.
All layers will be fully object oriented, so there will be no global functions nor handles floating around, typically you will be performing a bitblt like this:
TargetDC.Rect(10,10,50,50).Do( bitblt(srccopy) << SourceDC.Rect(10,10,50,50));
among other alternatives:
(TargetDC<<Myrect).Do<bitblt(srccopy) >(SourceDCrect);
The GDI object will provide access for the win32 environment with easy moves:
Window x=GDI.Window<caption>("My app");
x.minimize();
GDI.Window<top>().Destroy();
Window y=GDI.CreateWindow(wndclass,"my window",somepos);
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 18th, 2001, 03:19 PM
#9
That is quite a project! I cant wait to see how everything turns out.
Z.
-
Nov 18th, 2001, 05:27 PM
#10
transcendental analytic
Yeah, it's not going to be an overnight project, but rather slowly growing one
btw nice avatari
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 18th, 2001, 07:02 PM
#11
Thanks =). I thought it could go in for a change.
Z.
-
Nov 21st, 2001, 02:50 PM
#12
Hey, sorry for not replying; Just got back from a 3-day trip.
Anyway, I was looking for something more basic.
I'm just starting with C++ Windows programming, so I just want basic guidelines.
Primarily on the approach.
I have no idea where to start.
-
Nov 21st, 2001, 03:00 PM
#13
transcendental analytic
my recommendation is Sams teach yourself C++ in 21 days
http://newdata.box.sk/bx/c/
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 21st, 2001, 03:48 PM
#14
kedaman:
That's the book I used to learn C++.
What I would like are guidelines on how to apply the OOP techniques I learned there on Win32 programming.
-
Nov 22nd, 2001, 05:43 AM
#15
transcendental analytic
I'm not sure if there is such kind of things, win32api programming has been more or less functional with exception for MFC and GDI+ i guess but that's what I'm going to change in the nearest years
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 22nd, 2001, 02:46 PM
#16
OK, thanks for your time everybody.
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
|