|
You can use the SND_ASYNC flag... Look up the documentation for the PlaySound(...) function.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I am already using the SND_ASYNC flag on sndPlaySound function.
It seems that the drawing of the window doesn't happen once the user clicks anything in the window.
|
|
|
|
|
Are you using any other flags? You might not be combining them correctly. I have used the SND_ASYNC flag lots of time and never had it stall anything like you are describing.
You do not have any code that is waiting for the sound to finish, do you?
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
No, I am not using any other flags in the sndPlaySound function. That seems to be working. What i am having a problem with (now that I look at it further), is in my ability to update the window as I need to. I am using a simple 'wait until X amount of time has passed', then I update some values, call Invalidate(); followed by a UpdateWindow().
This all works unless, in the middle of my function where I am drawing the window, the user clicks my window. Then, it doesn't update until the very end of the function and I am not sure why.
I originally thought that maybe having the sound play on another thread would help, but it isn't.
|
|
|
|
|
If your "wait until X amount of time has passed" implementation is a blocking one, like calling Sleep(...) or going into a spin, you will not be able to pump any messages, so you will not get the Paint message to update the screen.
For example, if you are trying to do some cheap animation using old-school-style techniques in a loop, it will not work the same under Windows.
If you are doing the above, you can change your wait to use a Timer message, and then when the timer message fires, you can do your updates.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thank you for the help. Can you point me in the direction of Timer message info? I have never heard of this before.
Thanks again.
Josh
|
|
|
|
|
Look up the WM_TIMER message and the SetTimer(...) function. If you need high-accuracy timers, look up multimedia timers.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
That was it, thank you. I appreciate the help.
|
|
|
|
|
How can i access the exact hardware configuration details using Registry in VC++?Can u please give me with a piece of code?
|
|
|
|
|
V.Natarajan wrote: How can i access the exact hardware configuration details...
Of what?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
For all Hardware devices namely USB ports,D-I/O Ports & COM Ports respectively,which are currently connected to the system.Please explain with code using VC++.
|
|
|
|
|
V.Natarajan wrote: For all Hardware devices namely USB ports...& COM Ports...
Try the Win32_USBController , Win32_USBControllerDevice , Win32_USBHub , and Win32_SerialPortSetting WMI classes.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Okay, so I'm going through some code (off codeproject), which is always interesting, since you see so many different styles. One piece of code had a class within a class, I suppose forcing only one user of the internal class. I don't even know if I'm using the correct terminology, so bear with me.
I come from the school of development where one .cpp and one .h file defines one class. I've seen others have a utility.cpp/h file with multiple classes in it. In the past, this arrangement made it difficult to find things, but I suppose with the advent of code browsers, the issue is more subdued. However, in keeping with the one class / one file appproach, I tend to code my applications centered around dialogs or views or etc... standard mfc stuff. I doubt I'm the only one.
So, in real application development, some of these dialog/view classes can get huge. Due to the nature of my application, I am heavily dialog centric, so most of my application classes inherit from CDialog, etc. The data and processing associated with this dialog processing is heavily coupled to the dialog and usually is not used outside of the dialog. There are some obvious exceptions, and these go off into their own classes. Which brings me to my point....
Some of my dialog classes are large. Managing the data within it would lend itself to a class unto itself for the simple reason of enforcing discipline - the code can easily degrade to spaghetti land. But, I really don't want to break out the data (I guess we're talking business objects in a very distorted way) in a class, viewable across the project, when this class is only going to be used within another class.
How do you deal with this design issue? Inquiring minds want to know
Thanks
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
charlieg wrote: But, I really don't want to break out the data
charlieg wrote: How do you deal with this design issue? Inquiring minds want to know
Model-View-Controller[^]
led mike
|
|
|
|
|
Mike,
Excellent suggestion. but... maybe I'm making a mountain out of a mole hill, but my point is that this document only makes sense within the context of the dialog class. If I break out the 'document' into a separate class, I now have a cpp/h file that just broadcasts "use me".... argh... i know I've read about this before. In my sleep deprived state, the term slipped my brain - I want something like an anonymous class from Java land....
<oops> just read about anonymous C++ classes - not what I Want. I want a class that has only local scope. Hmm.. I am rambling bad
chg
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
Design Patterns (MVC is one of them) simplify things. Don't fight it, just do it.
charlieg wrote: The data and processing associated with this dialog processing is heavily coupled to the dialog
Yeah, tight coupling is "not good". MVC avoids it, get with it or continue to deal with the same coupling issues over and over again. It is an easy call.
led mike
|
|
|
|
|
You could have a class in a separate h+cpp pair, but only #include it in the dialog header. The only instance of this class would then be a member variable inside the dialog class. This would make sure no other code uses it. If you want to go further, the business logic class could have a private constructor, and the dialog class declared as friend - another step towards not letting any other code use the business logic class.
If you're really fond of patterns, you could also make a class factory for the business logic class. See: http://en.wikipedia.org/wiki/Abstract_factory_pattern
Hope this helps.
Denis
|
|
|
|
|
mike & all - thanks for the suggestions.. will look at religiously applying mvc and other patterns.
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
Hello everyone,
As I am new in this area I have few silly questions. What is the difference between Visual C++, Visual Basic, Visual C#?!!! I have been reading and learing about them and so far followed some simple tutorials to create window application (Simple Ones ofcourse! Much more compplicated then "Hello Word" ofcourse!). But I am unable to see much of differences on what is finnaly created.
Although I should say I like Visual C# enviroment Better! But that could be the result of the fact that I started from Visual C#!
Can someone be kind enough to take a moment and lead this confused indivitual?
Thanx so much for your help and have a great day.
Khoramdin
-- modified at 15:48 Tuesday 30th January, 2007
|
|
|
|
|
|
Khoramdin wrote: But I am unable to see much of differences on what is finnaly created.
The point is that there is no difference, they each create an exe which does the same thing, especially in console mode.
VB.NET is probably easiest, C++ is hardest. C++ is the most powerful, and C# provides the best framework for you to start learning, and move to c++ later if you want to.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hello Christian,
After spending hours and playing around with Visual C++, Visual Basic, and Visual C#, I would like to say you are 100% right.
May I ask you if you know of any good book, online tutorial or even Video Tutorial which I comit myself to in order to advance in Visual C# and Visual C++?
Thank you for the help and have a great day.
Khoramdin
|
|
|
|
|
I'm sorry, I really don't know. I worked through C# books from the level of an experienced C++ coder, so I can't really suggest any beginner books, but I would certainly advocate C# over C++ as a starting point.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I am creating a log file and writing to it in a function called WriteToLog. I am creating the file using CreateFile and writing to it using WriteFile. The problem is the filepointer is not moving and always I have only 1 sentence in my logfile, its just overwriting the file and even though I write lot of sentences into my logfile. I just see the last sentence that I wrote to it.
Any help greatly appreciated.
Thanks
Sai.
VOID WriteToLog(LPCTSTR lpszFormat, ...)
{
CString csT1,csT2;
va_list args;
BOOL bRet=FALSE;
HANDLE hFile=NULL;
SYSTEMTIME stTime;
DWORD dwT1=0;
va_start(args, lpszFormat);
csT1.FormatV(lpszFormat,args);
va_end(args);
CSingleLock oLockcopyCounter(&g_oMessageOutputSection);
oLockcopyCounter.Lock();
GetLocalTime(&stTime);
csT2.Format("%s[0x%x] %02d/%02d/%04d %02d:%02d:%02d.%03d: %s", "\r\n",GetCurrentThreadId(),stTime.wMonth, stTime.wDay,
stTime.wYear, stTime.wHour, stTime.wMinute, stTime.wSecond, stTime.wMilliseconds,(PCHAR)(LPCTSTR)csT1);
hFile=CreateFile(g_szLogFileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile!=INVALID_HANDLE_VALUE)
{
if(GetFileSize(hFile,NULL)> (5*1024*1024))
{
CloseHandle(hFile);DeleteFile(g_szLogFileName);
ReportAsEvent(EVENTLOG_INFORMATION_TYPE,0,"Deleting File %s since it croseed 5 MB Limit",g_szLogFileName);
hFile=CreateFile(g_szLogFileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
}
if(hFile!=INVALID_HANDLE_VALUE)
{
WriteFile(hFile,csT2,csT2.GetLength(),&dwT1,NULL);
WriteFile(hFile,csT2,csT2.GetLength(),&dwT1,NULL);
CloseHandle(hFile);
}
else
ReportAsEvent(EVENTLOG_ERROR_TYPE,0,"Creating File %s FAILED. Error %d",g_szLogFileName,GetLastError());
}
oLockcopyCounter.Unlock();
}
|
|
|
|
|