How to verify the size of an editbox item before copying it to a CString ?

Hi all

Here's the code :

/*******************************************/

CString szPassword;

// A test on the text length entered in IDC_EDIT_PASSWORD should be
// implemented here

// If I enter a very big value for the password, the application bugs
// On the following line :
GetDlgItemText(IDC_EDIT_PASSWORD, szPassword);

MessageBox(szPassword, "PASSWORD", MB_OK);

/*******************************************/



Thank you very much if anyone can help ;)
0
9/24/2004 8:50:35 AM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
427 Views

Similar Articles

[PageSpeed] 15

MicroCode2004,

You can set the limit of the text in the resource editor.

Johan Rosengren
Abstrakt Mekanik AB

"__MicroCode2004__@__Hotmail.Com__" <microcode2004@hotmail.com> a �crit dans
le message de news:480bd64a.0409240050.163fe44f@posting.google.com...
> Hi all
>
> Here's the code :
>
> /*******************************************/
>
> CString szPassword;
>
> // A test on the text length entered in IDC_EDIT_PASSWORD should be
> // implemented here
>
> // If I enter a very big value for the password, the application bugs
> // On the following line :
> GetDlgItemText(IDC_EDIT_PASSWORD, szPassword);
>
> MessageBox(szPassword, "PASSWORD", MB_OK);
>
> /*******************************************/
>
>
>
> Thank you very much if anyone can help ;)


0
9/24/2004 9:18:11 AM
try this...
if (GetDlgItem(IDC_EDIT_PASSWORD)->GetWindowTextLength() < 10)
  // ok
else
 // to long ...


"__MicroCode2004__@__Hotmail.Com__" wrote:

> Hi all
> 
> Here's the code :
> 
> /*******************************************/
> 
> CString szPassword;
> 
> // A test on the text length entered in IDC_EDIT_PASSWORD should be
> // implemented here
> 
> // If I enter a very big value for the password, the application bugs
> // On the following line :
> GetDlgItemText(IDC_EDIT_PASSWORD, szPassword);
> 
> MessageBox(szPassword, "PASSWORD", MB_OK);
> 
> /*******************************************/
> 
> 
> 
> Thank you very much if anyone can help ;)
> 
0
condor (3)
9/24/2004 9:19:04 AM
__MicroCode2004__@__Hotmail.Com__ wrote:
> CString szPassword;
>
> // If I enter a very big value for the password, the application bugs
> // On the following line :


What do you mean, "bugs" ?


> GetDlgItemText(IDC_EDIT_PASSWORD, szPassword);


This should work, the CString is resized to fit the text.  Are you sure
you're using a CString and not a char[] ?


-- 


Sigurd
http://utvikling.com


0
sigurds (118)
9/24/2004 12:03:29 PM
I am not sure the bug comes from the GetDlgItemText function. Maybe it
comes from the following line of code that outputs the CString
variable with a MessageBox function (MFC version of MessageBox).

I've tried to enter a very big value for the CString, and disabled the
MessageBox and it was OK.

Anyway, I don't see any variable in the Editbox properties that are
seen in the Ressource Editor. BUT : One time it seems that an editbox
had a maximum of approximatively 1100 characters (I don't know why,
neither how, but maybe it was an error in my code...).

Thanks



"Sigurd Stenersen" <sigurds@utvikling.com> wrote in message news:<u8YbD6ioEHA.896@TK2MSFTNGP12.phx.gbl>...
> __MicroCode2004__@__Hotmail.Com__ wrote:
> > CString szPassword;
> >
> > // If I enter a very big value for the password, the application bugs
> > // On the following line :
> 
> 
> What do you mean, "bugs" ?
> 
> 
> > GetDlgItemText(IDC_EDIT_PASSWORD, szPassword);
> 
> 
> This should work, the CString is resized to fit the text.  Are you sure
> you're using a CString and not a char[] ?
0
9/27/2004 8:38:44 AM
(modified) : Anyway, I don't see any variable for the maximum size of
text in the Editbox properties that are seen in the Ressource Editor.
BUT : One time it seems that an editbox had a maximum of
approximatively 1100 characters (I don't know why, neither how, but
maybe it was an error in my code...).


