|
Hello!
You cannot call the 'GetDocument()' function of a view before you call 'CRecordView::OnInitialUpdate()'. Your program crashes because GetDocument() does not know what to return.
Let me quickly explain. The CRecordView::OnInitialUpdate function hooks your view into the document, so that you can always retreive the associated document with GetDocument(). If you try and call GetDocument() before that, it will probably return NULL, giving you an 'Unhandled exception' (trying to access something in a NULL pointer).
So, you code should look something like this (minus the comments, of course, which just explain what I'm doing):
void CMgen1View::OnInitialUpdate()
{
CRecordView::OnInitialUpdate();
m_pSet = GetDocument()->m_mgen1Set;
LoadListbox();
}
Hope that helps!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hi All,
Can anyone tell me what should be done to provide the resize option to user for modeless dialog
Thanks in advance
Uday
|
|
|
|
|
|
I'm trying to enumerate all the different formats of a specific driver but acmFormatEnum keeps returning MMSYSERR_INVALPARAM (At least one parameter is invalid.). Anyone have an example of how to do this? Here's my code (id is a valid driver identifier of a driver):
ACMFORMATTAGDETAILS acmTagDetails;
<br>
void StartEnum()
{
HACMDRIVER hAcm;
acmDriverOpen(&hAcm, id, 0);
acmTagDetails.cbStruct = sizeof(ACMFORMATTAGDETAILS);
acmFormatTagEnum(hAcm, &acmTagDetails, acmTagCallback, NULL, 0);
acmDriverClose(hAcm, 0);
}
<br>
BOOL WINAPI acmTagCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd, DWORD dwInstance,DWORD fdwSupport)
{
ACMFORMATDETAILS acmFormat;
HACMDRIVER hAcm;
memset(&acmFormat, 0, sizeof acmFormat);
acmFormat.cbStruct = sizeof(ACMFORMATDETAILS);
acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &acmFormat.cbwfx);
acmFormat.pwfx = (WAVEFORMATEX *)malloc(acmFormat.cbwfx);
acmDriverOpen(&hAcm, hadid, 0);
acmFormatEnum(hAcm, &acmFormat, formatCallback, NULL, ACM_FORMATENUMF_WFORMATTAG);
acmDriverClose(hAcm, 0);
return TRUE;
}
<br>
BOOL WINAPI formatCallback(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
{
ACMDRIVERDETAILS details;
details.cbStruct = sizeof(details);
acmDriverDetails(hadid, &details, NULL);
SendMessage(GetDlgItem(ghWnd, IDC_FORMATS), LB_INSERTSTRING, 0, (LPARAM)details.szLongName);
return TRUE;
}
Thanks for your help!
-Rune Svendsen
|
|
|
|
|
You have to many members not initialized in acmTagCallback. MSDN says that for ACM_FORMATENUMF_WFORMATTAG , you must initialized dwFormatTag member of the ACMFORMATDETAILS structure must be equal to the wFormatTag member of WAVEFORMATEX. By the way, you need to free the memory you allocate with malloc or you may want to use a local variable : WAVEFORMATEX waveFormat = { 0 } ; and assign it to acmFormat.pwfx = &wafeFormat ; You still need to initialize wafeFormat with the format that you are looking
for. An 8Khz, 8-bit, 1 channel may be your starting point. Sorry if I don't have code to show you right now!
Good luck
VOTD:"5. The Lord loves righteousness and justice;
the Earth is full of his unfailing love. "-Psalm 33:5
|
|
|
|
|
Try to initialize your WAVEFORMATEX struct with this function:
void InitFormat(LPWAVEFORMATEX pwfx, WORD wChannel, DWORD dwSamplesPerSec, WORD wBitsPerSample)
{
_ASSERTE( NULL != pwfx );
pwfx->cbSize = sizeof(WAVEFORMATEX);
pwfx->wFormatTag = WAVE_FORMAT_PCM;
pwfx->nChannels = wChannel;
pwfx->nSamplesPerSec = dwSamplesPerSec;
pwfx->nAvgBytesPerSec = dwSamplesPerSec * wChannel * (wBitsPerSample>>3);
pwfx->wBitsPerSample = wBitsPerSample;
pwfx->nBlockAlign = wChannel * (wBitsPerSample>>3);
}
VOTD:"5 I know that the Lord is great, that our Lord is greater than all gods.
6 The Lord does whatever pleases him, in the heavens and on the earth, in the seas and all their depths."- Psalm 135:5-6
|
|
|
|
|
Something drive me tired and crazy.I want to put ten sting into COleSafeArray.Could someone pleaseeee give me a sample code?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
COleSafeArray saVector;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 10;
saVector.Create(VT_BSTR, 1, rgsabounds);
long index;
_bstr_t val = "Your string";
for(index=0; index<10; index++)
{
saVector.PutElement(index, (const WCHAR*)val);
}
VOTD:"5. The Lord loves righteousness and justice;
the Earth is full of his unfailing love. "-Psalm 33:5
|
|
|
|
|
Hi,
I am looking for a way to convert a double to the char representation, ie. put double, which is eight bytes, to char[8];
Example:
double nDb = 12.34;
char szDb[8];
szdB would hold the character representation of nDb which might look something like:
[0] 0''
[1] 0''
[2] 0''
[3] 0''
[4] 0''
[5] 0''
[6] 51'3'
[7] 64'@'
Thank you.
|
|
|
|
|
try snprintf
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
memcpy(szDb, &nDB, sizeof(double));
or, if you want to save keystrokes
(double & )szDb = nDb;
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
I call a modal dialog to input a number. The var that i added to the class has limits but these don't get checked until the calling (parent) dialog closes. Is there an option that I need to set or do i need to range ckeck on my own?
This is my call:
if(GetNumDlg.DoModal() == IDOK)
{
calleddialog = 0;
m_leftscale = atoi(GetNumDlg.m_numdisplayed);
UpdateData(FALSE);
//This will set the focus to another control to keep this dialog from popping up
//everytime focus returns
//
CEdit* pNextField = (CEdit*)GetDlgItem(IDOK); pNextField->SetFocus();
}
|
|
|
|
|
Can't you map your edit control to int variable with range validation? You can do this in ClassWizard.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
that is where I set the var up and I did use the range checking for it...just doest seem to check it until I try to exit the calling window.\thanks
|
|
|
|
|
I'm not really sure what exactly are you doing. In the code you've posted you have atoi call. This means that your dialog has string variable, not integer one.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
This is where the problem lies. This is a pop up number entry keyboard. I have two vars one is a string and the other is the integer. I use the string to create the number...make any sence?
|
|
|
|
|
Do you have range validation in GetNumDlg?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
calleddialog = 1;
if(GetNumDlg.DoModal() == IDOK)
{
calleddialog = 0;
m_rightscale = atoi(GetNumDlg.m_numdisplayed);
UpdateData(FALSE);
m_rightscale is where the value (int) is placed and returned to the edit box. This var is setup in the wizzard with a range. I'm thinking that I need another var in the getnumdlg to check the range on.
Thanks for the help...
|
|
|
|
|
GetNumDlg.m_numdisplayed seems to be string variable. Can't you just change that to integer with validation?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
It probably could be if I were to do the math to creat the next digit with each key entered. I went the easy route by just putting the key presses into a string. Thus if the user hits a 1, 3, 6 and a 9 I just put it in like 1369, then return it to the edit box as an int (atoi(1369)).
|
|
|
|
|
In the 'numeric' dialog, override DoDataExchange. Use atoi and check the range; if number doesn't satisfy your criteria display message box and call pDX->Fail().
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hello,
I think what Tomasz Sowinski meant is that in the class wizard for the variable attached to the particular CEdit control in your dialog, you can select it to be an "int" or another number type (it defaults to CString). This saves a a world of extra work (like translating user string in to a number).
JennyP
|
|
|
|
|
The problem is I use this dialog in other places where I use different ranges. So I have to check the range after the user presses OK. So I'm creating the number as the user presses keys/buttons on this dialog and displaying it in an edit box so they can see the value. As they keys are pressed I create a string the corresponds to the order pressed. When it is over I return this to the calling dialog to process the number. So because of the way I do this I have no way to call the dialog again if the number is out of range. HMMMM?
I guess I'm just brain dead today. Thanks for the help
|
|
|
|