Solved

GetDlgItemInt fail when user enter more than 10 digits.

Posted on 2006-11-16
6
1,100 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  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 …
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

636 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