"Sigurd Stenersen" <sigurds@utvikling.com> wrote in message news:<u8YbD6ioEHA.896@TK2MSFTNGP12.phx.gbl>...
> __MicroCode2004__@__Hotmail.Com__ wrote:
> > CString szPassword;
> >
> > // If I enter a very big value for the password, the application bugs
> > // On the following line :
> 
> 
> What do you mean, "bugs" ?
> 
> 
> > GetDlgItemText(IDC_EDIT_PASSWORD, szPassword);
> 
> 
> This should work, the CString is resized to fit the text.  Are you sure
> you're using a CString and not a char[] ?
0
9/27/2004 8:39:56 AM
__MicroCode2004__@__Hotmail.Com__ wrote:
> (modified) : Anyway, I don't see any variable for the maximum size of
> text in the Editbox properties that are seen in the Ressource Editor.

Sure there is.  You just make the member variable to be of the "Value"
category instead of "Control".
(I'm on VC6 but I'm sure the same is possible in newer versions as well.)

Or use CEdit::SetLimitText()


> BUT : One time it seems that an editbox had a maximum of
> approximatively 1100 characters (I don't know why, neither how, but
> maybe it was an error in my code...).

There used to be a limit of about 32KB on 16-bits Windows, but there is not
a significant limit today.


-- 


Sigurd
http://utvikling.com


0
sigurds (118)
9/27/2004 10:42:32 AM
Reply:

Similar Artilces:

Need to create Duplicate Items in Inventory
I own a bookstore & need to create items that have the same description; I may have 1 book with the exact same title three times with a different sub description (paper back, hard cover and Mass Market). When I use the import utility in POS 2009, I get an error message telling me that an item with the same description already exists. I am aware of this & want it to create the item anyway. Thai is also true for some of my gift items. If it was only a few items, I'm sure I couple just modify the description, however this is true for about 13,000 items. I se...

Save Window sizes in Config file?
Hey, I would like to save my child window sizes in some kind of config file. What is the accepted approach, using the registry somehow? I have seen this stuff before...... theApp.WriteProfileString("Optimizer", "Software", "password"); s = theApp.GetProfileString("Optimizer", "Software"); if(s != "password") errorexit("Illegal Software Security Code!"); Thanks, Wayne Hi, I think you are this way inviting people to start again with the always ongoing discussion of ini files versus registry en...

How to put a size limit on archive pst????
How do you limit the size or AGE of your archive.pst and Outlook.pst in Outlook 2000, xp Thanks Roo Roo <Kanga@hotmail.com> wrote: > How do you limit the size or AGE of your archive.pst and Outlook.pst > in Outlook 2000, xp All PSTs in Outlook 2000 come with built-in size limits of 1.83 Gb. Exceed that limit and your PSTs can become trash. As to age, what do you mean by that? -- Brian Tillman ...

Copy file to all users desktop directory
I have a d:\users folder on my server. inside users, each user has a folder named with their name. inside each of those folders is a desktop folder. I have a file on the C drive that I need to copy to each of those desktop folders, thereby giving each user this shortcut. Does anyone have a script that could do that, instead of me copying this file manually a few hundred times? many thanks if you do! ...

how to move data down a column, and copy it into a row
I have data like this dog cats birds snakes how can quickly move to a row like this dog cats birds snakes without having to use copy and paste for each cell Torres Hi Have a look at the TRANSPOSE function In your case it might be =TRANSPOSE($A$1:$A$4) HTH Michael Mitchelson "Dave T" wrote: > I have data like this > > dog > cats > birds > snakes > > how can quickly move to a row like this > > dog cats birds snakes > > without having to use copy and paste for each cell > > > Torres > What I do is to: 1. copy your ce...

DPM 2007 Copy Specific Recovery Points To Tape
Hello, I was wondering if it is possible to copy specific recovery points to one tape. In the console GUI if I go to the recovery tab and specify a recovery point I have the option to "Copy to tape". The limitation there is I seem to be able to only copy the one recovery point to a tape regardless of size. These recovery points belong to different protection groups also. Can this be done through Powershell? Thanks Here is an example of how I am copying a pg[0], ds[0], rp[0] to a library lib[0] to an empty tape by creating a tape label DPMTape1. Just a note he...

Array of ints of variable size
Hi, how can I make an Array of int's with no fixed size, that is a variable lenght arrray of ints? Is there any MFC class to achieve so? thanks Yes, you can use the CArray template class. Find the right includes and the declare as: CArray<int, int> MyIntArray; -- Jonathan Wood SoftCircuits Programming http://www.softcircuits.com "Martin" <mrbiancu@gmail.com> wrote in message news:1159913290.211472.8370@m73g2000cwd.googlegroups.com... > Hi, how can I make an Array of int's with no fixed size, that is a > variable lenght arrray of ints? > Is there a...

