|
Hi everyone,
I'm currently working on an FFT App which gets the Input about the Mic. Once the Mic Buffer is full the Function void void CWaveCtrl::Update(const Fft &FftTransformer) in my Static control is called. Now lets come to the problem. In the Function I can't call GetClientRect() or Invalidate(). I don't know if the problem only exists with those two Functions. This are the Functions i would need The Program always crashes with:
Debug Assertion Failed!
Program: ...\Visual Studio Projects\FFT\Debug\FFT.exe
File: f:\vs70builds\9466\vc\MFCATL\ship\atlmfc\include\afxwin2.inl
Line: 135
Please Help. I have no clue.
MFG
RedDragon2k
|
|
|
|
|
Trace it with single-stepping.
Don't try it, just do it!
|
|
|
|
|
I did and it just seems like the Functiun is unable to get the correct HWND.
I can't be more precioses because when i click retry to debug my system is vveeerrrryyyyy slow 'cause of the bug. But in the Locals Watcher i can see that GetClientRect(rect) return the right Rect Values. Here is the Complete Function:
void CWaveCtrl::Update(const Fft &FftTransformer)
{
CRect rect;
GetClientRect(rect);
int iMaxPoints = min(FftTransformer.Points(),FFT_POINTS * 8);
for(int i=0; i < iMaxPoints; i++)
{
int s = FftTransformer.Tape(i) / 512 + (rect.bottom - 1) / 2;
if (i >= rect.right)
{
Add( i, rect.right - 1, (rect.bottom - 1) / 2);
}
else
{
if ( s < 0 )
Add (i, i, 0);
else if (s >= rect.bottom)
Add (i, i, rect.bottom - 1);
else
Add (i, i, s);
}
}
}
|
|
|
|
|
I'm using this class in my UI thread (which has no dialog, so I needed to make a timer) so that I could fire off 3 different timers. I was wondering is I should wrap the postmessage as well as SetTimer and KillTimer as a critcal sections. My main app will be creating 3 threads that will be creating three timers. Would this help in making sure I did not step on another thread accessing TimerProc at the same time.
Here is the link to the class I'm using.
CWinTimerThread
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Would it hurt anything to give each thread its own timer function?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Well basically each thread is dirived from the CWinThreadTimer class. So it does have it's own timer function. I was under the understanding that the TimerProc used the same memory space regardless of what thread created it. is this not the case.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Just a suggestion, ignore me if I'm totally off base, but why not create a hidden window for the thread that will handle the WM_TIMER message? That way the window's message queue will take care of all those problems.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Good question. While at first i was attempting that, I figured it was more of a hassle dealing with a dialog that was modaless and modal.....blah blah blah. So it was easier too make a timer call....by the way this work great. I'm running three threads with each having 3 timers. That's 9 timers going, and it works great. I just want to make sure that then do not step on each other in memory.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
In this case, there's no need for thread synchronization because there are multiple independent timers. However, synchronization is required if you were to share one timer in multiple threads.
Kuphryn
|
|
|
|
|
So each time I create a thread, I create a new TimerProc that has it's own memory space? So I should just do a critical section around the postmessage?
What happens if I have 200 threads that I'm creating, would I need to protect the TimerProc function then? Or would I have 600 individual TimerProcs?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
|
Hey people
OK, I'm sure a lot of you guys have seen or at least used Microsoft Money. Do any of you have any idea how they did the user interface? It's as if they're using some kind of HTML...but not :P (Does that make any sense :P?)
I'd like to hear any ideas as I'm trying to write a similar application in MFC.
Thanks for any help.
The earth's rotation is caused by penguins running around the south pole.
|
|
|
|
|
I wish i knew, I've often asked this question and the best i can come up with is alot of javascript and mfc htmlview stuff. It's a pretty nice interface, but i never did find an easy way to mimic it.
|
|
|
|
|
GUIs like this can be built using a CDHtmlDialog [^]. For guidelines on inductive user interfaces (like MS Money), see this[^] link.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
What does this declaration mean?
|
|
|
|
|
abc is a pointer to a pointer to a double .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
what about this :
double d1;
double* d2;
double** d3;
double* d4[];
...?????????
you don't have it ? ok, i'll help you, but you will have to study a bit more the C/C++ language.
double d1; declares d1 as a double. (easy, isn't it ?)
double* d2; declares d2 as a double*, that means pointer to double. this is the same as double *d2;,double*d2; and double * d2;
double** d3; declares d3 as a double** (i'm sure you start understanding), that means pointer to double*, that means in fact pointer to pointer to double. you have it now ?
more difficult, but quite the same as the previous one. Let's see this :
double* d4[]; declares d4 as an array of double*, and as you know, arrays are pointers to the first element. Such code declares so a pointer to pointer to double.
see you
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Using MFC for Print and Print Preview, i cannot get it to work with CDC::SelectClipRgn to print in just a specified region. Even Print Preview never clips the output correctly. How could this be? I cannot find any information that would say clipping isn't working in Print and Preview modes, but it's not!!!
Please help me!!!
|
|
|
|
|
It complies and links but shows no output.It is suppose to enlist the application log files.
#include <windows.h>
#include <stdio.h>
void DisplayEntries( )
{
const int BUFFER_SIZE=1000;
HANDLE h;
EVENTLOGRECORD *pevlr;
BYTE bBuffer[BUFFER_SIZE];
DWORD dwRead, dwNeeded, cRecords, dwThisRecord = 0;
// Open the Application event log.
h = OpenEventLog( NULL, // use local computer
"Application"); // source name
if (h == NULL) { printf("yahooo1");}
// ErrorExit("Could not open the Application event log.");
pevlr = (EVENTLOGRECORD *) &bBuffer;
// Opening the event log positions the file pointer for this
// handle at the beginning of the log. Read the records
// sequentially until there are no more.
while (ReadEventLog(h, // event log handle
EVENTLOG_FORWARDS_READ | // reads forward
EVENTLOG_SEQUENTIAL_READ, // sequential read
0, // ignored for sequential reads
pevlr, // pointer to buffer
BUFFER_SIZE, // size of buffer
&dwRead, // number of bytes read
&dwNeeded)) // bytes in next record
{
while (dwRead > 0)
{
// Print the event identifier, type, and source name.
// The source name is just past the end of the
// formal structure.
printf("%02d Event ID: 0x%08X ",
dwThisRecord++, pevlr->EventID);
printf("EventType: %d Source: %s\n",
pevlr->EventType, (LPSTR) ((LPBYTE) pevlr +
sizeof(EVENTLOGRECORD)));
dwRead -= pevlr->Length;
pevlr = (EVENTLOGRECORD *)
((LPBYTE) pevlr + pevlr->Length);
}
pevlr = (EVENTLOGRECORD *) &bBuffer;
}
CloseEventLog(h);
}
int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR l,int n)
{
DisplayEntries();
return 0;
}
|
|
|
|
|
it uses windows.h and stdio.h headers
|
|
|
|
|
brilliant101 wrote:
printf("%02d Event ID: 0x%08X ",
...
int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR l,int n)
These are mutually exclusive statements. WinMain() assumes a GUI application whereas printf() assumes a console application. For testing purposes, I would change WinMain() to be main() instead.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
This is the code from MSDN, using the api SetupDiGetClassDevEx () fuction to retrieve the list of current devices. But this program does not complies.
Please debug the code so that it can enlist all the hardware devices in the computer.
#include<windows.h>
#include<stdio.h>
HDEVINFO DoDeviceEnum( GUID InterfaceClassGuid )
/*
Routine Description:
Retrieves the device information set that contains that contains
the devices of the specified class.
Parameters:
InterfaceClassGuid - The interface class GUID.
Return Value:
If the function succeeds, the return value is a handle to the
device information set.
If the function fails, the return value is zero.
*/
{
HDEVINFO DeviceInfoSet;
HDEVINFO NewDeviceInfoSet;
// Create a device information set that will be the container for
// the device interfaces.
DeviceInfoSet = SetupDiCreateDeviceInfoList(NULL, NULL);
if(DeviceInfoSet == INVALID_HANDLE_VALUE) {
Err = GetLastError();
printf( "SetupDiCreateDeviceInfoList failed: %lx.\n", Err );
return 0;
}
// Retrieve the device information set for the interface class.
//int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR l,int n)
//{
NewDeviceInfoSet = SetupDiGetClassDevsEx( InterfaceClassGuid,
NULL,
NULL,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE,
DeviceInfoSet,
NULL,
NULL
);
if(NewDeviceInfoSet == INVALID_HANDLE_VALUE)
{
Err = GetLastError();
printf( "SetupDiGetClassDevsEx failed: %lx.\n", Err );
return 0;
}
return NewDeviceInfoSet;
|
|
|
|
|
it uses windows.h and stdio.h headers
|
|
|
|
|
brilliant101 wrote:
But this program does not complies.
Why doesn't it? What error(s) are you receiving?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am trying to implement an ATL based .EXE server , with Connection Point Support
I am trying to Call a handler in the client with two variables
BSTR fileName
VARIANT result (intended to be a UINT)
The first variable is successfully passed to the client
while the VARIANT is not getting passed properly . it points to VT_NULL in my client
Code from my CoClass
STDMETHODIMP CMySrvr::OpenModel(BSTR FileName)<br />
{<br />
<br />
_bstr_t str(FileName);<br />
bool res = mgr.OpenModel((string)str);<br />
<br />
VARIANT result ;<br />
result.vt= VT_UINT ;<br />
if(res)<br />
result.uintVal=0x01;<br />
else<br />
result.uintVal=0x00;<br />
<br />
Fire_XmlOpenResponse(FileName,result); <br />
<br />
return S_OK;<br />
}
Here is the IDE generated code for Fire_XmlOpenResponse
HRESULT Fire_XmlOpenResponse(BSTR fileName, VARIANT result)<br />
{<br />
CComVariant varResult;<br />
T* pT = static_cast<T*>(this);<br />
int nConnectionIndex;<br />
CComVariant* pvars = new CComVariant[2];<br />
int nConnections = m_vec.GetSize();<br />
<br />
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)<br />
{<br />
pT->Lock();<br />
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);<br />
pT->Unlock();<br />
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);<br />
if (pDispatch != NULL)<br />
{<br />
VariantClear(&varResult);<br />
pvars[1] = fileName;<br />
pvars[0] = &result;<br />
DISPPARAMS disp = { pvars, NULL, 2, 0 };<br />
pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);<br />
}<br />
}<br />
delete[] pvars;<br />
return varResult.scode;<br />
<br />
} IDL definition of the above
dispinterface _IEACEepromSrvrEvents<br />
{<br />
properties:<br />
methods:<br />
[id(1), helpstring("method Event1")] HRESULT Event1();<br />
[id(2), helpstring("method XmlOpenResponse")] HRESULT XmlOpenResponse([in] BSTR fileName , [in] VARIANT result);<br />
};
Here is my client code
client .h file
static _ATL_FUNC_INFO dataInfo = {CC_STDCALL, VT_EMPTY, 0, 0};<br />
static _ATL_FUNC_INFO xmlOpenInfo = { CC_STDCALL, VT_EMPTY,2,{VT_BSTR , VT_UINT}};<br />
<br />
class CEacEepromClient : public IDispEventImpl<0,CEacEepromClient ,&DIID__IEACEepromSrvrEvents,&LIBID_EEPROMSERVERLib,1,0><br />
{<br />
public:<br />
void Use1();<br />
CEacEepromClient();<br />
virtual ~CEacEepromClient();<br />
<br />
BEGIN_SINK_MAP(CEacEepromClient)<br />
SINK_ENTRY_INFO(0,DIID__IEACEepromSrvrEvents,1,HandlerEvent1,&dataInfo)<br />
SINK_ENTRY_INFO(0,DIID__IEACEepromSrvrEvents,2,HandleXmlFileOpen,&xmlOpenInfo)<br />
END_SINK_MAP()<br />
HRESULT __stdcall HandlerEvent1();<br />
HRESULT __stdcall HandleXmlFileOpen(BSTR fileName , VARIANT result);<br />
protected :<br />
<br />
IEACEepromSrvrPtr m_srvr;<br />
IUnknownPtr iPtr ;<br />
<br />
<br />
};
Handler code in the client.cpp file
STDMETHODIMP CEACEepromSrvr::OpenXmlModel(BSTR xmlFileName)<br />
{<br />
<br />
_bstr_t str(xmlFileName);<br />
bool res = mgr.OpenModel((string)str);<br />
<br />
<br />
VARIANT result ;<br />
result.vt= VT_UINT ;<br />
if(res)<br />
result.uintVal=0x01;<br />
else<br />
result.uintVal=0x00;<br />
<br />
Fire_XmlOpenResponse(xmlFileName,result);<br />
<br />
<br />
return S_OK;<br />
}
Please help
|
|
|
|
|