|
In any recent version of VC, iterators are not simple pointers. There is some debug info kept around to detect dangling iterators and iterators that point outside of their containers. So doing a straight memcpy will work only as long as the original iterator exists.
What about this:
vector<T>::iterator* piter = new vector<T>::iterator ( someVector.begin() );
void* pv = (void*) piter;</T></T> ? Last modified: 5hrs 10mins after originally posted -- fixde tpyo
--Mike--
|
|
|
|
|
|
Is there any function which can transfer date time string to SYSTEMTIME?
the string may be, such as, "2009-06-21 3:12:13" or "2009-06-21".
|
|
|
|
|
|
No single WIndows function, but VarDateFromStr[^] followed by VariantTimeToSystemTime[^]. That will use the date/time format(s) defined by your current locale.
Alternatively,
SYSTEMTIME st;
sscanf("2009-06-21 3:12:13", "%4d-%2d-%2d %d:%d:%d", &sy.wYear, &st.wMonth, &st.wDay, &st.wHour, &st.wMinute, &st.wSecond);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I need help with the GDI-function Alphablend() on Vista. Here's my code:
hMemDC:=CreateCompatibleDC(hdc)
hbitmap:=CreatecompatibleBitmap(hdc,width,height)
...
blendfunc.BlendOp=0
blendfunc.BlendFlags=0
blendfunc.SourceConstantAlpha=128
blendfunc.AlphaFormat=0
AlphaBlend(hdc,siPX,siPY,width,Height,hMemDC,0,0,Width,Height,@blendfunc))
//StretchBlt(hdc,siPX,siPY,Width,Height,hMemDC,0,0,Width,Height,SRCCOPY)
//BitBlt(hdc,siPX,siPY,Width,Height,hMemDC,0,0,SRCCOPY)
When i use StretchBlt() or Bitblt() it works OK, so coordinates are ok. My language is not C so @blendfunc seams wrong but im sure it is not (it means 'pointer to a structure'). I suspect AlphaBlend does not work (returns false) because my bitmap has no alpha-channel. Saw on the MS-website an example that uses CreateDibSection() to create a 32-bit bitmap but that doesn't work also.
It goes like this:
hMemDC:=CreateCompatibleDC(hdc)
memclear(@bmi,_sizeof(_winBITMAPINFO))
bmi.bmiHeader.biSize:=_sizeof(_winBITMAPINFOHEADER)
bmi.bmiHeader.biWidth:=width
bmi.bmiHeader.biHeight:=height
bmi.bmiHeader.biPlanes:=1
bmi.bmiHeader.biBitCount:=32
bmi.bmiHeader.biCompression:=BI_RGB
bmi.bmiHeader.biSizeImage:=oDim:width*oDim:height*4
hbitmap:=CreateDIBSection(hMemDC,@bmi,DIB_RGB_COLORS,pBits,NULL,0)
SelectObject(hMemDC,hbitmap)
So im out of options... Has anyone an idea, or a codesnippet that does work, so i can try that one?
Thanks,
Rozis
modified on Sunday, June 28, 2009 5:04 AM
|
|
|
|
|
I've been working in C# and Java for a while, with only a little experience in using C++, and I'm having a little trouble finding information on if there is anything like base or super in C++. If for example I have this:
class foo {
public:
virtual void myMethod() { cout << "this part is in foo" << endl; }
};
class bar : public foo {
public:
void myMethod() { base.myMethod(); cout << "\tthis part is in bar" << endl; }
};
Such that, base.myMethod() would perform the tasks of myMethod() in the base class, and then it would carry out the new implementation from there; is anything like this possible in C++?
thanks!
|
|
|
|
|
Hi. Just use the base's name:
class bar : public foo {
public:
void myMethod() { foo::myMethod(); cout << "\tthis part is in bar" << endl; }
};
There's no specific keyword, since C++ allows multiple inheritance and therefore it is not guaranteed that one class has one and only one base class.
Regards.
Stupidity is an International Association - Enrique Jardiel Poncela
|
|
|
|
|
Thanks ! Going back to C++ continues to remind me how different it really is from C#
|
|
|
|
|
Visual C++ provides a non-standard keyword __super[^] that does that. Not that I recommend it
|
|
|
|
|
To expand on Fernando's answer - you can't really have a 'base' or 'super' keyword in C++ because a C++ class can inherit from multiple non-abstract bases.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi
I'm trying to save image from webBrowser control after a open webpage.
It is like right clicking on the picture and clicking at "Save Picture As..." Context menu, except I wanted to do it
programmaticaly with out showing save dialog box.
I tried
this->webBrowser1->Document->execcommand("Save As", false, strFilePath);
it does not work.
Some one Knows better way?
|
|
|
|
|
Hi,
im using the below code to increase the size of the DialogBox along with the controls inside it during Runtime...ie im overriding DoModal()function...
CTestDlg is my application name....
INT_PTR CTestDlg::DoModal()
{
CDialogTemplate dlt;
int nResult;
// load dialog template
//CTestDlg::IDD is the ID of my resoource...
if (!dlt.Load(MAKEINTRESOURCE(CTestDlg::IDD))) return -1;
// set your own font, for example "Arial", 10 pts.
dlt.SetFont(L"Arial", 12);
// get pointer to the modified dialog template
LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
// let MFC know that you are using your own template
m_lpszTemplateName = NULL;
InitModalIndirect(pdata);
// display dialog box
nResult = CDialog::DoModal();
// unlock memory object
GlobalUnlock(dlt.m_hTemplate);
return nResult;
}
The issue is the font of one of the control (CheckBox) is not getting increased...
Please let me know...
|
|
|
|
|
Hi All,
i know it might be a basic question but still i have to ask as i didnt find it that how i can replace " with \"
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
If you are trying to insert a backslash using a string literal you need to escape the character. The escape character is of course a backslash so that means you need two consecutive to produce one.
"\\"
Otherwise I have no idea what you are trying to do.
|
|
|
|
|
You can use CString::Replace or string::find and string::replace.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I'm not a C++ programmer, but I have some work to do with fixing a Memory Leak. I created a reference to an object called myObject:
myObject = CreateObject();
right?
So if I recreate that myObject by using:
myObject = CreateObject();
Again and it creates a new object will it overwrite that memory space and destroy the old object or do I have to delete myObject first and then write to that reference again?
Thanks for your help, I've been looking everywhere for this.
|
|
|
|
|
You have to delete the previously created object before creating a new object.
If you have used new or new[] inside CreateObject you have to call delete or delete[] respectively.
If malloc is used, you have to call free.
If it is a COM object, you have to call its Release method.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
It all depends on what CreateObject actually does...
If it does something like this:
struct Object
{
whatever
};
Object CreateObject() { return Object(); }
then you don't need to do anything to myObject before reassigning to it.
If it uses a resource allocating function (e.g. new and malloc allocate memory, CreateFile, CreateEvent and CreateProcess allocate kernel handles, there are many more different examples of resource allocators) and passes control of that resource back to you, then you are responsible for deallocating that resource.
To show a simple example:
Object* CreateObject() { return new Object(); }
To reassign to myObject, you'd need to deallocate the thing referenced by myObject using delete myObject
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
just to clarify :
does CreateObject() return a pointer to an object or a reference ?
This signature was proudly tested on animals.
|
|
|
|
|
It's just simply:
{return new Object();}
|
|
|
|
|
In which case a delete myObject; is required to deallocate the object before assigning a different value to myObject - so long as the reference held by myObject hasn't been copied to some other variable.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
No ,this will not overwrite the Memory Space.
if you have created object and collected the Reference it's just a reference (i.e. constant pointer).If you will assign it a new address it 'll not delete old object.(As it should not, Bcoz that object may be used ant where else).So if you are sure it is not usable now.Then call delete on it first .Then create new and assign value to it.
But if you are not assigning new value , set it to null ('ll save from Dangling pointer).
So you can say
if( myObject != NULL)
delete myObject;
myObject = CreateObject(); //or myObject = NULL;
It's not enough to be the best, when you have capability to be great....
|
|
|
|
|
Dear All,
I want to display Unicode characters in my CEdit control but it is not displaying and it is displaying as boxes. Any ideas ?
Bhanu
|
|
|
|
|
Is your project set to build for unicode?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|