message copy remains in outbox
All messages I send leave a copy behind in the outbox. I know that the messages are definately being sent. The message changes from italics to normal face once it's been sent, but the copy remains, and I get the message upon exiting outlook that messages remain in the outbox. I've been using this installation of outlook, (outlook 2002 running on win98), for months. This problem has only appeared a few days ago. I have 3 email accounts - all pop3 accounts. I'm not using exchange server (as far as I know :-). The problem exists for all accounts. I've downloaded all ...

Item aging report by user
I have a need to generate a report that shows totral number of items in the store by user by age. How many messages are 60 days old, how many 180- days old, how many over a year old. We are trying to get a handle on our ever expanding information store and management has requested this type of report. Can anyone point me in the right direction to generate this? Thanks Try Recipient Policies (may need to use multiple) set to Report Only mode. -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: www.exchangepedia.com/blog ----------------------------------------------...

Minimize Excel File Size
Hello! I would like to minimize the file size of my large Excel spreadsheet. They don't have any graphics or charts - mostly links to other spreadsheets and formulas. Does anyone know what I can do? "Jeff L." <jeffliptrap@yahoo.com> wrote in message news:044401c38392$42b83c20$a401280a@phx.gbl... > Hello! > > I would like to minimize the file size of my large Excel > spreadsheet. They don't have any graphics or charts - > mostly links to other spreadsheets and formulas. > > Does anyone know what I can do? Make sure that the last used cell o...

Cannot verify email
I'm trying to retrieve a "reset password" link for another forum. However, the address the reset link was sent to is for some reason demanding I verify my username and password, which means that until I do I cannot recieve the reset link. However I do not know the username or password, and all my guesses were rejected. To test I tried to make a new account where I knew both username and password, but it rejected those as well even though they were correct. Whatever I put in, the window automatically pops back up. Now for some reason I can't even test the new acc...

Easy way to remove access to a menu item and all submenus?
I'm still trying to get the hang of using Advanced Security, and I don't know if I'm doing things the hard way or not. For example, I installed SmartList Builder on several user's PCs so they could run some custom SmartLists that I developed. However, I don't want them to be able to have access to the menu items that appear under Tools>SmartList Builder. Is there a fast way of shutting off the entire menu option (and all sub-menus) for SmartList Builder? The only way I can figure out how to do it is to go through each menu option, one by one, and eliminate access...

copy subtotals with detail
i have produce a table with group data as subtotals and require to copy one subtotal and the relating data(detail). i know how to copy the totals only but i would like to be able to do the opposite of this and copy everything relating to that sub total. Is this even possible? Thanks PS. another way to look at it is to delete the subtotal and the detail is delete also -- crunkenmonkey ------------------------------------------------------------------------ crunkenmonkey's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26132 View this thread: http://www.excelfo...

Missing trending items
One of the features I expect to use most regularly in Money Deluxe 2008 is cash flow forecasting. However, it so far refuses to add trending for "Dining Out" and "Entertainment" even though I have plenty of data in those categories. What gives? I have changed the cash flow report settings to include discretionary items. When that failed, I tried changing the "Entertainment" category to a necessity. Still no go. I've fiddled with several other things without luck. Other, barely used categories DO get included as trend items, so why not these? Any clues...

