|
oh I remembered this is one proper op
dw &= ~mask;
probably something more brief
if(dw & mask) //bit=0
dw |= mask;
else //bit=1
dw &= ~mask;
9ine
|
|
|
|
|
i don't like removing the curved braces, because they can end in heavy problems (especially when using macros...
i disadvise you to do so ; moreover, it won't produce lighter code after the compilation, so why writing less readable code ?!
but as badkarma suggested, you can also use the ^ XOR operator. but be careful !!! the mask variable must have only one bit set at a time, otherwise you could have several bits switching...
|
|
|
|
|
the fewer the code the better, so it is quite normal to use if(!a) instead of if(a==0)
9ine
|
|
|
|
|
9ine wrote: the fewer the code the better
false.
the explicit cast you don't do, the compiler will do them implicitely itself.
so don't loose the readability point
moreover, read this[^]
|
|
|
|
|
9ine wrote: ...it is quite normal to use if(!a) instead of if(a==0)
I don't consider that to be normal at all.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
9ine wrote:
0100101010011[1]001001010100111001 to invert 1 value bit
0100101010011[0]001001010100111001
Try:
unsigned int x = 0x4A9C9539;
x &= ~0x40000;
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I need to toggle it simultaniously 1to0 or if 0to1
xor is good
9ine
|
|
|
|
|
Right. You'll need the XOR operator to do both. My suggestion was just for one (i.e., 1 to 0). To go the other way (i.e., 0 to 1), use the OR operator.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
David, this will only unset the bit if it was set, but won't switch the state of the bit
|
|
|
|
|
|
Hi!
Does somebody know, if there is shareware to create class diagrams or flowcharts of programs? I already tried Jude, but thats only for JavaScript?
Thank you very much!
-- modified at 8:47 Tuesday 18th April, 2006
|
|
|
|
|
Microsoft Visio...
or Dia if you like awful GUIs
|
|
|
|
|
Check the "Rational Rose" application. But it's not shareware. some times u can evaluate it...
its a good one
nave
|
|
|
|
|
check http://meesoft.logicnet.dk/ for their nice free diagram designer.
|
|
|
|
|
|
If you're looking for a UML diagram editor, I've been playing with StarUML[^], and I'm rather impressed with it -- although I've only done a couple of class diagrams so far.
Another reasonable alternative for UML diagramming is ArgoUML[^].
|
|
|
|
|
I double click on a file (eg: C:\MyFileName.pdf ).
Now in my MFC code, I want to check if that file is already open.
One way of doing this is using CFile::Open function with CFile::shareExclusive mode.
Is there any better way to acheive this?
|
|
|
|
|
ArtiGujare wrote: Is there any better way to acheive this?
Not that I am aware of.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
ArtiGujare wrote: ne way of doing this is using CFile::Open function with CFile::shareExclusive mode.Is there any better way to acheive this?
thats the only way, but there are many api that se same logic to achive that
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
|
See the "Extras" section of this article.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
1.Create a CFont object( This object should not be created with in local scope. Its better to create this object as memeber variable of the class )..
2. call CreateFont function of this object
3. Create the member variable of the static control( for this u have to change the id of static control from IDC_STATIC to some other name )
4. Call the SetFont function of the static control to change the font.
nave
|
|
|
|
|
Thanks NaVin.
Leya
|
|
|
|
|
Hi All,
Using Timeline in DirectShow Editing services I did video and audio mixing.
I want to save it in avi format.
This is the code I used to save it. But it is not saving anything localy. At run time it creates an empty avi file.
It disappears automatically.
IRenderEngine *pRender = NULL;
hr = CoCreateInstance(CLSID_RenderEngine, NULL, CLSCTX_INPROC,
IID_IRenderEngine, (void**) &pRender);
hr = pRender->SetTimelineObject(pTL);
hr = pRender->ConnectFrontEnd( );
CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder2, (void **)&pBuilder);
// Get a pointer to the graph front end.
IGraphBuilder *pGraph;
pRender->GetFilterGraph(&pGraph);
pBuilder->SetFiltergraph(pGraph);
// Create the file-writing section.
IBaseFilter *pMux;
pBuilder->SetOutputFileName(&MEDIASUBTYPE_Avi,
OLESTR("Output.avi"), &pMux, NULL);
long NumGroups;
pTimeline->GetGroupCount(&NumGroups);
// Loop through the groups and get the output pins.
for (i = 0; i < NumGroups; i++)
{
IPin *pPin;
if (pRender->GetGroupOutputPin(i, &pPin) == S_OK)
{
IBaseFilter *pCompressor;
// Create a compressor filter.
IBaseFilter *pCompressor;
CoCreateInstance(CLSID_AVICo, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pCompressor);
pGraph->AddFilter(pCompressor, L"Compressor");
// Set compression parameters.
IAMStreamConfig *pStreamConfig = NULL;
IAMVideoCompression *pCompress = NULL;
AM_MEDIA_TYPE *pmt;
pBuild->FindInterface(NULL,NULL,pCompressor,IID_IAMStreamConfig, (void**)&pStreamConfig);
pStreamConfig->GetFormat(&pmt);
if(pmt->formattype == FORMAT_VideoInfo)
{
((VIDEOINFOHEADER *)(pmt->pbFormat))->dwBitRate = 10000;
pStreamConfig->SetFormat(pmt);
}
pStreamConfig->QueryInterface(IID_IAMVideoCompression, (void**)&pCompress);
pCompress->put_KeyFrameRate(4);
Note: I am converting BMPs into video file and adding wav file for audio.
Please help me on this.
Thanks in advance
Poornima
// Connect the pin.
pBuilder->RenderStream(NULL, NULL, pPin, pCompressor, pMux);
pCompressor->Release();
pPin->Release();
}
}
|
|
|
|
|
Just a thought, I'm just guessing here:
Is it possible that the output file isn't closed properly? That usually gives a zero-length file.
Is there such a thing as:
pBuilder->Release();
?
|
|
|
|