|
Please use the code block button when pasting code. It will make it readable.
The code is roughly what I suggested. But I don't understand what
pTab = new CTab_one(this);
is doing i the contructor? What do you need that page for? And also it has to be deleted in the destructor. I suggest you declare it as CTab_one m_tab; in the class declaration instead.
Also, there is a message for when the active tab is changed as per my last message. Relying on WM_LBUTTONDOWN is not enough, since one can navigate using keyboard.
Was there a question in your last post?
|
|
|
|
|
Hey,
Thx a lot for your replies. I have already solved my problem for redrawing graph it was just small stupid pointer mistake i wasn't passing correct value and yeah thx for TCN_SELCHANGE message i was wondering about it but didn't have time to look at it. I will have to google how that works. Could you let me know how that works like what method it will call. and wat's exact message for that.
Thx again,
cheers from CANADA
|
|
|
|
|
The message description is here[^].
You can create a message handler for it in the resource editor, or using the properties->message window.
|
|
|
|
|
|
Is there anyway i can resize my tabcontrol. like i wana have some feature like when you double click graph inside tab it will resize to mainwindow and when you double click again it will be back as normal window.
I had couple of thoughts like creating frame for tabcontrol and another for rest of the form and then just deal with frame but didn't work.
thx
|
|
|
|
|
Well, you could just resize it using SetWindowPos(), and then temporarily change the parent window to your CMainFrame I suppose.
Another way might be to mimic the behavior of print preview, but without the printing so to speak.
|
|
|
|
|
Yet problem's not solved .
Now you know I have two main class. calculator and tab_one(graphs). now calculator is formview and tab_one is dialog box. now everytime i change something in calculator i will need to redraw graphs in dialog box so i will call invalidate but dialog box will need to get new values from calculator, so i created instance of calculator in tab_one but everytime i call invalidate it creates new calculator and all values goes to default value thus not able to get new values.
any clue ?
|
|
|
|
|
Can't you just set a pointer to your main calculator in your tab_one dialog? Then you can read up-to-date data from the calculator when repainting your dialog.
A better way would be to have a data object, containing all current information in your calculator. This should be owned by the calculator. Then set a pointer to this in your tab_one.
Did that make sense?
|
|
|
|
|
i don't know if that makes sense or not but somehow i managed to solve that problem.
What I did is.
mytabcontrol was inside of calculator
so whenever i changed something i inform that to mytabcontrol ( i have valid m_hWnd since it's inside calculator )
now all tabs are initialized inside tab control so they wont have problem getting m_hWnd for tabone so if they get called they will inform tab_one to redraw it(invalidate) now problems was if i calls tab_one from tabcontrol , then tab_one will be reinitialzed which will read defaults values of calculaotr so graph will be same.
now i have calcparam which holds all values of calculator inside(calculator)
and tab_one was reading those value. but now i created another calcparam inside tab_one and made sure tab_one read that calcparam not the one from calculator and if i change something in calculator.
it does this
memcpy( &m_tabMyTabCtrl.m_tabPages[i]->CalcParam,&CalcParam,sizeof(CALC_PARAMS));
m_tabMyTabCtrl.m_tabPages[i]->Invalidate( );
// m_tabmytabcontrol is instance of mytabcontrol inside gphview and tabpages is instance of tabone defined in mytabcontrol
that's how i got it work.
anyways thx a lot,
cheers from canada.
|
|
|
|
|
mohit`12 wrote: anyways thx a lot,
You're welcome
|
|
|
|
|
if m_hWnd is 0X000000 means that the windows isnt created or yet destroyed.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
okay Hey,
I found out my problem but no solution yet. The reason m_hWnd is getting null because i am trying to update tab_one out side of that class which is mytabcontrol:
This is what happening :
My Tab Control (Holds Tab) Tab_one ( Holds data and on draw graph)
switch tab(tab_current changes) Draws first graph initial graph
if(tab_current changes) OnDraw() is called
tab_one is already initialized
---------> calls method -----------> ongraph1(){changes graph &try to update which should call ondraw again
it wont update because ongraph1() got called by mytabcontrol who doesn't know what m_hWnd is for tab_one if you call updategraph() inside of tab_one it will work and will show value of m_hWnd..but from mytabcontrol NOPE..
so is there anyway i can inform mytabcontrol that tab_one is initialzed and has soem value of m_hWnd and use that value to updategraph.
|
|
|
|
|
you are mixing something that is buggy. Use some pointers to the approbiate objects.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I Know it's buggy and that's y i am here to find solution and solve buggy code.
thx tho.
|
|
|
|
|
we have a saying: "Help yourself and so god will help you".
you got to do your homeworks yourself
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
haha. I think that saying "" does WORK.. I was trying this since last week and finally today i solved it. GOD HELPED ME....It wasn't that easy though. But this is not the end yet..got some more problems to solve. Let the GOD help me for all of them
|
|
|
|
|
In a form, I am having a message map at the Tab-level like below:
ON_NOTIFY_RANGE(DTN_DATETIMECHANGE, DLG_CTRLBASE, DLG_CTRLBASE + DLG_MAXITEMS_CTRL, OnDateTimeChange)
From TabCtrl::OnDateTimeChange(), I have a call to next level DataFormDlg::OnDateTimeChange
TabCtrl::OnDateTimeChange
{
DataFormDlg->OnDateTimeChange;
}
Inside DataFormDlg, I have another message map as below
ON_NOTIFY_RANGE(DTN_DATETIMECHANGE, DLG_CTRLBASE, DLG_CTRLBASE + DLG_MAXITEMS_CTRL, OnDateTimeChange) and the function is
DataFormDlg::OnDateTimeChange ()
{
//body
}
Now when I click at the datepicker control, the DTN_DATETIMECHANGE event is triggering twice. So, the TabCtrl -> DataFormDlg -> OnDateTimeChange() is executing twice.
Could you please help me finding what is going wrong here?
Thanks,
|
|
|
|
|
|
MODIFIED QUESTION
hello guys...I want to play wave audio data but it is not playing properly, plays differently
WAVEFORMATEX _oFormat;
LPWAVEFORMATEX _pFormat = NULL;
HGLOBAL _hWaveData;
PCHAR _pWaveData;
HGLOBAL _hWaveHeader;
LPWAVEHDR _pWaveHeader;
HWAVEOUT _hOutputDevice = NULL;
DWORD _nAlignedBufferSize = 0;
MMRESULT rc = 0;
HANDLE fileHandle = NULL;
DWORD size = 0;
DWORD readBytes = 0;
void* block = NULL;
_pFormat = &_oFormat;
_pFormat->wFormatTag = WAVE_FORMAT_PCM;
_pFormat->nChannels = 1;
_pFormat->nSamplesPerSec = 8000;
_pFormat->wBitsPerSample = 8;
_pFormat->nBlockAlign = 1;
_pFormat->nAvgBytesPerSec = 8000;
_pFormat->cbSize = 0;
_hWaveHeader = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT, (DWORD)sizeof(WAVEHDR));
if(!_hWaveHeader) return false;
_pWaveHeader = (LPWAVEHDR) GlobalLock(_hWaveHeader);
if(!_pWaveHeader) return false;
_hWaveData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, AUDIO_BUFFER_SIZE);
if(!_hWaveData) return false;
_pWaveHeader->lpData = _pWaveData = (LPSTR)GlobalLock(_hWaveData);
rc = waveOutOpen(&_hOutputDevice, WAVE_MAPPER,_pFormat, (DWORD) &waveOutProc, 0, CALLBACK_FUNCTION);
if (rc!=MMSYSERR_NOERROR)
MessageBox(NULL,"Error:","",NULL);
if ((fileHandle = CreateFile("\sounds\\ringout.wav", GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL)) == INVALID_HANDLE_VALUE)
return NULL;
do {
if( (size = GetFileSize(fileHandle,NULL)) == 0)
break;
if ( (block = HeapAlloc(GetProcessHeap(), 0, size)) == NULL)
break;
ReadFile(fileHandle, block, size, &readBytes, NULL);
} while(0);
CloseHandle(fileHandle);
CopyMemory(_pWaveHeader, &block, sizeof(block));
_nAlignedBufferSize = (AUDIO_BUFFER_SIZE - AUDIO_BUFFER_SIZE % _pFormat->nBlockAlign );
_pWaveHeader->dwFlags = 0;
_pWaveHeader->dwBufferLength = _nAlignedBufferSize;
rc = waveOutPrepareHeader(_hOutputDevice, _pWaveHeader, sizeof(WAVEHDR));
rc = waveOutWrite(_hOutputDevice, _pWaveHeader, sizeof(WAVEHDR));
modified on Thursday, August 12, 2010 12:32 PM
|
|
|
|
|
|
overloaded Name wrote: What can be the problem
How should we know? You have not said what the problem is. "Plays differently" and "is not running" don't mean a whole lot.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Could it be the improperly escaped backslash in the path to the file?
"\sounds\\ringout.wav"
|
|
|
|
|
And the other one?
It's time for a new signature.
|
|
|
|
|
|
Niklas Lindquist wrote:
"\sounds\\ringout.wav"
I think perhaps you meant:
"\\sounds\\ringout.wav"
[edit]Sorry, I see what you were trying to point out to the OP.[/edit]
It's time for a new signature.
|
|
|
|