Okay, since you guys are 2 for 2 with my recent programming questions, I'll ask you guys again. 
I got my windows sockets "chat" program running (thanx for the help) now, I want to have the user specify the IP to use so I can easily test my code on remote machines.
I plan to do this with an editBox (or is it called a textBox?) All I need is a windows message box with a single line for input, so I can take the string the user enters (should be an IP addy) and connect to the IP. I tied looking for this for a while and MSDN isnt helping, Google sux, and if I see another page on .NET or C#, I'm gonna cut someone. I dont use Vis-C++ 7.0, I sometimes use 6.0 but I mostly use Dev-CPP for my windows programming, and it has done a great job with the API stuff I learned.
So, I just want to make a simple textbox so I can enter a string, and then use that string elsewhere in the program.
Thanx a lot.
I'm no good at the windows API (or whatever it is), but if you simply want that you could use the command line
not quite as easy, but easy enough for testing purposes.
I'm recently programming Visual C++ 6.0 an so...
Create your Dialog (CDialog class) and draw an edit Box using the Edit Box Draw button...
That's ok I hope...
now:
- Create a class for your dialog (2 click on your dialog and giva a name to the class.).
- Click on your edit Box with Right mouse button a select properties.
- Assign a good name such as ... MY_EDIT_BOX_INPUT (ok , you should make it better).
- Click again with the right mouse button upon your edit box and choose "events".
- Select an event (onfieldchange is good, or better, "onKillFocus" too), and "add&Edit" this event to your dialog class. (you have override a method.)
- Inside this code, after the TO DO comments, use this:
#include <string> using namespace std; CString my_cstring; GetDlgItemText( MY_EDIT_BOX_INPUT, my_cstring ); // setDlgItemText is the set method ;) string my_str = my_cstring; // now do what you want when the text into the box change....
For additional questions, I suggest to you this very userfull site: www.codeguru.com
Try my game...
ciao ciao
Is there a way to do this in Dev-C++ or in pure code? I know other parts of windows that MFC can do can also be done in pure code, so I'd imagine this wouldnt be any different. I rather not switch to vis-c++ since I started this in dev-c++.
thanx.
I think what you're looking for is information on working with the win32 api.
This: http://www.google.ca/search?l&q=win32+api+tutorial seems to turn up quite a few hits, the first one looks particularly promising, but I don't really know much about it (I've done all my previous windows programming in MFC with MSVC 6).
I know that MFC means Microsoft Foundation Classes, but I don't know if the can be create from a compiler different from Microsoft's.
I think that a good site that let you programmatically do everything with windows is this, but your way will become difficult very soon:
http://www.functionx.com/visualc/
I like very muth this site, It's my starting point to my applications...
Take a look, but, watch your six 
ciao ciao
Thanx for the links guys, but most of them are too basic for me.
I have been to all of those links when I first started learning the win api stuff, but they dont help much now. I have been looking at some source code, so hopefully I will get what I want from them.
I have been looking at the CreateWindowEx for making child windows and the options that go along with them, but so far, blindly cutting and pasting code into my win32 stuff doesn't work. ah well...
Try this
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define ID_EDIT 1 |
| 4 | LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); |
| 5 | |
| 6 | TCHAR szAppName[] = TEXT("Single line text input test"); |
| 7 | |
| 8 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, |
| 9 | PSTR szCmdLine, int iCmdShow) |
| 10 | { |
| 11 | HWND hwnd; |
| 12 | MSG msg; |
| 13 | WNDCLASS wndclass; |
| 14 | |
| 15 | wndclass.style = CS_HREDRAW | CS_VREDRAW; |
| 16 | wndclass.lpfnWndProc = WndProc; |
| 17 | wndclass.cbClsExtra = 0; |
| 18 | wndclass.cbWndExtra = 0; |
| 19 | wndclass.hInstance = hInstance; |
| 20 | wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); |
| 21 | wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 22 | wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); |
| 23 | wndclass.lpszMenuName = NULL; |
| 24 | wndclass.lpszClassName = szAppName; |
| 25 | |
| 26 | if(!RegisterClass(&wndclass)) |
| 27 | { |
| 28 | MessageBox(NULL, TEXT("Ths program require Windows NT!"), |
| 29 | szAppName, MB_ICONERROR); |
| 30 | |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | hwnd = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW, |
| 35 | CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
| 36 | NULL, NULL, hInstance, NULL); |
| 37 | |
| 38 | ShowWindow(hwnd, iCmdShow); |
| 39 | UpdateWindow(hwnd); |
| 40 | |
| 41 | while(GetMessage(&msg, NULL, 0, 0)) |
| 42 | { |
| 43 | TranslateMessage(&msg), |
| 44 | DispatchMessage(&msg); |
| 45 | } |
| 46 | |
| 47 | return msg.wParam; |
| 48 | } |
| 49 | |
| 50 | |
| 51 | |
| 52 | LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
| 53 | { |
| 54 | static HWND hwndEdit; |
| 55 | |
| 56 | HDC hdc; |
| 57 | PAINTSTRUCT ps; |
| 58 | RECT rect; |
| 59 | |
| 60 | static TCHAR szText[512] = ""; |
| 61 | |
| 62 | switch(msg) |
| 63 | { |
| 64 | case WM_CREATE: |
| 65 | hwndEdit = CreateWindow(TEXT("edit"), NULL, |
| 66 | WS_CHILD | WS_VISIBLE | WS_BORDER, |
| 67 | 10, 10, 500, 20, hwnd, (HMENU) ID_EDIT, |
| 68 | ((LPCREATESTRUCT) lParam)->hInstance, NULL); |
| 69 | |
| 70 | return 0; |
| 71 | |
| 72 | case WM_SETFOCUS: |
| 73 | SetFocus(hwndEdit); |
| 74 | return 0; |
| 75 | |
| 76 | case WM_COMMAND: |
| 77 | if(LOWORD(wParam) == ID_EDIT) |
| 78 | { |
| 79 | if(HIWORD(wParam) == EN_ERRSPACE || HIWORD(wParam) == EN_MAXTEXT) |
| 80 | MessageBox(hwnd, TEXT("Edit control out of space!"), |
| 81 | szAppName, MB_OK | MB_ICONSTOP); |
| 82 | |
| 83 | if(HIWORD(wParam) == EN_UPDATE) |
| 84 | { |
| 85 | GetWindowText(hwndEdit, szText, 511); |
| 86 | |
| 87 | InvalidateRect(hwnd, NULL, TRUE); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | return 0; |
| 92 | |
| 93 | case WM_PAINT: |
| 94 | hdc = BeginPaint(hwnd, &ps); |
| 95 | |
| 96 | GetClientRect(hwnd, &rect); |
| 97 | DrawText(hdc, szText, -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); |
| 98 | |
| 99 | EndPaint(hwnd, &ps); |
| 100 | |
| 101 | return 0; |
| 102 | |
| 103 | case WM_DESTROY: |
| 104 | PostQuitMessage(0); |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | return DefWindowProc(hwnd, msg, wParam, lParam); |
| 109 | } |
In short it creates a white window with a single line edit box
hwndEdit = CreateWindow(TEXT("edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 10, 500, 20, hwnd, (HMENU) ID_EDIT, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
(I omitted the style ES_MULTILINE)
The relevant code is
if(HIWORD(wParam) == EN_UPDATE) { GetWindowText(hwndEdit, szText, 511); InvalidateRect(hwnd, NULL, TRUE); }
Which detects when new characters are entered / deleted and updates each time the buffer, plus it forces an update of the entire window.
Marco, You are the man!!
Thanx for the help!
You're welcome 
Let me know if it works