|
excuse me, 30+? you mean 300k dollars per year?
I'm from China, work in Beijing.
|
|
|
|
|
300K / year? lol, no. I mean over 30 years of experience.
Although if you start working for yourself, you might get there and more.
Charlie Gilley
<italic>You're going to tell me what I want to know, or I'm going to beat you to death in your own house.
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
wow, over 30+ years experience. it's almost impossible to find such a person in China, we have fall behind for a long time. are you a manger?
|
|
|
|
|
I was at one time. Work for myself now as an independent business.
Charlie Gilley
<italic>You're going to tell me what I want to know, or I'm going to beat you to death in your own house.
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Maybe you could consider developing with QT?
You write one C++ code that you can compile for all major platforms ...
|
|
|
|
|
|
Dear all;
I wanna implement a application.
1.play sound from buzzer on motherboard in win xp, win 7, win 8.
2.play wav from sound card in win xp, win 7, win 8.
The function 2 is OK, but the function 1 failed.
(A)use Beep function
i. works on win xp.
ii. failed on win 7, the sound just play from the sound card.
iii. failed on win 8, the sound just play from the sound card.
(B)use MessageBeep function
i. Did not test on win xp.
ii.failed on win 7, the sound just play from the sound card.
iii.Did not test on win 8.
Somebody says the Beep.sys was different between win xp and win 7. I don't want to replace the Beep.sys on win 7.
How can I implement this application?
Thanks for your help. Victor
|
|
|
|
|
See the Beep function[^] in the MSDN. It describes why the sound is generated by the sound card with Windows 7 and later. Modern PC systems did not have the timer chip to generate the sound for the internal speaker. Without the timer chip, there is no need for an internal speaker. Some system manufacturers has therefore added a buzzer to their systems. But this is not true for all systems.
So you should use the MessageBeep() function which decides how to play the sound. Your application may also check for the Windows version and use the Beep() function whith XP. But you can not rely on the existance of an internal speaker or buzzer.
|
|
|
|
|
But you can not rely on the existance of an internal speaker or buzzer
I guess that every PC has something that buzz when he had no RAM inserted in he's RAM slot ... or not ?
|
|
|
|
|
You are probably right about the buzzer.
|
|
|
|
|
Dear Jochen:
My computer install two operation system, win xp and win 7
use MessageBeep()
1.XP-Did not test.
2.Win 7- The sound play from sound card, not buzzer.
use Beep()
1.XP-The sound from buzzer.
2.Win 7- The sound play from sound card, not buzzer.
So I ensure the buzzer exist.
Anything else method?
Thank for your help, Victor
|
|
|
|
|
The simplest solution to use the buzzer/speaker with XP and the soundcard with Vista and later is:
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion >= 6)
::MessageBeep(-1);
else
::Beep(1000, 1000);
If you want to use the buzzer with Windows Vista and later, you must replace the beep.sys driver (which is a bad option). There may be alternatives by accessing the buzzer by low level code. But these will probably not work with 64-bit Windows versions.
If have found BEEPx at http://www.waldbauer.com/tmp/reference.php[^].
|
|
|
|
|
IIRC, Beep is synchronous and MessageBeep is asynchronous.
MessageBeep is the recommended way to go.
To play a real WAV file, you could use the PlaySound[^] function.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
Dear «_Superman_»:
I want to play sound from buzzer on computer, not from sound card.
Thank for your help, Victor.
|
|
|
|
|
I really need some advice with this „problem“.
I am rebuilding a class and according to the original its function is to act as „COM lookalike”Basically y a callback for DirectShow frame capture.
The original uses global variables and there is the “problem”.
No matter what I do the linker will complain about multiple definitions, but only on some variables.
I have made sure the variables are unique and compiled only once, same as the header file, but it does not help.
Here is the code:
#ifndef _CALLBACK_GLOBALS
#define _CALLBACK_GLOBALS
#pragma message( "Compiling " __FILE__ )
#pragma message( "Last modified on " __TIMESTAMP__ )
BOOL g_bOneShot_CB = FALSE;
DWORD g_dwGraphRegister_CB=0; // For running object table
HWND g_hwnd_CB;
// Structures
typedef struct _callbackinfo_CB
{
double dblSampleTime;
long lBufferSize;
BYTE *pBuffer;
BITMAPINFOHEADER bih;
}CALLBACKINFO_CB;
CALLBACKINFO_CB callback; // = {0};
#endif
And here is a small sample of linker errors:
_AVIFrame.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_AVIFrame.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_Blob.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_Blob.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_BlobTracker.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_BlobTracker.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_ChildFrame_Tab.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_ChildFrame_Tab.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_DocManager.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_DocManager.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_DrawBitmap.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
And here is sample usage
STDMETHODIMP BufferCB( double dblSampleTime, BYTE * pBuffer, long lBufferSize )
{
if( !g_bOneShot_CB )
return 0;
// Since we can't access Windows API functions in this callback, just
// copy the bitmap data to a global structure for later reference.
callback.dblSampleTime = dblSampleTime;
callback.lBufferSize = lBufferSize;
PS I did change the BOOL to bool and the linker error now reads “bool g_bOneShot_CB”...
Any hint how to fix this would be appreciated.
Cheers
Vaclav
|
|
|
|
|
Declare the global variables in the .h file like:
extern BOOL g_bOneShot_CB;
extern DWORD g_dwGraphRegister;
and then in the corresponding .cpp file, define them like:
g_bOneShot_CB = FALSE;
g_dwGraphRegister_CB = 0;
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thanks David,
but I just found my stupid "problem". Or better yet, stupid found the problem!
THe orignal has two classes in one cpp file, I really do not understand why people do that - it just makes things convoluted and does not save anything.
I had the globals in my header file - mistake #1. After fixin that I had the header file in StdAfx and than BEFORE the globals - mistake #2 and #3.
Now both compiler and linker are OK.
Not the best solution, but now I can code!
Cheers
Vaclav
|
|
|
|
|
I use a CMapStringToString object to store some string key-value pairs, the string are read from a Unicode text file.
a.text like the following:
4001 English //space is a TAB key space
4002 German
4003 Chinese
4004 Russia
then I read the text file to a CString strLine, use
str1 = strLine.Tokenize(TEXT("\t"),tokenPos); to get token;
str2 = strLine.Tokenize(TEXT("\t"),tokenPos);
I set breakpoint, I can read the token is right,i.e. str1 = 4001/4002/4003/4004; str2 = English/German/Chinese/Russia every loop.
In the loop, I use :
mStrMap.SetAt(str1,str2);
and after loop;
mStrMap.Lookup(_T("4001"),tstStr);
mStrMap.Lookup(_T("4002"),tstStr);
mStrMap.Lookup(_T("4003"),tstStr);
mStrMap.Lookup(_T("4004"),tstStr);
The weird thing is , 4002/4003/4004 key, I got right value:
German/Chinese/Russia
but for 4001, I got an empty string;
I thought maybe it is oxFEFF (unicode BOM), so before the loop to readline circularly, I first read BOM so as to move the file pointer back.
But still, for 4001, I got an empty string.
Don't know why this happened.
modified 5-Mar-14 15:12pm.
|
|
|
|
|
You need to show the exact code. And please use <pre> tags around the code blocks so it is more readable thus:
mStrMap.Lookup(_T("4001"),tstStr);
mStrMap.Lookup(_T("4002"),tstStr);
mStrMap.Lookup(_T("4003"),tstStr);
mStrMap.Lookup(_T("4004"),tstStr);
You can automate that by selecting all the lines of code in the editor and using the code button at the top.
|
|
|
|
|
Sorry, it's my fault too. I read BOM, forgot to change the key string.
|
|
|
|
|
Please read the pseudo code as follows:
class A
{
CMap myMap;
A() {
myMap.InitHashTable(857);
}
};
void test(void)
{
A *pa = new A();
}
My question is, myMap member in A class is in Heap or Stack?
is destructor of A class need to delete myMap object expressly?
|
|
|
|
|
The actual memeory used by the Map is allocated internally and dynamically, so it will be on the Heap. You may need to delete the map in your destructor, it depends on the lifetime of your object.
|
|
|
|
|
So, the myMap memory allocation is dominated by it's container class A, right?
for pseudo code like the following:
void test() {
CMap myMap;
}
then I dont need to delete myMap expressly, right?myMap should be in function stack.
|
|
|
|
|
That is correct, as far as I recall; MFC classes clean up after themselves.
|
|
|
|
|
I try to use delete myMap, IDE shows cannot convert from 'CMap' to 'Void*'.
|
|
|
|