|
Cedric Moonen wrote: Why did you delete your message ? This could be helpfull to somebody else !
Something Wrong here! Is that an error? As Message Header shows you have deleted the message and inside text show that you are arguing with some for Message
"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
|
|
|
|
|
No, I was just replying to the first post which has been deleted (that is why the header is: Re: [Message Deleted] ).
I mean, why delete the posts when you get an answer ? That's a little bit selfish. Now other people are not able to follow the discussion because they just have an answer to a deleted question.
|
|
|
|
|
Cedric Moonen wrote: No, I was just replying to the first post which has been deleted (that is why the header is: Re: [Message Deleted]).
Ohh, My Mistake...
"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
|
|
|
|
|
Hi,
I derived a class from CFileDialog and added a ComboBox manually, in absence of the normal VS dialog editor (as the CFileDialog isn't public). I also add message handling for the ComboBox manually, but I can't make it work.
here's some code.
BEGIN_MESSAGE_MAP(CImageFileDialog, CFileDialog)<br />
ON_CBN_SELCHANGE(IDC_BROWSEBYCOMBO, OnBrowseBySelChanged)<br />
END_MESSAGE_MAP()
The problem is that OnBrowseBySelChanged is never reached.
Is there any blocking of message handling of undocumented MFC classes, and in that case how do I get around it?
Thanx in advance!
Josef Granqvist
Student and Trainee
-- modified at 7:06 Monday 5th December, 2005
|
|
|
|
|
See the OFNKing sample in MSDN
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
Thanx, that was very useful.
A studier of that sample have to change edt1 to cmb13, though. At least I had to, to make it runnable.
Cheers
Josef Granqvist
Swedish student and Indian trainee
|
|
|
|
|
Is there any single function to determine wether a folder is empty in VC++!
Thanks in advance
emmatty
|
|
|
|
|
emmatty wrote: Is there any single function to determine wether a folder is empty in VC++!
AFAIK, there is no such function... I believe you have to make your own.. you can use CFileFind Class to achieve same...
"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
|
|
|
|
|
There is not direct function in VC++(its not VB)
but
u can try finding the size of the folder but that
u can find if its empty or not
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Something like:
bool IsFolderEmpty( LPCTSTR lpszFolder )
{
CFileFind fileFind;
CString strFolder(lpszFolder);
bool bFound,
bEmpty = true;
bFound = fileFind.FindFile(strFolder + _T("*.*"));
while (bFound != FALSE)
{
bFound = fileFind.FindNextFile();
if (! fileFind.IsDots())
{
bEmpty = false;
break;
}
}
return bEmpty;
}
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
hi
i am converting a MFC ,MDI application to unicode.
when i run the program in release version it runs fine but once i set the config to Unicode Release it just crashes at the start itself.(doesn't even show error msg but abruptly stops the execution of the program)
There are no compile time and linker errors.
i kept breakpoints and arrived at the conclusion that the crash occurs at following lines of code in InitInstance().
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
is there too much of difference between release and unicode version??
how to go abt solving that error....
Thanx in advance
|
|
|
|
|
Hi,
Do you call any other functions from InitInstance(). If yes, check whether you are handling any unicode data.
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Is the entry point set to 'wWinMainCRTStartup'? I ended up putting this in builds a long time ago for UNICODE:
#ifdef _UNICODE
#ifdef _AFXDLL
#ifndef _AFXEXT
#ifndef _WINDLL
#ifndef _USRDLL
#ifndef _CONSOLE
#pragma message("Project appears to be an MFC executable, changing entry-point function")
#pragma comment(linker,"/entry:wWinMainCRTStartup")
#endif
#endif
#endif
#endif
#endif
#endif
|
|
|
|
|
Hi,
in my code i have to take astring from edit box, then it should read each and every character in string, and find the decimal number of each ASCII character and ,for this i used the fallowing code but it doesn't worked..
**
UpdateData(TRUE);
int Length = m_strEdit1.GetLength();//m_strEdit1 is member variable of editbox
TRACE( "Stringlength: %i\n", Length );
int i = 0;
int q;
int p;
while( i < Length)
{
char c = m_strEdit1[ i ];
TRACE( "%c ASCII %i hex %x\n", c, c, c );
q=atoi(c);
p=int(c);
++i;
}
*****
can you please help me how to do this..
Thanking you.
sheshidar patnam
|
|
|
|
|
I haven't tested it but shouldn't this work?
int i;<br />
int length = str.GetLength();<br />
int p;<br />
for (i = 0; i < length; i++)<br />
{<br />
p = str[i];<br />
TRACE("%i\n",p);<br />
}
this is this.
|
|
|
|
|
Thx very much my friend..
|
|
|
|
|
Simply:
char c = m_strEdit1[ i ];<br />
int AsciiValue = (int)c;
The atoi function will try to transform a string representing an integer value (for example the string "123456" ) to its integer value (thus to the integer 123456 ). If you want to get the ASCII value of a char, just cast it to an integer because the character IS the ASCII number
|
|
|
|
|
sheshidar wrote: int Length = m_strEdit1.GetLength();//m_strEdit1 is member variable of editbox
TRACE( "Stringlength: %i\n", Length );
int i = 0;
int q;
int p;
while( i < Length)
{
char c = m_strEdit1[ i ];
TRACE( "%c ASCII %i hex %x\n", c, c, c );
q=atoi(c);
p=int(c);
++i;
}
change above code to :-
m_strEdit1.GetLength();
TRACE( "Stringlength: %i\n", Length );<br />
int i = 0;<br />
int q;<br />
int p;<br />
while( i < Length)<br />
{<br />
char c = m_strEdit1[ i ];<br />
TRACE( "%c ASCII %i hex %x\n", c, c, c );<br />
p=int(c)-41;
++i;<br />
}
"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
|
|
|
|
|
Hi, I discovered that PlaySound does return TRUE on Windows XP systems even when the given filename does not exist. So you get a TRUE return value and GetLastError returns 2 (file not found).
However this problem is Windows XP specific for me, on a old Win9x this does not happen? I wonder if this is a known bug ... more code details needed?
/M
-- modified at 6:40 Monday 5th December, 2005
|
|
|
|
|
Here some code to reproduce the problem I described:
#include <mmsystem.h>
void CTestsoundDlg::OnOK()
{
CString sOutput;
CString sFileName = "soundfile.wav";
if(!PlaySound(sFileName, NULL, SND_FILENAME + SND_ASYNC + SND_NODEFAULT))
{
sOutput.Format("Playing sound file '%s' failed... %s (returned %d)",
(LPCSTR)sFileName, GetLastError()==ERROR_SUCCESS?"OK":"ERROR", GetLastError());
} else {
sOutput.Format("Playing sound file '%s' sucessfull... %s (returned %d)",
(LPCSTR)sFileName, GetLastError()==ERROR_SUCCESS?"OK":"ERROR", GetLastError());
}
m_list.AddString(sOutput);
m_list.AddString("");
}
A possible workaround that works for Win9x and WinXP, please comment.
void CTestsoundDlg::OnOK()
{
CString sOutput;
CString sFileName = "soundfile.wav";
SetLastError(ERROR_SUCCESS);
PlaySound(sFileName, NULL, SND_FILENAME + SND_ASYNC + SND_NODEFAULT);
if(GetLastError()!=ERROR_SUCCESS)
{
sOutput.Format("Playing sound file '%s' failed... %s (returned %d)",
(LPCSTR)sFileName, GetLastError()==ERROR_SUCCESS?"OK":"ERROR", GetLastError());
} else {
sOutput.Format("Playing sound file '%s' sucessfull... %s (returned %d)",
(LPCSTR)sFileName, GetLastError()==ERROR_SUCCESS?"OK":"ERROR", GetLastError());
}
m_list.AddString(sOutput);
m_list.AddString("");
}
|
|
|
|
|
Does sndPlaySound() behave any differently?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I haven't tried. I am now checking the file access myself before calling PlaySound.
|
|
|
|
|
I had some weird problems with sound capture and playback functions on a PC which has Realtek AC97 audio on the motherboard. I solved them by installing the latest (unsigned) audio drivers. The last official (signed) drivers did not fix the problem.
Another thought - MSDN help on PlaySound says "If it cannot find the specified sound, PlaySound uses the default system event sound entry instead. If the function can find neither the system default entry nor the default sound, it makes no sound and returns FALSE." So if the default sound exists, you will not get a FALSE return even if the sound file does not exist.
And another thought - are you sure the GetLastError() value of 2 is a result of the PlaySound function? MSDN help on GetLastError says "If the function is not documented to set the last-error code, the value returned by this function is simply the most recent last-error code to have been set; some functions set the last-error code to 0 on success and others do not." And PlaySound's MSDN documentation does not say anything about error codes, so . . .
You could try GetLastError() before and after PlaySound(), to see if PlaySound is setting the last error code to 2, or if this is left over from some previous error.
|
|
|
|
|
Thanks for the feedbacks!
MSDN is a bit ambigous here? Should it return TRUE or FALSE when no sound is played, I interpreted that TRUE indicates a sound is played and could be dead wrong.
About GetLastError, I am setting it to 0 (ERROR_SUCESS) before calling the API function... please see code snippet I posted. This way I make sure that an error code indicates an error from PlaySound() and not from a previous API call. As you said the PlaySound documentation doesn't say anything about setting error code on sucess. Well, the code snippet I posted looks like a dirty hack and I decided to test file access before calling PlaySound()...
...here my new (pseudo) code:
<br />
MyFileClass file;<br />
if(file.open(sFileName)) <br />
PlaySoundFromFile(sFileName);<br />
else<br />
PlaySoundFromResource();<br />
Cheers, Moak
|
|
|
|