Solved

GetDlgItemInt fail when user enter more than 10 digits.

Posted on 2006-11-16
6
1,088 Views
Last Modified: 2008-01-09
I'm using vs2005 but only win32 libraries.

I have a IEdBoxEditor control.  If I enter more than 10 digits of interger number then my code below would fail to get the data.  success is return as 0.  How can correct this problem so there is no limit to the digits entered?  Thanks.

      intRet = (int)GetDlgItemInt(hwndDialog,IDC_INDEPENDENT_ENTRY_ID,&success, TRUE);
0
Comment
Question by:lapucca
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:Raymun
Comment Utility
use long
0
 

Author Comment

by:lapucca
Comment Utility
Tried it but it still doesn't work.  

longRet = (long)GetDlgItemInt(hwndDialog,IDC_INDEPENDENT_ENTRY_ID,&success, TRUE);

Thanks.
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
Comment Utility
That won't work since you still cast an int to a long, which leave the int limitations. Get that input as a string and convert it, e.g.

#include <stdlib.h>

//...

char acText [255];
char pcCnvEnd;
GetDlgItemText(hwndDialog,IDC_INDEPENDENT_ENTRY_ID,acText, sizeof(acText));

longRet = strtol(acText,&pcCnvEnd,10);

if (NULL == *pcCnvEnd) {

  // conversion successful, it is a valid integer value
}


0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Does that still cause trouble?
0
 

Author Comment

by:lapucca
Comment Utility
Sorry jkr, I haven't tried it.  I will when I return to work on Monday and will let you know.  Thanks.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now