|
-
Oct 7th, 2001, 10:06 AM
#1
Thread Starter
Frenzied Member
classes....
Im trying to remake my win32 graphics class. so far its works, if I put this as global:
Code:
HDC hDC, hMemDC;
HBITMAP hBitmap;
BITMAP bm;
PAINTSTRUCT ps;
RECT rect;
HINSTANCE ghInst2;
but I want to put it in my class....is this possible?
-
Oct 7th, 2001, 10:50 AM
#2
If you want 1 copy per class, rather than 1 copy per instance, then declare it as static.
If that's not what you meant, please elabourate further (e.g: what objects do you want to be able to access it, and which ones do you not want to be able to access it).
-
Oct 7th, 2001, 11:53 AM
#3
transcendental analytic
You might have to explain where and how you access those variables.
Variables with global scope are accessible from anywhere, that's what makes them bad. If you put them in a class, you have to instantiate the class and have accessors for them, then access them by the object's name. This is not a good idea, because classes should be as independent as possible and protect it's data, so i have to ask you what you want with the variables.
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.
-
Oct 7th, 2001, 01:51 PM
#4
Thread Starter
Frenzied Member
Im using them to show a picture. I want 1 set per instance. But my graphic won't show (function) if I just put those in the class, the graphic only shows if they are global.
-
Oct 7th, 2001, 01:54 PM
#5
transcendental analytic
how and where do you access them?
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.
-
Oct 7th, 2001, 03:26 PM
#6
Thread Starter
Frenzied Member
through one of my classes functions. The function will be called in the WM_PAINT.
-
Oct 7th, 2001, 05:27 PM
#7
transcendental analytic
well I was expecting more scope related information.
Anyways, you can do a false assertion in the accessor to track the access.
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.
-
Oct 7th, 2001, 05:47 PM
#8
Thread Starter
Frenzied Member
*zoom* right over my head heres my class:
Code:
class graphics {
public:
~graphics() {
}
graphics() {
}
void ReDraw(int x, int y, HWND window) {
hDC = BeginPaint(window, &ps) ;
GetClientRect(window, &rect) ;
hBitmap = LoadBitmap(ghInst, MAKEINTRESOURCE(IDB_BITMAP1));
GetObject(hBitmap, sizeof(BITMAP), &bm);
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitmap);
BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
EndPaint(window, &ps);
DeleteObject(hBitmap);
}
};
now I want this to be able to show a graphic without having to put all those variables seperate for each instance of the class. where should I put them? everywhere I try to put them in the class, the function doesn't work. If they're global it does
-
Oct 8th, 2001, 04:51 AM
#9
transcendental analytic
Well that's not enough either, because I have no idea if you're accessing them or not. Easiest for you would be to zip it all up.
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.
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
|