Solved

GetDlgItemInt fail when user enter more than 10 digits.

Posted on 2006-11-16
6
1,097 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

734 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