|
Excellent. I just learned something very useful.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I thought I understood this but I am now confused as to the memory allocation. Why new char[2][10] and not just new char[10] ? Isn't p just an array of characters?
The best things in life are not things.
|
|
|
|
|
Take a look at the following examples.
Say I have a function as below -
void fun(char (*p)[10])
{
cout << *p << endl;
} Now you will be able to call it as -
char name[10];
strcpy_c(name, "Hello");
fun(&name); But you will get a compile error if you try something like -
char name[11];
strcpy_c(name, "Hello");
fun(&name); You could have a slightly different version using references -
void fun(char (&r)[10])
{
cout << r << endl;
}
char name[10];
strcpy_c(name, "Hello");
fun(name);
char name2[11];
strcpy_c(name2, "Hello");
fun(name2); So even though the code calling the function looks exactly like it does when using a function accepting a simple character pointer, it is a safe function.
This is exactly how the new safe string functions are implemented.
The advantage here is that you do not need to pass in a second size parameter to the function and the check for the size is done by the compiler at compile time.
But when you allocate memory using new , then it becomes something like -
char (*p)[10] = new char[5][10]; You can now pass this on to a function, but you would need another level of indirection -
void fun(char (**p)[10]){}
fun(&p); Or
void fun(char (*&p)[10]){}
fun(p);
|
|
|
|
|
Thanks, it all begins to make sense now.
The best things in life are not things.
|
|
|
|
|
Please advise.
I want to control microphone gain in my application, however, in wave library there in no such thing as waveInSetVolume.
It looks like I need to learn how to use “mixer” API's.
Is “mixer” API the only way to accomplish this in Windows?
Mixer API seems pretty complex and I do not want to waste time on it to find out it is not the best API to use to control audio input gain.
Any constructive suggestions will be as always appreciated.
Cheers
Vaclav
|
|
|
|
|
Yes the mixer APIs are the worst I've ever worked with, especially since Windows Vista.
Since you're using the old wavexxx APIs you may as well use the mixer APIs.
If you were using other APIs/framework, DirectX (DirectSound) has control. On Vista and later there's also WASAPI and Media Foundation.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello Mark,
do the other API's / frameworks use same goofy terminology to define input device and selected output device? I am having a heck of a time understanding "mixer" "line" terminology and the way "ends" of such line are identified.
Seems like lots of unnecessary work.
I have also "discovered " that device ID in wave and in "mixer" are opposite.
I have two (so far) and they are exactly opposite to identify.
I bet one of them was developed on Northern hemisphere and the other on Southern!
|
|
|
|
|
I have made a program under VS 2010. It doesn't work on XP on other machines than mine. It asks on some DLLs.
What can I do to build a program with VS 2010 that is fully compatible with Windows XP?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
You need to find out which DLLs are required and install them on the other machines. Generally this will be the Win32 or MFC redistributable libraries; see here[^] for further details.
The best things in life are not things.
|
|
|
|
|
Merci
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
One more question:
How can I determine that that Visual Studio 2010 Redistributable Package is installed on a computer?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
I'm not sure of the answer, but this link[^] may help you.
The best things in life are not things.
|
|
|
|
|
You can try to link with the static libraries of MFC, ATL and the C runtime time.
By default it links to the dynamic libraries.
Go to Project -> Properties -> Configuration Properties -> General .
If you're using MFC, change Use of MFC from Use MFC in a Shared DLL to Use MFC in a Static Library .
If you're using ATL, change Use of ATL from Dynamic Link to ATL to Static Link to ATL .
Finally go to Project -> Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library .
Change /MDd to /MTd (Debug mode) or /MD to /MT (Release mode).
|
|
|
|
|
I know this is not my thread, but I have to ask this...
Last time I checked this out, I walked away thinking I could not do this and utilize MFC extension librairies. Is this still the case?
Not saying this would impact the OP's project but if this is still a limitation, it might be worth mentioning.
|
|
|
|
|
Thank you both
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
modified on Sunday, July 17, 2011 11:34 PM
|
|
|
|
|
I am using VS2003. I need to implement hover effect on a button. I tried with VS2008 using owner draw button and its working fine.
But VS2003 do not recognize below messages:
ON_WM_MOUSEHOVER()
ON_WM_MOUSELEAVE()
Without these messages how to implement hover effect over a button. please suggest...
|
|
|
|
|
|
That is fine but how call WM_MOUSELEAVE so that I will get to know about mouse is leaving the area.
|
|
|
|
|
Did you look at the example in the link?
|
|
|
|
|
Yes the example also says about WM_MOUSELEAVE event.
Please you also have a look and suggest some alternate...
|
|
|
|
|
If you're asking how to do this in MFC, you must use the ON_MESSAGE macro -
ON_MESSAGE( WM_MOUSELEAVE,OnMouseLeave)
ON_MESSAGE( WM_MOUSEHOVER,OnMouseHover)
|
|
|
|
|
I know how to use, I have implement the hover effect using VS 2008 but the above said messages are not supported by VS2003.
Can suggest me how to do same task in VS2003
|
|
|
|
|
Thanks superman, Its done.
Thanks for help
|
|
|
|
|
Hi
I am opening my VC++6.0 application in VS2008 and getting the above error. what setting needs to be done for this to port this application in VS2008.
Also if I am porting this application to VS2008, will it work in Visual Studio Pro 2010?
SNI
|
|
|
|
|
SNI wrote: I am opening my VC++6.0 application in VS2008 and getting the above error. what
setting needs to be done for this to port this application in VS2008.
Have you tried this?
SNI wrote: Also if I am porting this application to VS2008, will it work in Visual Studio Pro 2010?
Possibly, but much like porting from VS6 to VS2008, you may encounter conversion problems, though they may be fewer.
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|