|
Hi Ash,
Aescleal wrote: Normally I'd say use standard library features
I have noticed that
Aescleal wrote: the union of bit fields with an integer of the correct size has some advantages:
- you can name your bits
For single bit manipulation you can name your bits and your patterns with enums and std::bitfield makes it simple and easy to maintain:
typedef std::bitset<8> MyBits;
enum e_REG { RX0E, TX0E, RX1E, TX1E, RX2E, TX2E, EOFF, FNEF};
enum e_VAL { val_OK = 0, val_SOMETHING = 0x4A, val_FAILURE = 0x8f, };
MyBits myReg(val_SOMETHING);
myReg[RX2E] = true;
if (myReg == MyBits(val_FAILURE))
{
Aescleal wrote: you can deal with collections of bits (electronic engineers like packing them it, so you'll often get things like a 4 bit number, a 2 bit number and 2 x 1 bit numbers in one 8 bit register)
For that cases the poorly documented std::valarray<bool> is powerful.
With the C++0x lambdas, conversions between bitsets and valarrays become a breeze, so you can benefit of both
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Cool, I'll have to look at them a bit more closely. I've had problems in the past with bitsets mapping to hardware but that was probably some form of muppetry on my part.
Cheers,
Ash
|
|
|
|
|
My target hardware is ARM and my compiler only supports c/c++ standard libraries and not STL. http://www.cplusplus.com/reference/[^] In that link I have all the libraries up to but not including STL.
Gcc version is 4.1.0 Codesorcery ARM however its a branch of that tool chain for Cortex support.
|
|
|
|
|
Just out of interest STL is part of the standard library. A C++ standard library is like a C library without stdlib and string, almost completely useless.
Cheers,
Ash
|
|
|
|
|
I followed a basic DirectX tutorial that displayed a cube, were each of the sides displayed
were not anti aliased, 'I thought that directx would deal with this',
Can anybody tell me why this is so? And:
I used getPixel command in mfc to retrieve the values of a loaded
image in MFC, so I could use these in Directx, when ploting these
in directx, usiung the approbiate draw pixel command,
the overal image size differs from the original, it was shorter!
The ratio of plotting a pixel in MFC comparing to Directx differs
Why so, Please can somebody enlighten me?
Cheeers Simon S
modified on Monday, September 27, 2010 5:43 PM
|
|
|
|
|
Yes I know it is a Database question but I have not had much luck in that forum so I am looking for a fresh perspective.
I am using accessors to perform DB queries which works fine except when I come to do INSERTs.
This is the SQL in the accessor
DEFINE_COMMAND_EX(CDBEvtRawInsert, L" \
INSERT INTO [RawEvent] ([TimeStamp],[Direction],[Hub],[RawEvent]) \
VALUES (GETDATE(),? ,? , ?);")
which works fine with this snippet...
wcscpy_s(rsEvtRawInsert.f_RawEvent, iSize*2, CA2T(pTmp));
rsEvtRawInsert.f_Direction = 1;
rsEvtRawInsert.f_HubID = m_pHubDev->m_iHubID;
hr = rsEvtRawInsert.Open(m_oDB->session);
However in order to retrieve the ID of the record which has just been inserted I need to add SELECT @@IDENTITY AS RecID to the SQL but this makes it a multiple command accessor which is where my problem is.
I have search MSDN and the SDK's but for the life of me I cannot find anything that shows me how to code the accessor properly to deal with the multiple results. I know I can use GetNextResult to move onto the second result set but I cannot get it to work.
It has been suggested using ExecuteScalar would be the solution but as I am going to have multiple threads executing the same code I would prefer to use the @@IDENTITY to avoid any possible collisions between the threads.
The only other solutions I can think of are to either issue a search to find the record I have just created OR maintain a counter which would track the ID field.
Does anyone have any other ideas or point me to a way to get the accessor to process my multiple commands?
Alan
|
|
|
|
|
I have a multidoc app based on CFormView. I have a dialog using CListCtrlEx. Everything works fine. I moved the CListCtrlEx object from the dialog to the view (CFormView). Now it doesn't work. The call to GetHeaderCtrl() for the CListCtrlEx object now returns NULL whereas it didn't when that object was in the dialog. Anyone know why that should be and how I can get the call to GetHeaderCtrl() to return the CHeaderCtrl() when it's in the view instead of the dialog? Thanks in advance.
|
|
|
|
|
As what often happens, I found my problem after posting. In the words of Emily Latella, "never mind" (I think that was Emily, wasn't it?)
|
|
|
|
|
Hi everyone. I have a console application that plays .mp3 and .wav audio files. For .mp3 audio files there is no problem but when playing .wav audio files (PCM), there is always a pop sound at the end of the file. That is, the last bytes that get written to the audio device always produce a pop sound even for different .wav audio files. I tried to change the size of the buffer (4kB, 6KB, 8KB) but I still hear these pop sounds. What I have done is to read a fixed size of wav samples from the file and write them. When the bytes remaining in the file is less than this fixed size, the program reads only the size remaining in the file and writes these wave samples but the last samples read and written to the audio device produce the pop sound. However, when I play these .wav files with other media players, the pop sound is not produced. What am I missing?
|
|
|
|
|
Just a quick idea here since i don't know the wav format but why don't you padd your buffer with zeroes (or whatever will produce silence)?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
I have tried that as well. I had to padd the last 8 bits with zero values as follows:
memset(&samples_buffer[fileBytesRead], 0, 8);
where fileBytesRead has the total size of bytes read from the file but I was still hearing the pop sound.
|
|
|
|
|
Are you sure the pop comes because of those "extra" bytes? As said, i don't know wav but maybe you need something else than simple zeroes to specify silence. Come to think of it, you probably have to "decode" the wav to feed it to the sound driver, so maybe you need to give the "silence" in the end of the sound in a format the sound driver (or hardware?) understands. Am just guessing...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
modified on Friday, September 24, 2010 3:41 PM
|
|
|
|
|
Hi,
If I create a view like
CMyView *pView = new CMyView();
How should I delete it wheather using
pView ->DestroWindow() or
delete pView ;
|
|
|
|
|
Call DestroyWindow() only
if your class is derived from CView :
void CView::PostNcDestroy()
{
delete this;
}
virtual void BeHappy() = 0;
|
|
|
|
|
I did as you told...
But same problem I am facing.
If I use delete CMyView then only I am getting fresh view and not getting any refresh issue but crashing for next view.
|
|
|
|
|
Have you try ? :
pView->OnClose();
and after that , of course
delete pView;
modified on Monday, September 27, 2010 1:42 PM
|
|
|
|
|
Hello, I have an app which I need to make single instance. When the second instance is called it needs to bring the window of the first instance to the front, and pass it its command line params in some way. And I need the program to be single-instance on session only - i.e. only one instance is allowed per user, but many users logged on can each have their instance.
There are a lot of articles on this in codeproject, but I'm not sure which of them is the best and covers all the requirements.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Use the named mutex method.
This is by default unique per session unless you prefix "Global\" to the mutex name.
|
|
|
|
|
I think you can make your class as singleton by making you contructors and destructor as private and publically expose a static method which will return the same instance once an instance is created. That shud take care of your problem.. Google for singleton class examples ..u will get loads of them ..
-Kushagra
|
|
|
|
|
The singleton pattern is not applicable in this case: its purpose is to have a unique instance of an object for each process.
If you have two or more different instances of the same application, each of them runs on a different process with its own address space, then two applications cannot share the singleton object.
Cheers,
Sauro
|
|
|
|
|
another way, if you are certain about the window caption, is to use FindWindow() API to search for already running application. To make it unique, you may use your own name for your window class, and use it in FindWindow().
|
|
|
|
|
I've used FindWindow before, but I remember it had a lot of issues, for example (I don't remember) but didn't it fail if the window was minimized?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
no.. you can find out minimized windows also.
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
I am getting active view (say AV1) attached with main window (MainFrame) using GetActiveView, some other views are member of Av1 view.
If I use GetActiveView() just after initialzation of winow I am getting correct view.
But If I click of some another view then I am not getting Av1 view.
How to get same view at both instance?
|
|
|
|