Solved

GetDlgItemInt fail when user enter more than 10 digits.

Posted on 2006-11-16
6
1,091 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
ID: 17961889
use long
0
 

Author Comment

by:lapucca
ID: 17962011
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
ID: 17962219
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
ID: 17982081
Does that still cause trouble?
0
 

Author Comment

by:lapucca
ID: 18010627
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

776 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