|
I am working with an MFC Dialog Application built with VS 2010
My application uses CPropertySheet with multiple CPropertyPage's and on one of them I am using a CMFCPropertyGridCtrl. The Dialog associated with that page handles PreTranslateMessage's.
When running this code on a Windows 7 Touch Screen computer, I get the following exception in the PreTranslateMessage handling a WM_MOUSEDOWN for the CMFCPropertyGridCtrl which eventually calls IsDialogMessaag():
mfc100ud.dll!ATL::IAccessibleProxyImpl<ATL::CAccessibleProxy>::get_accParent(IDispatch * * ppdispParent) Line 69 C++
// Delegate to standard helper?
HRESULT CWnd::get_accParent(IDispatch **ppdispParent)
{
ASSERT(m_pStdObject != NULL);
return m_pStdObject->get_accParent(ppdispParent);
}
The problem is that ppdispParent points to a NULL.
I have no idea what should be done to fix this???
Can anyone help explain this?
|
|
|
|
|
Start by posting a stack trace. Always post a stack trace when reporting a crash.
Steve
|
|
|
|
|
I've found the solution to this problem.
It appears to be related to the HTML control issue discussed in:
http://support.microsoft.com/kb/954251/de
I added the following WM_DESTROY handler to my CMFCPropertyGridCtrl.
void CPropGridCtrl::OnDestroy()
{
if ( NULL != m_pStdObject ) {
m_pStdObject->Release();
m_pStdObject = NULL;
}
CMFCPropertyGridCtrl::OnDestroy();
}
When I run with this, I don't see any crashes, but without it I get them so looks like this is the magic bullet.
|
|
|
|
|
The Internet comes through with the goods again.
Steve
|
|
|
|
|
I had the same problem using a CMFCPropertyGridCtrl in a CPropertyPage with VS2012 (without Touch Screen).
Using the resouce in a CDialog is no problem, but when used in a CpropertyPage,the page calls OnDestroy as soon as it should be initialized.
The Solution was, dont include the CMFCPropertyGridCtrl aus a resource control and dynamically create it after the InitDialog of the CProperyPage is called.
CMFCPropertyGridCtrl * pctrlPropertyGrid = new CMFCPropertyGridCtrl();
if (pctrlPropertyGrid)
{
CRect rect;
GetWindowRect(&rect);
ScreenToClient(&rect);
rect.DeflateRect(5, 10, 5, 10);
pctrlPropertyGrid->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, rect, this, IDC_MFCPROPERTYGRID1);
...
}
|
|
|
|
|
I am student, taking C programming now.
I have assignment to write function to check if inputed data is numbers. if not - it should write that, and ask to enter number again.
I wrote code, to write error message, but dont know how to make program to work on next input.. should I call the Main function again ?
int main()
{
double hours; //hours worked in a week
double payrate; // hourly salary
double grosspay; //total weekly payment
int k; //number of values read
printf ("Enter number of hours, and hourly pay (or press 0 to exit) \n");
while ((k = scanf ("%lf%lf", &hours, &payrate))==2)
{
if (isdigit(hours) !=0)
return hours;
else
printf ("You entered invalid data, please enter number of hours \n");
if (isdigit(payrate) !=0)
return payrate;
else
printf ("You entered invalid data, please enter payrate \n");
if (hours==0 || payrate==0)
{
printf ("Good Bye. \n\n");
system("PAUSE");
return 0;
}
double grosspay;
grosspay = calculateGrossPay(hours, payrate);
printf ("Hours worked: %.2f\n", hours);
printf ("Hourly Rate: %.2f\n\n", payrate);
printf ("Your weekly payment is: $ %.2f \n\n\n", grosspay);
|
|
|
|
|
You cannot use a double parameter as input to the isdigit() [^] function. You should read your numbers in as strings and then apply isdigit() to each character, using a loop. Rather than having all your code in the main() function, you may want to think about writing a helper function that will input the string, validate it and return the converted value.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
i dont really know how to do that yet... Ok, i will try..
is there a general format of that function somewhere?
|
|
|
|
|
Mikerush7 wrote: is there a general format of that function somewhere? Assuming you mean isdigit() , I put the link in my previous message.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Mikerush7 wrote: while ((k = scanf ("%lf%lf", &hours, &payrate))==2)
If scanf succeeds then you need no other check.
Mikerush7 wrote: should I call the Main function again
No. You may call scanf (if you are allowed to use it) many times inside your main function.
Veni, vidi, vici.
|
|
|
|
|
Mikerush7 wrote: while ((k = scanf ("%lf%lf", &hours, &payrate))==2) Without a full understanding of assignments and expressions, mixing the two in one statement is highly discouraged.
Mikerush7 wrote: return hours; While I'm not sure who you'd be returning hours worked to or why, the compiler should have at least warned you about loss of data.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
DavidCrow wrote: the compiler should have at least warned you Given the number of syntax errors elsewhere I don't think a compiler has ever seen this sample.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
thank you everybody for help. I will keep working on it. my teacher is not helping, so I am on my own..
|
|
|
|
|
Build your logic based on the following example.
int main( )
{
char n ;
int no = 0 ;
printf("Enter a no " );
while( (n = (char)getche( )) != '\r') //Check for enter key
{
if( n >= '0' && n <= '9' )
{
n = n - 48 ;
no = (no * 10) + n ;
}
else{
printf("\nInvalid. ");
}
}
printf("\n %d " , no ) ;
return 0 ;
}
|
|
|
|
|
i,m astuedent in university ,and my doctor want from every
student aproject ,and i want code to make from that (requirement,design,and testing)
please send me code by c++ language such as about
how identification digit system works
and welcome
eman
|
|
|
|
|
I think what your teacher wants is for you to develop the project yourself.
Pick a topic.
Read up on it. (Google is a good place to start.)
Get working on it.
If you have some specific problem with some detail, come back here and ask a question.
We are not in the business of writing your project for you.
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Ok eman, You ask this question twice. You cant have a project asking online. No one will help you, no one will even suggest you a project.
Help yourself.
I wish I could believe there is an after life.
|
|
|
|
|
emanalshboul wrote: ...my doctor want from every student...
emanalshboul wrote: ...please send me code... What do you think your "doctor" would say if you turned in someone else's code?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
DavidCrow wrote: What do you think your "doctor" would say
"Young man, you are suffering from a virus".
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
When I am designing a dialog box with static text boxes to display numbers can I initialize control variables as arrays through the wizard?
As an example, say I am collecting information in 8 channels and would like to display this information in a 8 separate text boxes. I want to store the information in the variable int m_chan[8] but I don't see the array option in the 'Add Variable...' in VS2010.
|
|
|
|
|
The answer is "No you cannot". But you can apply various method to achieve that simpley
You can remind in your two variable your first id and last id, if they are incremental. on various occasion we have to create more than one static object, dynamically.
I wish I could believe there is an after life.
|
|
|
|
|
The Add Variable wizard does not support what you want to do.
However, you can add the variables manually to get at what you're trying to do.
For the first text box, right click and select Add Variable .
Then select the datatype as int and enter the name of the variable as m_chan .
After this, open the dialog header file and change the member variable from int m_chan; to int m_chan[8]; .
Now open the dialog source file and make the following changes -
At the dialog constructor remove the line , m_chan(0) .
In the DoDataExchange function, remove the line DDX_Text(pDX, IDC_EDIT1, m_chan); and add the following lines -
DDX_Text(pDX, IDC_EDIT1, m_chan[0]);
DDX_Text(pDX, IDC_EDIT2, m_chan[1]);
DDX_Text(pDX, IDC_EDIT3, m_chan[2]);
DDX_Text(pDX, IDC_EDIT4, m_chan[3]);
DDX_Text(pDX, IDC_EDIT5, m_chan[4]);
DDX_Text(pDX, IDC_EDIT6, m_chan[5]);
DDX_Text(pDX, IDC_EDIT7, m_chan[6]);
DDX_Text(pDX, IDC_EDIT8, m_chan[7]);
Here, replace the IDs of the edit boxes to the appropriate IDs.
|
|
|
|
|
The wizard is limited; you should get used to skip the wizard. Many times it's even faster to add something to your code, than using the wizard. What you want is possible (as shown already), but not with the wizard.
|
|
|
|
|
how do i go abt starting creating a client and server program will really appreciate a the help than
|
|
|
|
|
Start here.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|