persomnal file size limits?
OK, this is odd. I thought that Outlook 2003 had a size limit of 20gig. I've migrated multiple people from eudora to Outlook with no size problems at all, but this one user's Outlook 2003 insists on a two gig maximum, which is forcing me to create multiple archival PSTs in order to find a home for all his mail. On top of this (don't know if this is related or not) is even though I've moved a large amount of mail from the user's primary pst, when I go into explorer to look at the size of the file, it still shows the same size (but current date stamp.) I've ensured the ...

sent items not retaining attached docs...
I have a client that has a strange problem. She is using Outlook 2000 on an XP Pro machine and regualry sends emails containing attached items. If she creates a new email and then attaches the pic from there, it is saved in her sent items no problem. However, if she browses to the actual picture, thenright-clicks and selects "Send To"->Email recipient, the email will be sent out to the recipient, but the email never winds up in her sent items. I took a quick peek and discovered that everytime she sends an email with an attachment and uses the method above to do this, it alw...

How do I protect a worksheet from being copied & pasted?
In Excel 97 I need to send a client a worksheet that I am protecting. But I don't want them to be able to copy the whole worksheet and paste it into a blank worksheet and amend that. The safest way is to print the item and scan the printed output to .tif file, then send either the .tif or a .pdf copy of the .tif (no a .pdf copy of the Worksheet) The 'Capture' process from Adobe, or a good OCR program will stil enable copy & paste, but will make it more difficult. There are very few other ways to prevent the Copy / Paste fro happening -- Bryan Hesse -----------------...

Workbook Size
MS Excel Newsgroup: I had occasion to create two Tables in Excel. The first file is one page in length and uses approximately 762 Kb memory. The second Table is seven pages long and only uses 77 Kb memory. Can anyone explain this? Bernie Beal bquest@optonline,net Hi Bernie! Most likely cause is a false end of used range in the first workbook. See: Debra Dalgleish: http://contextures.com/xlfaqApp.html#Unused -- Regards Norman Harker MVP (Excel) Sydney, Australia njharker@optusnet.com.au Excel and Word Function Lists (Classifications, Syntax and Arguments) available free to good homes...

copy dimensons
is there a way to copy just the dimensons of a range, say (a1:a10) an not the values that range contains to another range, say(c1:c10) in vb -- spear ----------------------------------------------------------------------- speary's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2495 View this thread: http://www.excelforum.com/showthread.php?threadid=38522 Do you mean you'd like to copy the format of a1:a10 to c1:c10, without copying values? Or is a1:a10 a named range? i think i just need the formats, i.e. if their are 10 data files in column a then there...

Issue with copy/paste dates from filtered data
I have a spreadsheet with a lot of account numbers. I have autofiltered to sum a specific account number. I copied and pasted all of the data associated with this account number into another spreadsheet. Everything pasted fine, but the dates changed. For example, the first row of the original data is for 7/1/2004, but changes to 6/30/2000 in the new spreadsheet. Does anyone know why this happens and how to fix so that the dates are consistent between the 2 spreadsheets? Thanks! -- deacs ------------------------------------------------------------------------ deacs's Profile: http...

Information store size considerations during an Exchange 5.5 to 2003 migration
I was wondering if the size of the information store will grow or shrink during the migration. If I have a 50GB information store now in Exchange 5.5 that I expect to grow at 20% per year, what type of storage capacity would be sufficient over the next 5 year period? Thanks for any help In a migration you would expect to see a reduction in the benefits of single instance storage. However a migration should also present a good opportunity to archive old mail so take your pick. So if your are trying to provision storage give yourself plenty of margin. Nue "Ian East" <ian....

Smaller Font Sizes ?
Smallest font size available using Mircrosoft Works Home version Spreedsheed Apps is 8. How Can I use smallar font sizes i.e 6? This is an excel newsgroup. In excel, I can just type the 6 in the font size box. Maybe it'll work in MSWorks, too. YorkBeach wrote: > > Smallest font size available using Mircrosoft Works Home version Spreedsheed > Apps is 8. How Can I use smallar font sizes i.e 6? -- Dave Peterson ...

CListCtrl coloring and uncoloring indivual item
Hello, I am using a CListCtrl control in Report_View, and I was interested in coloring the cell of some particular items. how would I go about doing that? So for example, by default, I have some item A with subitems, B and C. I would like to have that row colored some color and just that row. I would also like to be able to uncolor, ( paint it back to default). Thanks >Hello, I am using a CListCtrl control in Report_View, and I was >interested in coloring the cell of some particular items. how would I >go about doing that? Jon, Have a look at using the custom draw facilities ...

Forward copy of outgoing e-mails to managers
I have a client that is running Exchange 2003. It is a brokerage firm and is bound by strict rules from the SEC and NASD. One of the requirements is that all incoming and outgoing e-mail is recorded and stored. We have this taken care of using journaling and ComplianceVault. Another requirement is that all managers receive a copy of all of the users e-mail. We are using forwarding to accomplish this for incoming e-mail but can't figure out how to also send the managers a copy of their outgoing. Is there anything that I am missing or can I do this? Aztech wrote: > I have a client...

Verify Password
Just download Money 2006 Delux trial version and would like to setup my account and connect to my bank (Hang Seng Bank) which is listed on the directory.. however, it keep saying my "verified password" is not correct and don't proceed to connect..what's wrong? I am 100% sure the password and verify passward are the same (no caps lock).. Please help. In microsoft.public.money, Casper wrote: >Just download Money 2006 Delux trial version and would like to setup my >account and connect to my bank (Hang Seng Bank) which is listed on the >directory.. > >ho...