|
reinterpret_cast is the same as the C style cast your writer uses. The compiler does nothing, the cast is a statement from you the programmer that the types are equivalent. In this case they are. It would be better style to use reinterpret_cast but the code in question isn't modern C++, rather it's C with a few C++ bits, so the C style class seems appropriate.
The other C++ casts are more constraining and allow the compiler to determine whether what you (or a user of your code) are trying to do is appropriate.
Paul
|
|
|
|
|
Paul, thanks, that makes alot of sense. I appreciate the response.
I don't know why, but I've always had this irrational fear of rogue pointers, since it's so easy to re-assign the address. But, they sure are ubiquitous, and so many Windows functions couldn't live without them.
|
|
|
|
|
Hi there,
I have an image available as a pointer to an unsigned char array (grayscale, 1 byte/pixel) and I know its width and height.
I can add all data to a BITMAP structure, but how do I display that using MFC?
Thanks in advance!
|
|
|
|
|
If you have an HBITMAP returned from a function such as CreateDIBSection , you need to select that object into a device context compatible with the screen (call CreateCompatibleDC ) and use BitBlt to copy from the memory device context into the screen device context.
BitBlt also has a number of cousins for stretching the bitmap while copying, or performing mask or pattern operations.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for your answer.
I have used a library to deal with image calculations and have the pointer and the width and height available, so I can fill a BITMAP structure.
Other than that, I have a dialog to let the user input some data, so I need to open a new dialog, which I already did, but how do I move on?
Al
|
|
|
|
|
I have an SDI application.
This code in on the OnOpen document function.
for(i=0; i<numevents; i++)="" the="" numevents="" are="" midi="" events="" extracted
="" from="" document
="" {
="" event="pTrackList[0]-">GetEvent(i);
time = event->time;
status = event->status;
data1 = event->data1;
data2 = event->data2;
data3 = event->data3;
//temp = tempo(data1, data2, data3);
if(status == 144 && data2 > 0)
{
tempPoint = tempGrid->FindNote(data1);
tempPoint.y = -tempPoint.y;
tempPoint.x = cur_pos;
tempPoint.x = tempPoint.x * 720;
cur_pos++;
pView->AddNoteToptArray(tempPoint);
}
The Find Note function returns some coordinates. The AddNoteToptArray adds the tempPoint value to a CPoint array which is used to draw in the OnDraw Function. The problem is that the notes are drawn and then immediately cleared of the screen. Is that when the view is updated from the document..? Is the only way to make this work to use a document to hold all the data I need to draw the notes? Will it need to have virtual functions to draw them as well?I don't know much about document/view arctitecture so any kind of help could prove usefull!
|
|
|
|
|
Hi guys
Do you know a reason to get an error linking, but only in release mode.
In debug mode all is good, but in release I receive a linker error.
Do you know why this could happens?
Doc
|
|
|
|
|
More Info
I'm using class CListCtrlEx in the article about ScrollSync
This is what the class has
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
If I remove this, in debug mode I receive the same errors linking as release mode.
What I have to do to link in release mode?
Thanks
Doc
|
|
|
|
|
Have you perhaps tried to replace the global ::operator new ? What is the actual linker error message?
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I'm using DAO (CDaoRecordset) on an Access database. I'm using Get/Set FieldValue using an ordinal position. In debug everything is fine. In release mode I get "Data Type Conversion" errors. It's happened on numeric and text fields - I know that the correct type/value is being get/set.
When I change the ordinal to an actual field name everything is fine.
|
|
|
|
|
Hi,
I'm using Dependency Walker 2.1.3790. It lists 5 types of dependencies: Implicit, Delay-load, Forward, Explicit, and System Hook. I want to know how they are related to the 2 types of Dynamic Linking: Load-time and run-time. Does the dependency type indicate which Dynamic Linking type is used?
Thank you for any help.
|
|
|
|
|
The simplest ones to explain are Implicit and Explicit. Implicit is where the binary's Import Address Table lists a particular function exported by a given binary (normally a DLL). This type of dependency is resolved by the loader when loading that binary and causes an error if not present. This is your 'load-time' case.
The Explicit case is where LoadLibrary has been used to load a DLL by the program or one of its DLLs. This can include loading COM DLLs (which you'll see grouped under OLE32.DLL, since that actually does the loading).
Forwarding is an advanced feature where a DLL can simply include a function in a different DLL in its exported function table. On Windows NT-based systems, some functions exported by kernel32.dll are simply forwarded on to ntdll.dll . This allows you to move functionality between DLLs without having to recompile the applications.
Delay-Load is another advanced feature which allows the application to get the benefit of run-time linking while having the convenience of simply calling the functions in code. If the function called is not present at run-time, a Windows SEH exception is raised. IIRC, this feature is used by MFC 6.0 and higher to reduce start-up time.
I'm not entirely sure how the System Hook type occurs.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I started on the below description and code and am trying to see if I can get any further. Does this look right?
lab.h
public class Point
{
friend ostream &operator<<(ostream&, const Point&);
friend istream &operator>>(istream&, Point&);
private:
double x;
double y;
String name;
public
Point();
Point(double a, double b);
Point(const Point& p);
//have to add methods to this class and add the operators +,-,++,--,<,>,==,=, operators
};
//I have to add 2 classes Rectangle and Oval
//Rectangle is to have a point included in it which represents the left corner of the
//Rectangle. It should also have a length and width data member
//create the correct methods and include a method named move which can have 2 forms
//from 1 move(Point p) which says move the current point to (x+p.x, y+p.y, form 2 is move
// (double x, double y) which says make the current point set to this.x,this.y
// have the values of x,y.
// Oval is to have a Point p which is its center and a radius and should also have a move
//which operates the same as the one in Rectangle.
public class Rectangle
{
friend ostream &operator<<(ostream&, const LPoint&);
friend ostream &operator>>(istream&, LPoint&);
private;
double l;
double w;
String name;
public; Move(Point p)
Move(double x, double y)
};
public class Oval
{
friend ostream &operator<<(ostream&, const CPoint&);
friend ostream &operator>>(istream&, CPoint&);
private;
double c;
double r;
String name;
public; Move(Point p)
Move(double x, double y)
};
does this look like it makes any sense?
Thanks
|
|
|
|
|
Hi.
I have a class, CMyClass, and I want to build an array of CMyClass.
Could I write something like this?.
i=0;<br />
CMyClass* myClass = new CMyClass[];<br />
myClass[i] = new CMyClass();
That throw the following error:
error C2582: 'CMyClass' : 'operator =' function is unavailable
I don't want to use some template array.
What I'm doing wrong.
Thank you.
|
|
|
|
|
Try:
CMyClass** myClass = new CMyClass[];
myClass[i] = new CMyClass();
John
|
|
|
|
|
Hi John.
Now throws:
error C2440: 'initializing' : cannot convert from 'class CMyClass *' to 'class CMyClass ** '<br />
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
I don't know what happend.
|
|
|
|
|
Sorry my fault:
CMyClass** myClass = new CMyClass*[NUMBER_TO_ALLOCATE];
myClass[i] = new CMyClass();
John
|
|
|
|
|
you don't need the second line...
all the cells of the tab will be automatically created with the default constructor...
your myClass[i] = new CMyClass(); is so redondant..
regards
TOXCCT >>> GEII power
|
|
|
|
|
No the first line creates an array of pointers to CMyClass and the second line Creates the object instance.
John
|
|
|
|
|
CMyClass* myClass = new CMyClass[]; don't mean nothing... how many bytes will be allocated ??
prefer that :
<font style="color:blue;">#define</font> TAB_SAZE 10 <font style="color:green;">// for example
</font>
<font style="color:blue;">int</font> i=0;
CMyClass* myClass = new CMyClass[TAB_SIZE];
<font style="color:green;"></font> <font style="color:green;">
<font style="color:green;">
</font>
I assume that you have the needed operators written, or that you will...
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
/* myClass[i] = new CMyClass(); */ // not needed anymore. // each object is now initialized as the default constructor would do...
This was this line that throw the error (and so when you say this is not needed anymore, you'll have to say this CAN'T BE USED !).
In fact when you write:
CMyClass* myClass = new CMyClass[TAB_SIZE];
you are declaring an array of OBJECTS and not an array of pointers to object. So myClass[i] is an object and not a pointer !!
So this is totally wrong to write such a thing: myClass[i] = new CMyClass(); .
Hope this helps
|
|
|
|
|
Hi, i´d like to put and retreive to-from a LPBYTE variable data from a class, like
class A
{
int a;
double b;
LPBYTE GetStream();
} void SetStream(LPBYTE lpData, DWORD dwLen);
...
A class1,class2;
LPBYTE stream = class1.GetStream();
class2.SetStream(stream)
Qhris!
|
|
|
|
|
How does one go about opening a file that is located in the directory of the executable without using any code that is OS-dependent (not microsoft functions)?
(The user could be in a directory different from where the executable is located, and run that executable, which opens a file in the directory where the executable is located.)
Thanks!
|
|
|
|
|
In standard C, I am prertty sure that the argv[0] command line argument to main usually has the full path of the executable file. Strip off the program's file name, you are left with the path to folder where exe is located.
|
|
|
|
|
Okay, "HOW TO: Write an Applciation That Supports Fast User Switching in Windows XP".
Yep, another technically accurate but totally worthless document from Microsoft
Statements like "Block any problematic features' are useless. Well, what could I expect to be problematic? If I blocked the user from switching, the app would work fine.
So, now that I have the session switch notifications in the program and I get WTS_SESSION_LOCK and WTS_SESSION_UNLOCK, what kinds of activity should I PREVENT while the session is locked?
My program is actually returning ACCESS DENIED (GetLastError = 5) on a call to the Rectangle(HDC, int, int, int, int) GDI function!
And of course, they have the classic 'FindWindow' example of locating an existing instance..
Any worthwhile ideas?
|
|
|
|