GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Aug-2006, 08:06
ryver ryver is offline
New Member
 
Join Date: Aug 2006
Posts: 13
ryver is on a distinguished road
Exclamation

problem with filling a char array in a windows GUI app.


I'm working on a GUI for windows, for this I'm using the win32 API.
I have a dialog with a single textedit control, An Ok and Cancel button.

What I want is, that when I enter some text in the first control, it will appear in a messagebox. But for some reason it won't.

I've added the string variable result to see if the messagebox worked properly (which it does) and the variable dat to see if the while statement did it's job(iterate through the char array).

CPP / C++ / C Code:
case IDA_INVOER_NIEUWDATA: {
                int ret;
                ret = DialogBox(GetModuleHandle(NULL), 
                MAKEINTRESOURCE(IDB_DIALOG_AANTALNEWDATA), hwnd, NewdataProc);
                if(ret == IDOK){
                   char buf[80];
                   GetDlgItemText(hwnd,30001,buf,80);
                    int i = 0;
                    std::string result = "wyy";
                    std::string dat = "ert";
                    while(buf[i] != NULL) {
                        result = result + dat;
                        i++;
                        }
                    MessageBox(hwnd, result.c_str(), "Notice", MB_OK | MB_ICONINFORMATION);
                    }
                else if(ret == IDCANCEL){
                    break;
                }
                else if(ret == -1){
                    MessageBox(hwnd, "Dialoog mislukt!", "Error",MB_OK | MB_ICONINFORMATION);
                    break;
                    }
                break;

Well the iteration won't work because, quite probally because the char array is empty. But how can this array be empty? I did enter data in de textedit control and clicked "Ok".
  #2  
Old 13-Aug-2006, 09:22
outlaw98 outlaw98 is offline
New Member
 
Join Date: Aug 2006
Posts: 14
outlaw98 is on a distinguished road

Re: problem with filling a char array in a windows GUI app.


Everything looks good except when you call GetDlgItemText() you are sending the parent window of the dialog box as an argument for the hwndDlg parameter. You need to find some way of getting the handle of the dialogbox window and sending that as an argument there.. A suggestion is getting it through the NewdataProc() window procedure somehow.. GL
 
 

Recent GIDBlogI?m Home by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2D arrays:dynamic allocation and freeing bravetanveer C Programming Language 48 27-Nov-2007 16:55
Need help deleting the last element in the array headphone69 C++ Forum 2 15-Mar-2006 20:31
problem modifying an array of char in a function ronin C Programming Language 10 28-Mar-2005 19:15
Compiling Errors ToddSAFM C++ Forum 22 18-Dec-2004 12:42
Creating N string gwk C Programming Language 3 21-Jul-2004 00:27

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:24.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.