|
Can you post some relevant code? I'm not clear where and how you
are calling PlaySound() and what OnIdle() has to do with it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am trying to create a game in mfc
in the OnDraw, I am calling ---- PlaySound("c:\\sound.wav",0,SND_FILENAME | SND_ASYNC); -----
the OnIdle is called when there is no mouse or keyboard activity
and with in onidle the invalidate is called for ondraw
--- AfxGetMainWnd()->Invalidate(false); ---
so the draw is called a number of times,
I know that the playsound is called a number of times, sofor I would expect
odd behavior, so I have set the onidle return value to 0, so it is only called after keyboard or mouse interuption has ended as aposed of the call to be continuse
as I mentioned the sound only plays when there is no keyboard or mouse acticvity
what I am after Is a soloution, or a structered method to go about this,
I have looked around on the internet, an d things seem very complcated
this playsound is all I can go about
if you can refer me to any relevant articles, it would very much be a appreciated
simon
|
|
|
|
|
simon alec smith wrote: as I mentioned the sound only plays when there is no keyboard or mouse acticvity
That's the only time you'll get OnIdle() calls!
Ok I understand now, thanks for the explanation.
You may want to look into using a timer, either a regular windows timer
if resolution isn't important, or a multimedia timer for more precise timing.
I think you'll find this will work much better than trying to do periodic stuff
in OnIdle()
Using Timers[^]
Multimedia Timers[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi, for some reason i can only call ON_COMMAND in my main dialog, how can i call it in a child dialog?
Any ideas would be much apreciated!
|
|
|
|
|
How can you call ON_COMMAND? ON_COMMAND is not a function or method AFAIK.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark, I call it via afx_msg void OnAddNewItem(); and ON_COMMAND(ID__ADDITEM, &CItemDlg::OnAddNewItem)
Edit:
the menu item is created via CMenu and if i move ON_COMMAND(ID__ADDITEM, &CItemDlg::OnAddNewItem) to the main dialog it works fine. But i want to know why i cant call it in the child dialog
|
|
|
|
|
You aren't calling anything. You've added a method that will get called when the
window you've added it to receives a WM_COMMAND message corresponding to a
menu item or child window with the id "ID__ADDITEM".
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok, how do i associate the menu to the dialog? The menu opens when right mouse button is pressed and so i dont care to attatch it to the Child Dialogs system menu.
|
|
|
|
|
FredrickNorge wrote: ...how do i associate the menu to the dialog? The menu opens when right mouse button is pressed...
The TrackPopupMenu() API/method takes a window handle/ptr to the window
that should receive the command messages.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks, that made it work
|
|
|
|
|
I will try to write question shortly
struct CEvents
{
virtual HRESULT Method1() = 0;
virtual HRESULT Method2() = 0;
virtual HRESULT Method3() = 0;
};
class A : public CEvents
{
// Implementation of VTBL methods
virtual HRESULT Method1();
virtual HRESULT Method2();
virtual HRESULT Method3();
HRESULT Some();
B *m_B;
};
HRESULT Some()
{
m_b->Initialize( (CEvents*)this );
return S_OK;
}
class B
{
CEvents *m_evs;
HRESULT Initialize( CEvents *evs );
}
HRESULT B::Initialize( CEvents *evs )
{
///////////////////// THIS IS MY QUESTION /////////////////
// This i have trouble... access violation and ect....
// But when i use not pointer to class B as member of A ( B *m_B; )
// there is no any problems - PLEASE, TOLD ME, WHY??????????????
m_evs = evs;
return S_OK;
}
ISQ 469907496
|
|
|
|
|
Are you initialising the m_b member in the constructor of class A?
Habetis bona deum
|
|
|
|
|
|
I don't see anywhere that you actually create any objects.
You have pointers declared but they are uninitialized.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
actually it was shortly sample...
ISQ 469907496
|
|
|
|
|
How should we help you then?
What errors are you getting? On what line(s)? Compile or runtime?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i have write answer for my question above... see third reply...
i am ashamed of myself....
ISQ 469907496
|
|
|
|
|
might be some one is intrested in the answer!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
i'm looking for a c++ program that will read in an ascii file and will output a csv file, is there anyway that this can be done? can anyone help me?
|
|
|
|
|
a CSV file is an ASCII file and both files are text files.
Are you only wanting to put commas between fields ?
In general, when one wants to do something like that, one will read the file in memory, parse each line ( if that is the case ) to extract the different fields (whatever is the separator criteria) and one will print out each field separated by a comma.
Do you know how to read a text file ? and write the file ?
Do you know how to parse a line of text ?
|
|
|
|
|
I need to parse each line based on a criteria I'm not sure how to go about it though, here's what I know:
Head data (zip file of 9.2 mbytes) A 109-slice MRI data set of a
human head. Complete slices are stored consecutively as a 256 x
256 array. Pixels consist of 2 consecutive bytes making one binary
integer. Data taken on the Siemens Magnetom and provided courtesy of
Siemens Medical Systems, Inc., Iselin, NJ.
I need the csv file so that a program called paraview can read it, I just don't know where to start.
I would appreciate any help.
|
|
|
|
|
whats written in your ASCII file!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
It's data for a visualization of a human head, I need to parse each line according to this:
Head data (zip file of 9.2 mbytes) A 109-slice MRI data set of a
human head. Complete slices are stored consecutively as a 256 x
256 array. Pixels consist of 2 consecutive bytes making one binary
integer. Data taken on the Siemens Magnetom and provided courtesy of
Siemens Medical Systems, Inc., Iselin, NJ.
|
|
|
|
|
I'm trying to write a dll for the Microsoft cmak Connection manager administration kit, which we will use for a VPN connection. It's supposed to have this signature:
HRESULT WINAPI function
[IN] HWND hWndParent
[IN] HINSTANCE hinstDll
[IN] LPCSTR pszCommandLine
[IN] DWORD dwReserved
But it still uses the DllMain of my console win32 c++ dll-file. Cmak can only run DLLs synchronously. I want it to run two .exe files after each other. I start them from the DLL. It may not go on establishing the connection until both of them has executed successsfully. It has to stop after starting each .exe. That's why it has to be a DLL. It doesn't stop otherwise. No matter what function name I use in the [Pre-Connect Actions] section of the .cms-file it uses DllMain anyway.
Do you have to export the function names for automation like an ActiveX-DLL?
|
|
|
|
|
Hi, I used the microsoft's example to load a simple HTML file from a stream.It works fine but when I make a second call to the following method it shows a white screen.
for example :
TestPage("a.htm") --> it works
TestPage("b.htm") --> it shows a white screen have only the code.
What's wrong here ?
void CMemHTMLView::TestPage(CString filename)<br />
{<br />
<br />
Navigate2( _T("about:blank"), NULL, NULL, NULL, NULL ); <br />
<br />
LPSTREAM pStream; <br />
HRESULT hr; <br />
HGLOBAL hSource = NULL; <br />
char * source; <br />
<br />
FILE *stream;<br />
long lFileStreamSize;<br />
<br />
<br />
<br />
<br />
<br />
if ( (stream = fopen( filename, "rb" )) == NULL )<br />
{<br />
AfxMessageBox("error");<br />
return;<br />
<br />
}<br />
<br />
fseek (stream , 0 , SEEK_END);<br />
lFileStreamSize = ftell (stream);<br />
rewind (stream);<br />
<br />
<br />
source = (char*) malloc (sizeof(char)*lFileStreamSize);<br />
<br />
fread (source,sizeof( char ) ,lFileStreamSize,stream);<br />
<br />
fclose(stream);<br />
<br />
<br />
<br />
if (hSource) <br />
{ <br />
GlobalFree(hSource); <br />
} <br />
<br />
hSource = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE | GMEM_NODISCARD, strlen(source)+1 ); <br />
<br />
void * p=GlobalLock(hSource); <br />
<br />
memcpy((char *)p, source,lFileStreamSize ); <br />
GlobalUnlock(hSource); <br />
<br />
hr = CreateStreamOnHGlobal(hSource, TRUE, &pStream); <br />
<br />
IDispatch* pHtmlDoc = NULL; <br />
IPersistStreamInit* pPersistStreamInit = NULL; <br />
<br />
pHtmlDoc = this->GetHtmlDocument(); <br />
<br />
hr = pHtmlDoc->QueryInterface( IID_IPersistStreamInit, (void**)&pPersistStreamInit ); <br />
if ( SUCCEEDED(hr) ) <br />
{ <br />
hr = pPersistStreamInit->InitNew(); <br />
if ( SUCCEEDED(hr) ) <br />
{ <br />
hr = pPersistStreamInit->Load(pStream); <br />
} <br />
pPersistStreamInit->Release(); <br />
} <br />
Refresh(); <br />
<br />
free (source);<br />
<br />
}
sdancer75
|
|
|
|