|
can i type caste WPARAM and LPARAM into Int32 or not.
is there any lose of values;
Int32 wp=(Int32)wParam;
Int32 lp=(Int32)lParam; is there any lose of value if i get wParam,lParam like that?
WPARAM wParam=(WPARAM)wp;
LPARAM lParam=(LPARAM)lp;
r00d0034@yahoo.com
|
|
|
|
|
WPARAM and LPARAM are 32-bit integers, however depending on the exact message, they may be signed or unsigned. So without knowing the origin of the values, it's impossible to say whether assigning them to signed int variables could lose data.
Note that in 64-bit Windows, they are 64-bit integers.
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
i want to store thes values.
that can be put into
system.collection.hashtable and can be retrive again
but in case of wparam and lparam these values cant be retrive again ?
so what yo do ?
any suggestion.
r00d0034@yahoo.com
|
|
|
|
|
I have a little problem here maybe someone can help me please. I have to provide a Programmer class which is a sub class of both Person class and the Staff class. I have done simple inheritance but I don’t know much about multiple inheritance. Can anyone please help me with initial part of the program. Here are the Person.h and Staff.h file:
Person.h
#ifndef __PERSON_H
#define__PERSON_H
class Person{
Protected:
char* name;
int age;
Public:
Person(char*, int);
Person(const Person&);
Person& operator=(const Person&);
~Person();
char* getName();
int getAge();
};
#endif
&&&&&&&&&&&&&
Staff.h
#ifndef __STAFF_H
#define__STAFF_H
class Staff{
Protected :
Char* post;
Public:
Staff(char*);
Staff(const Staff&);
Staffoperator=(const Staff&);
`Staff();
char* getPost();
};
#endif
// thanks for replying
|
|
|
|
|
Here is how you would inherit from both classes:
class Programmer : public Person, public Staff
{
public:
Programmer () : Person(), Staff()
{
}
... All of the internal class stuff
};
One more thing, you should really make your destructors for your staff and person classes virtual. Otherwise if you use your classes polymorphically, the incorrect versions of the destructors will be called and you will get memory leaks.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
It would seem to me that all Staff objects would probably be people too (unless you have Robots or something!), so you would first derive Staff from Person, and then derive Programmer from Staff. Multiple inheritance can be useful, but I don't think you'll have to do it in this case.
Chris Richardson
|
|
|
|
|
Hi Thanks for replying, actually i must use multiple inheritance. I totally agree that staff derives from Person but the way the problem is set i have been told to use multiple inheritance.
|
|
|
|
|
do you have an idea when i will used this part of the problem please:
Staffoperator=(const Staff&);
Thanks
|
|
|
|
|
If you describe the actual problem you are having, I'll try to provide some information. Just from what you posted, you'll have to change that to:
Staff & operator=(const Staff&);
Chris Richardson
|
|
|
|
|
Hi, Actually i would really like to know how to use:
Person& operator=(const Person&);
and
Staff& operator=(const Staff&);
in my implementation and for the programmer class implementations. This is the part that i am failing to understand. Can you tell me what these pices of code mean and how we can use that please. thanks
|
|
|
|
|
I have a little problem here maybe someone can help me please. I have to provide a Programmer class which is a sub class of both Person class and the Staff class. I have done simple inheritance but I don’t know much about multiple inheritance. Can anyone please help me with initial part of the program. Here are the Person.h and Staff.h file:
Person.h
#ifndef __PERSON_H
#define__PERSON_H
class Person{
Protected:
char* name;
int age;
Public:
Person(char*, int);
Person(const Person&);
Person& operator=(const Person&);
~Person();
char* getName();
int getAge();
};
#endif
&&&&&&&&&&&&&
Staff.h
#ifndef __STAFF_H
#define__STAFF_H
class Staff{
Protected :
Char* post;
Public:
Staff(char*);
Staff(const Staff&);
Staffoperator=(const Staff&);
`Staff();
char* getPost();
};
#endif
|
|
|
|
|
Hello!,
I am a little stuck with this piece of code, can anyone help me please?
Actually I don’t know how to implement the assignment operator and the overloaded operator. Can you give me some tips and ideas please. As it is apparent, I have just started with C++ programming.
//file myString.h
#include <iostream.h>
class myString
{
private:
char* theString;
int length;
public:
myString();
myString(char*);
~myString();
myString(const myString&);
myString(const char*);
//the assignment operator
myString& operator=(const myString&);
myString& operator=(const char*);
int getLength();
const char* GetString();
// == operator overloaded for string comparison
friend int operator==(const myString&, const myString&);
friend int operator==(const myString&, const char*);
};
Thanks
|
|
|
|
|
I'm loading a bitmap off the disk and managing it with an IPicture pointer. What I would like to do is make a copy of that bitmap object in memory and obtain an IPicture interface pointer on this second object. This is what is giving me trouble. I've tried to make a memory device context select in a newly created bitmap, render the first IPicture, then converting the new bitmap into an IPicture, but the new bitmap is just all black.
I'm hoping there is something quick and easy I'm missing here about duplicating IPicture objects.
Ultimately my goal is to have two bitmap objects start off identically, then display one with a transparency mask in my toolbar (i can do this fine, but it alters the bits of the bitmap in memory so that is why i need the second copy) and another in my outline view as a plain bitmap.
thanks,
nebbish
Smart, Sexy, Sane. Pick two.
|
|
|
|
|
Are you making the newly-created bitmap with CreateCompatibleBitmap() ? A memory DC starts out with a 1-bit bitmap in it, so maybe the bitmap you create is also ending up 1-bit?
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hey Mike, yes i was using that and yes they were 1-bit black & white bitmap copies.
i don't have the time to go digging through MSDN for all the steps it will take to copy the bitmap through a DC........sooooo....i found another way --
<br />
void CopyPicture(IPicture *pOrig, IPicture **pCopy)<br />
{<br />
HRESULT hr;<br />
<br />
*pCopy = NULL;<br />
IPicturePtr spOrig(pOrig);<br />
IPicturePtr spCopy;<br />
<br />
IPersistStreamPtr spPS(spOrig);<br />
<br />
IStreamPtr spStream;<br />
hr = CreateStreamOnHGlobal(NULL, TRUE, &spStream);<br />
<br />
hr = spPS->Save(spStream, FALSE);<br />
<br />
hr = OleCreatePictureIndirect(NULL, IID_IPicture, TRUE, (void**)&spCopy);<br />
<br />
LARGE_INTEGER li;<br />
li.QuadPart = 0;<br />
hr = spStream->Seek(li, STREAM_SEEK_SET, NULL);<br />
spPS = spCopy;<br />
hr = spPS->Load(spStream);<br />
<br />
hr = spCopy->QueryInterface(pCopy);<br />
}<br />
(i know i don't do anything with 'hr', it's mostly for when i step through the code in a debugger, it would be very strange for any of this to actually not work)
...this proved much easier to wrap my mind around in the short run, avoiding the complexities of GDI. This way even the palette is copied from one image to the other.
thanks,
nebbish
Smart, Sexy, Sane. Pick two.
|
|
|
|
|
If i do the folowing:
class CMyListBox : public CListBox
{
DrawItem(LPDRAWITEMSTRUCT lpDIS){ }
MeasureItem(LPMEASUREITEMSTRUCT lpMIS){}
};
I can use the ownerdraw mechanism to create the display and keep the drawing code encapsulated inside the CMyListBox object. However if I want to do thie in SDK i'm screwed...cuz WS_OWNERDRAW must be handled by the controls parent window procedure...
Is there any way I can get around this...?
I guess I could handle the parent WM_DRAWITEM and just re-direct the message back to the control...but this doesn't seem very elegant...
Suggestions...???
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
Thanx Ravi!
I'll look into forsure...however I thought reflection was a MFC mechanism...?
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Yes it is - sorry I replied in a hurry!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Sorry for my English , it is not my own English.
I write a program which draw and move a triangels. When i move i must a redraw area. I use double buffering. I use MDI.
OnDraw(CDC *pDC)
{
CClientDC lpDC(this);
lpPen = new CPen(PS_SOLID,1,RGB(0,0,0));
lpDC.SelectObject(lpPen);
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(pDC);
MemBitmap.CreateCompatibleBitmap(pDC,rWinRect.right,rWinRect.bottom);
CBitmap *pOldBitmap = MemDC.SelectObject(&MemBitmap);
// Draw all
lpDC.BitBlt (0,0,rWinRect.right,rWinRect.bottom,&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(pOldBitmap);
}
And then i move a triangel i use for example
OnMouseMove(..)
{
// Do something
CClientDC lpDC(this);
OnDraw(&lpDC);
}
BUT AFTER A SEVERAL TIME PROGRAM CRASH WITH MESSAGE:
" A require resource was unavaliable"
PLEAZE HELP.
|
|
|
|
|
u need release ur dc;
code should be:
1. create a function:
DrawDC(CDC*pDC)
{
//put memory dc etc here
//do not use CClientDC lpDC(this);
//use pDC directly
}
2. OnMouseMove()
{
CDC pDC=GetDC();
DrawDC(pDC);
ReleaseDC(pDC);
}
3.OnDraw(CDC *pDC)
{
DrawDC(pDC);
}
includeh10
|
|
|
|
|
|
I am writing a program that provides the cost depending on weight. If the item weighs less than 16 ounces, the cost is $3.00. If more than 16 ounces the cost increases by .50 for each additinal 4 ounces. Here is what I have so far. It give me the 3 (not showing current format of $3.00) for weights <=16. But >16 shows a negative number.
Can some edit my code so it'll work? URGENT
#include <iostream.h>
#include <stdlib.h>
#include<stdio.h>
int main()
{
int wgt;
int x=0;
double cost;
int n = 4;
double i = 0.50;
double y;
cout <<"Enter the weight" <<endl;
cin="">> wgt;
if (wgt <16)
cost = 3.00;
cout <<"The cost is" <<cost <<endl;
="" {
="" if
="" (wgt="">16)
wgt = wgt +x;
x= n++;
y= i++;
cost = cost +y;
cout <<"Do you want to calculate the delivery";
cout <<" cost for another package?" <
|
|
|
|
|
sounds like homework, to me
so, here's a hint: if weight > 16, find out how much greater, then multiply the difference by $.50.
-c
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
As I see it this will only work if the cost is $.50 per amount >16. I need to figure out that amount at $.50 per increments of 4. (4 for .50, 8 for 1.00, etc.)
How can I do this?
|
|
|
|