|
If you read the rest of #2, you'll see I tell him to read more data out of the file, appending to the original chunk. That covers the case where you haven't read enough of the data to include an entire marker.
Software Zen: delete this;
|
|
|
|
|
See here.
In summary:
CFile file;
char *pBuffer = new char[file.GetLength() + 1];
file.Read(sBuffer);
sBuffer[file.GetLength()] = '\0';
file.Close();
CString str(sBuffer);
int nIndex1 = str.Find(">>");
int nIndex2 = str.Find("<<", nIndex1 + 2);
CString strData = str.Mid(nIndex1 + 2, nIndex2 - nIndex1 - 2);
or
int nNumber = atoi(str.Mid(nIndex1 + 2)); This can also be done without using CString .
"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 never did properly read this chapter. With a lot of functions you are able to pass more than one paramater in the form of a xor. For example when setting a window style: WS_CHILD | WS_BORDER
If I was to make a function for which I could pass the same form of argument, how do you break them apart again?
I would like to make a function which can enable/disable more than one toolbar at a time. ie.
enable_button(ID_BUTTON1 | ID_BUTTON2);
within the function I would check the button id and send the approprate button a message.
SendMessage(hToolBar,TB_ENABLEBUTTON,ID_BUTTON?,FALSE);
So how do I find out which button id's were passed?
|
|
|
|
|
They are using bitwise OR to combine flags. A 32-bit integer would have 32 bits to tell them apart. You would assign values to the flags in powers of 2.
#define ID_BUTTON1 0x0001
#define ID_BUTTON2 0x0002 // ( 1 << 1 )
#define ID_BUTTON3 0x0004 // ( 1 << 2 )
#define ID_BUTTON4 0x0008 // ( 1 << 3 )
As you can see, there is a limited number of flags you can have (32 in this case).
To tell them apart you would do something like this
bool bButton1 = ((nFlags & ID_BUTTON1) == ID_BUTTON1);
|
|
|
|
|
|
Hello,
I'm looking for a way to capture the sound from the microphone in real time, modify it by applying an effect and output it back to the microphone stream so that other applications which might be recording from the microphone would receive the modified audio. Does anyone have any ideas on how to approach this task?
Thanks.
|
|
|
|
|
As far as I know the microphone is not a shared resource in Windows. That means that an application that needs to use the microphone input would have to get exclusive ownership of that resource. That being said, in the user mode, only one application may have access to the microphone at a time. Also I don't think that user mode applications are given permission to modify the input buffer (the memory arrea allocated to store data from the microphone input).
To cut to the chace, my opinion is that for the type of functionality you seek, you need to write a Kernel Mode application (a virtual driver) that hooks into the sound driver and intercepts writes to the input buffer and applies whatever effects you need to apply, then let the user mode applications "get" their chance at the mic input buffer.
www.muzikstor.com
|
|
|
|
|
Thanks for pointing me in the right direction. I'll read some articles on driver development now (I found many great ones on this web-site) because I've never developed drivers before.
|
|
|
|
|
I have decided to change much of my code from C string (char *) to the C++ style string. So far I have noticed that they are pretty easy to use, and much faster when it comes to searching for sub strings, converting string (BSTR to string).
Now a lot of functions in C++ expect C style strings, this is no problem when using c_str(), but what about those functions that would fill a string? c_str() returns a const pointer, this cannot be changed. For example
SendMessage(hwnd,WM_GETTEXT,0,buffer);
normally the buffer would be filled with the text, how do you make this work with the string class?
|
|
|
|
|
I'm not sure if there is any portable way of doing this. The reason is that all of the strings characters need not actually be sequentially stored in all implementations. For example an implementation may use a deque like structure to avoid having to copy the entire contents of the string across to a new buffer when the string length exceeds its capacity. I think you'll have to read into a normal char array then assign to a string.
Steve
|
|
|
|
|
I figured as much, its a shame, these basic_strings are very adaptable, you can do just about anything with them except send them to a frequently used function.
Thanks for the reply anyway
|
|
|
|
|
I tend to use a std::vector for things like WM_GETTEXT, and then copy this to a std::string when I am done.
The Rob Blog Google Talk: robert.caldecott
|
|
|
|
|
If you use a std::vector make sure it has enough space allocated either by using the appropriate constructor or the reserve function. i.e.
typedef std::vector<char> CharVec;
CharVec chars(MAX_PATH);
PathCanonicalize(&chars[0], pPathToCanonicalize);
chars.reserve(MAX_PATH);
PathCanonicalize(&chars[0], pPathToCanonicalize);
Steve
|
|
|
|
|
Most of the C++ string classes will include a member function that will return a pointer to a simple character buffer of a specified length. You pass that to the function, and then release the buffer afterward.
I use the MFC CString class myself, which has member functions GetBufferSetLength() and ReleaseBuffer() for this purpose.
I would imagine the STL string class has something like this.
Software Zen: delete this;
|
|
|
|
|
I have a button with BS_CHECKBOX style and text.
I want to center the checkbox with my dialog so
I need to get the "real" width of the control
(Checkbox + gap + text = full width).
I know how to get the width of the text part
but how do I get the width and height of the
checkbox itself?
I looked at GetSystemMetrics and SystemParametersInfo
but didn't find any. Any ideas where to look at?
The width of the gap between is also needed.
I need a plain WinAPI solution that works on all versions
of Windows (not XP only).
Thanks in advance, Sebastian
-------------------------------------------
My website: http://www.hartwork.org
-- modified at 1:03 Sunday 5th March, 2006
|
|
|
|
|
More searching taught me that SM_CXMENUCHECK and
SM_CXMENUSIZE seem to be what I was looking for.
So my new problem is how do I tellGetTextExtentPoint32
to work with the new font and not the default one.
Here's my code:
const TCHAR * const szNeverAgain = TEXT( "Do not ask again" );
SendMessage( hNeverAgain, WM_SETFONT, ( WPARAM )GetStockObject( DEFAULT_GUI_FONT ), ( LPARAM )TRUE );
const HDC hdc = GetDC( hNeverAgain );
SIZE size;
GetTextExtentPoint32( hdc, szNeverAgain, _tcslen( szNeverAgain ), &size );
ReleaseDC( hNeverAgain, hdc );
size.cx is always the width for the old font.
I need the new one - any ideas?
-------------------------------------------
My website: http://www.hartwork.org
|
|
|
|
|
Select a font into the DC before calling GetTextExtentPoint32 . e.g.
const TCHAR * const szNeverAgain = TEXT( "Do not ask again" );
SendMessage( hNeverAgain, WM_SETFONT, ( WPARAM )GetStockObject( DEFAULT_GUI_FONT ), ( LPARAM )TRUE );
HDC hdc = GetDC( hNeverAgain );
HFONT hOldFont = (HFONT)SelectObject(hdc, hYourFont);
SIZE size;
GetTextExtentPoint32( hdc, szNeverAgain, _tcslen( szNeverAgain ), &size );
SelectObject(hdc, hOldFont);
ReleaseDC( hNeverAgain, hdc );
Steve
|
|
|
|
|
This is it! It works!
I'm so happy - Thank you very much!
Best regards, Sebastian
-------------------------------------------
My website: http://www.hartwork.org
|
|
|
|
|
Btw in case you are the author of SpeedLoad - good work!
-------------------------------------------
My website: http://www.hartwork.org
|
|
|
|
|
Yeah I'm to blame for SpeedLoad. Thanks for your kind words.
Steve
|
|
|
|
|
Create a variable for the check box.
And call GetWindowRect
Mythili
|
|
|
|
|
No. The problem is the width can be much more than
the text in it actually needs. If I want to center
the checkbox I need the width of what the user sees,
not the width of the window rect.
Best regards, Sebastian
-------------------------------------------
My website: http://www.hartwork.org
|
|
|
|
|
What is modal loop?
Thanks in advance.
|
|
|
|
|
Running a message pump means a loop something like the following:
MSG m;
while ( GetMessage(&m, NULL, 0, 0) )
{
DispatchMessage(&m);
}
There are many variations but the code above captures the essence of every message pump.
A modal window is window that has to be dismissed before any other windows in the app can be used. This is normally done by creating a top level owned window, disabling the owner and then running a message loop. This is what people mean when they talk about a modal loop. Note the message pump need not be explicit. For example the DialogBox family of functions run a message pump. It is important to remember that, taking the DialogBox as an example, while the modal dialog is displayed we're inside the DialogBox function and when it returns the modal box has been destroyed.
Steve
|
|
|
|
|
You must be an expert on computer science. I very appreciate your help, thanks a lot.
I'm a beginner
|
|
|
|