|
The only time you can't rewrite a base class is when you haven't got the code for it. The rest of the reasons are all social.
Just out of interest anything you can do with inheritance (of concrete base classes) in the context of code generation you could a lot more cleanly do with composition. MFC, as one example, wouldn't be such a mess of deriving from concrete classes if they'd have done that. However there wasn't the C++ expertise around in 1991 that there is now so you can't blame them in hindsight.
Cheers,
Ash
|
|
|
|
|
I think the social bit got lost in translation. I was looking upon social as political, and not economical, which I assume now you include in social?
|
|
|
|
|
I tend to include economic reasons as social, although as a supposed engineer perhaps I shouldn't.
Cheers,
Ash
|
|
|
|
|
In MFC application, I want to play audio and video file on my dialog. Audio/video file like mp3,vob,wav,flv,wma,dat,avi etc
Is there any example available
|
|
|
|
|
|
Thanks for the link
It's working for avi and mp3 files
is there any sample for other audio/video files like dat,vob,slv
|
|
|
|
|
well.. directshow is not a format bounded architecture. You just need to have the codec for the audio/video format you need to play. Directshow's intelligent connect mechanism will do the rest for you.
|
|
|
|
|
Edit: Solved myself, after a flash of inspiration!
Just removed the "KMDF_VERSION_MAJOR=1" line from SOURCE file.
Sigh...
-------------------
Good afternoon all.
I'm trying to make a driver to run on XP. I've trawled the web, and ended up with the following ultra minimal code:
#include <ntddk.h>
NTSTATUS driverCleanupFunction (IN PDRIVER_OBJECT pDriverObject);
NTSTATUS DriverEntry (IN PDRIVER_OBJECT pDriverObject, IN PUNICODE_STRING strRegistryPath)
{
strRegistryPath = strRegistryPath;
pDriverObject->DriverUnload = driverCleanupFunction;
DbgPrint ("Iain: Driver starting\n");
return STATUS_SUCCESS;
}
NTSTATUS driverCleanupFunction (IN PDRIVER_OBJECT pDriverObject)
{
pDriverObject = pDriverObject;
DbgPrint ("Iain: Driver stopping\n");
return STATUS_SUCCESS;
}
As you can see it doesn't do a whole bunch. I do plan on adding some functionality!
But I can't run it on my XP VM (you didn't expect me to mess about on a real machine to start with?), as the DDK's build has linked it with WDFLDR.sys.
I'm not using any of the WDF functionality. It's not installed on my basic XPsp3 VM (or the real XPsp3 machine to my left).
I've downloaded the DDK pretty recently (7600.16385.1).
I suspect I just have to use some sort of "#define NO_WDF_PLEASE" constant, but I have no clue what.
Any hints?
Cheers,
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
modified on Thursday, July 22, 2010 9:03 AM
|
|
|
|
|
Hi,
I am facing problem in my project and to simulate this problem I have reproduced in sample application.
I have created a SDI MFC app with doc view architecture.
I am facing problem while Print preview.
While I close the preview Window, application hangs and after some time it crashed.
Following is the implementation of OnFilePrintPreview and OnEndPrintPreview:
void CSampleView::OnFilePrintPreview()
{
// must not create this on the frame. Must outlive this function
CPrintPreviewState* pState = new CPrintPreviewState;
// temporary remove the parent so that the DoPrintPreview() uses the mainframe
ShowWindow(SW_HIDE);
SetParent(NULL);
//AfxMessageBox("Before DoPrintPreview");
if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
RUNTIME_CLASS(CPreviewView), pState))
{
//AfxMessageBox("After DoPrintPreview IF");
// In derived classes, reverse special window handling here for
// Preview failure case
TRACE0("Error: DoPrintPreview failed.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState; // preview failed to initialize, delete State now
}
//AfxMessageBox("After DoPrintPreview");
}
void CSampleView::OnEndPrintPreview( CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView)
{
pView->DestroyWindow();
SetParent(AfxGetApp()->m_pMainWnd);
AfxGetApp()->m_pMainWnd->ShowWindow(SW_SHOW);
AfxGetApp()->m_pMainWnd->UpdateWindow();
}
Please provide input on this if anybody has any idea on this.
Thanks in Advance!!
Regards,
Tony
|
|
|
|
|
Had this problem before. Dont remember exactly how I solved.
I think that, OnEndPrintPreview, call:
SetDlgCtrlID(AFX_IDW_PANE_FIRST);
I have an article, http://www.codeproject.com/KB/miscctrl/BasicAdminCP.aspx
In the utils folder, ViewPrintPreview.cpp there is code working.
it´s the journey, not the destination that matters
|
|
|
|
|
Thanks for your response.
It helped me partailly but I guess now I can solve that.
Once again thank you for your response!
Regards,
Tony
|
|
|
|
|
You´re welcome.
I spent a LOT of time making print preview work for different controls and situations.
it´s the journey, not the destination that matters
|
|
|
|
|
Hi
How to create a wrapper class for an existing class?
thanks :
|
|
|
|
|
Your question is too generic: it depends on your scenario.
Which kind of class do you want to wrap (COM object, ActiveX, ...)?
What is your target?
|
|
|
|
|
Typically what you do is to create a new class exposing methods of an interface that you are interested in. Depending of what you want to wrap, the interface might be a C header file, a COM interface or another class, etc. The wrapper class often manages resource allocation and deallocation of the exposed interface, and this is often the most valuable aspect of wrapping. You can also make it easier to use the interface by bundling methods together as you see fit, removing rarely used parameters and such.
|
|
|
|
|
As a member of the wrapper class, an object of the existing class is created.
The member object is then initialized in the constructor of the wrapper class.
From the methods of the wrapper class, the methods of the existing class will be called using the member object.
|
|
|
|
|
The problem here is that one man's wrapper is another's bridge, adapter, guard or facade. Generally you use wrappers to modify the functionality of the wrapped class in some way so how you do it depends on what the class you're wrapping does and what you want the wrapper to do.
If I were you I'd have a look at a book on design patterns - e.g. "Design Patterns" by Gamma, Helm, Johnson and Vlisides - and go through the patterns looking at which of the classes used are just there to modify the behaviour of other classes by containing them rather than by extending them.
Cheers,
Ash
|
|
|
|
|
hi guys need help about my problem,
am trying to swap the values of 'x' and 'y' without using a temporary storage like 'z'..
here is the code
int x = 150 (or any integer value);
int y = 45 (or any integer value);
output:
x = 45
y = 150
help guys, thanks ahead.
|
|
|
|
|
x += y;
y = x - y;
x -= y; If you have long variables or able to type cast to long, try InterlockedExchange .
|
|
|
|
|
one way to get there is by using a number of exclusive-or operations.
|
|
|
|
|
1)
With simple arithmetic operations:
int x = 150;
int y = 45;
x = x + y;
y = x - y;
x = x - y;
[EDIT]
The above technique is dangerous because in some situations you can exceed the data types range!!
Now I know (thanks to emilio_grv and his excellent post[^]) that this technique is not dangerous if the two variables are of the same integer type.
[/EDIT]
2)
The XOR swap:
int x = 150;
int y = 45;
x ^= y;
y ^= x;
x ^= y;
You can read more about the XOR swap here[^].
Also you can check out some CodeProject articles (and their message boards) on this topic:
- A Curious Economic Swap[^]
- The Stupid XOR Trick[^]
modified on Thursday, July 22, 2010 3:56 AM
|
|
|
|
|
Point 1 isn't dangerous at all.
The carry overflow of the sum is compensated by a missing borrow of the subtraction.
Both +- and ^ operates on closed Galois field (+- of size 232 and ^ on 32 fields of size 2)
The only difference is that the ^ operation requires a combinatorial network simpler than + and this can make the processor ALU faster. But it is quite hard this may be observed outside.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Thank you very much for this enlightening information.
modified on Thursday, July 22, 2010 4:01 AM
|
|
|
|
|
emilio_grv wrote: But it is quite hard this may be observed outside
Today's processors are so severly RAM-speed limited, and integer arithimetic has been so optimized in the silicon, that I doubt the speed difference is measurable between the addition and XOR methods.
If we're talking something like floats.. well, then the addition method doesn't work reliably anyway.
patbob
|
|
|
|
|
More importantly if you're into this sort of micro-optimisation then add'em subtract'em method only works on arithmetic types. Pointers need not apply.
Cheers,
Ash
|
|
|
|