|
There are four GDI functions that can be used to converts DIBs to DDBs: CreateDIBitmap() , SetDIBits() , and SetDIBitsToDevice() , and StretchDIBits() .
Have a look at the Bitmap Basics - A GDI tutorial[^] article. The sources contain sample code to convert bitmaps.
Google will give you also a lot of results when feeding it with the above function names or 'DIB to DDB'.
|
|
|
|
|
Sir i have an base class which has an pure virtual member function..i have made it and also made other member function. now this is a general base class.i want that member member functions in derived class by their virtual function in which i can get the member function of base class and can do individual operation in each derived class.. what will be the syntax code for this problem how i can do these things? please reply my soon because this is my last day of assignment.. please
|
|
|
|
|
|
Sir i have mail you.. please check and teach me how i can use member member function of base class in virtual function of derived class for individual operations
|
|
|
|
|
|
That can add file header comment and function comment automatically.
|
|
|
|
|
The better way you can record one and edit that macro on your choice simple..
Jibesh V P
|
|
|
|
|
You will get a EN_KILLFOCUS message,when the focus switch from CIPAddressCtrl to another control, and this is normal case. But when you click at the dots among four ip fields,
you will get the EN_KILLFOCUS message too(with SPY++), which is not what I want, because I just want to do data validation when
the CIPAddressCtrl lost focus. How can I filer the EN_KILLFOCUS message when I click the dots???
|
|
|
|
|
Not sure if this will work or not, but in the message handler for EN_KILLFOCUS, check where the focus "went" with GetFocus[^] or CWnd::GetFocus[^] (whichever suits you best) and determine if the newly focused control is still "inside" the IP address control. I suspect it has four separate edit fields for each segment and all four have the IP address control thing set as its parent, so i supose a GetParent[^] or CWnd::GetParent[^] call can tell you if the user is still editing the IP address or is trying to leave the control altogether.
If you try this, do share with us if it worked or not, thanks in advance.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Thank you mat.
You are right.I just call GetFocus and determine weather the
EN_KILLFOCUS comes from the focused control.
BOOL CMyDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
UINT notificationCode = (UINT)HIWORD(wParam);
if (notificationCode == EN_KILLFOCUS || notificationCode == CBN_KILLFOCUS)
{
HWND hwnd = (HWND)lParam;
if (hwnd == NULL)
{
return false;
}
CWnd* pWnd = CWnd::FromHandle(hwnd);
int nID = pWnd->GetDlgCtrlID();
if (GetFocus() != NULL && GetFocus()->m_hWnd == pWnd->m_hWnd)
{
return false;
}
GetParent()->PostMessage(UM_KILLFOCUS, nID, 0);
}
return CDialog::OnCommand(wParam, lParam);
}
|
|
|
|
|
A bit less "specific" than the approach i might have chosen, but if it works for you, then great!
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
I am looking for a way to save a matrix (essentially an array) of data that has the intensity information for each pixel into an avi file.
I want the avi file to be of no size limits and uncompressed. This is on an NTFS system with windows XP or greater.
Any ideas or tutorials?
PKNT
|
|
|
|
|
AVI is a video file, that is a sequence of frames (and possibly related audio). If you have pixel intensity then you have one frame. Am I missing something?
Veni, vidi, vici.
|
|
|
|
|
Thanks for your reply. Yes, you are correct and we dont even have audio. I already have a way to save videos, but when saving longer videos, I am facing issues such as file index corruption etc and these longer videos are very important for us as they are research data.
I am looking for a new better way tos ave videos without any problems.
PKNT
|
|
|
|
|
|
Would AVIFileWriteData do the trick?
"The AVIFileWriteData function writes supplementary data (other than normal header, format, and stream data) to the file."
I hope you are well aware that there are at least three Win32 API for working on audio / video files.
The "AVI", "capAVI" and "wave".
I am curently using capAVI and recomend always to use whatever standard status/ error reporting API's are avaiable in the particular set.
Cheers
Vaclav
|
|
|
|
|
Try to Google "ffmpeg" this library helps you to write avi files with very little hassle. You can even choose coded or write uncompressed files using their example code included in the library download.
|
|
|
|
|
hello guys... im trying to write a small recording program. But waveInOpen fails with error code 11. Here is what I am trying.
LPHWAVEIN phWaveIn = NULL;
WAVEFORMATEX pcmWaveFormat;
::memset(&pcmWaveFormat, 0, sizeof(WAVEFORMATEX));
pcmWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
pcmWaveFormat.nChannels = 1;
pcmWaveFormat.nSamplesPerSec = 11025L;
pcmWaveFormat.nAvgBytesPerSec = 11025L;
pcmWaveFormat.nBlockAlign = 1;
pcmWaveFormat.wBitsPerSample = 8;
MMRESULT rResult;
rResult = IsFormatSupported(&pcmWaveFormat, WAVE_MAPPER);
if(rResult != MMSYSERR_NOERROR) return;
rResult = ::waveInOpen(phWaveIn, WAVE_MAPPER, &pcmWaveFormat, 0, 0, CALLBACK_NULL);
if(rResult != MMSYSERR_NOERROR)
{
CString sErrorMsg;
if(rResult == MMSYSERR_ALLOCATED)
sErrorMsg = "Specified resource is already allocated.";
else if(rResult == MMSYSERR_BADDEVICEID)
sErrorMsg = "Specified device identifier is out of range.";
else if(rResult == MMSYSERR_NODRIVER)
sErrorMsg = "No device driver is present.";
else if(rResult == MMSYSERR_NOMEM)
sErrorMsg = "Unable to allocate or lock memory.";
else if(rResult == WAVERR_BADFORMAT)
sErrorMsg = "Attempted to open with an unsupported waveform-audio format.";
}
What could be wrong? Thanks
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Your first parameter is supposed to be a pointer to a handle buffer, it should be:
HWAVEIN hWaveIn = NULL;
rResult = ::waveInOpen(&hWaveIn, WAVE_MAPPER, &pcmWaveFormat, 0, 0, CALLBACK_NULL);
|
|
|
|
|
I'm trying to copy some C code to a C++ class and I've got stuck with a function pointer issue. I've been trying to mess around with calling conventions but I don't want to make my C++ function static and don't want to change the old C code. Thanks for looking.
class theClass
{
public:
int theFunction(int theParam1);
int anotherFunction(void);
};
typedef int (*funcPtr) (int Param1);
int theClass::theFunction(int theParam1)
{
return 0;
}
int function(int theParam1)
{
return 0;
}
bool globFunction (funcPtr aFunction, bool someOtherArg)
{
int anArg = 0;
int ret = aFunction(anArg);
return true;
}
int theClass::anotherFunction(void)
{
globFunction (function, false);
globFunction (&theClass::theFunction, true);
return 0;
}
|
|
|
|
|
If, in your function, you don't access members of the class then it makes more sense to make it static then implement it as ordinary member.
Veni, vidi, vici.
|
|
|
|
|
If I remember correctly, you can't declare a pointer to a non-static member function in native C++. If you need to keep the original functions as they are, I would add a static helper function which gets the class object pointer as additional parameter and calls the member function. Something like that:
int theClass::theFunctionCaller(theClass * obj, int theParam1)
{
if (obj != NULL)
obj->theFunction(theParam1);
}
bool globFunction (theClass * obj, funcPtr aFunction)
{
int anArg = 0;
int ret = aFunction(obj, anArg);
return true;
}
int theClass::anotherFunction(void)
{
globFunction (this, &theClass::theFunctionCaller, true);
}
If you need the globFunction() for different classes, you could pass the obj as void * and cast it back in the helper function, because you know which class it is for at that point.
|
|
|
|
|
Cheers.. I'm having a play with this but you've modified globFunction, which in my case I'm really trying to avoid. Also it wont build as it stands (you can't call non static functions from a static function).
error C2352: 'theClass::theFunction' : illegal call of non-static member function
|
|
|
|
|
If modifying your global function is out of the question, then you can only pass it either a global function or a static class function. There is no other way. As CPallini remarked, the type of a pointer to a nonstatic member function is incompatible with your function pointer type definition.
What's more: a pointer to a nonstatic member function requires more memory to store than a simple function pointer, so casting is out of the question, too!
The question is: what is your goal? You're converting code, so why can't you change that global function?
If you really can't, the only solution I can think of would be a wrapper function that calls your member function indirectly:
namespace wrapper {
class theClass* instance; int theClassWrapper(int arg) {
int ret = 0;
if (instance != nullptr)
ret = instance->theFunction(arg);
return ret;
}
};
int theClass::anotherFunction() {
wrapper::instance = this;
return globFunction(&wrapper::theClassWrapper, true);
}
I've put the required additional global variable and global function inside a namespace to minimize global namespace polution and risk of conflicts, but you cannot avoid these additional globals if you cannot modify your existing global function.
|
|
|
|
|
Thanks for the reply - my original question was based on the premise that my casting or function declaration was wrong in some way - actually it looks like getting a pointer to a non-static class function and then casting it to match the original 'C' functions isn't straightforward.
So solution 1 - make the function and all the class variables static.
solution 2 - examine the original 'C' function that takes the function pointer and re-implement it.
Thanks for looking.
|
|
|
|