View Single Post
Old Dec 15th, 2006, 3:50 PM   #3
Prm753
Professional Programmer
 
Prm753's Avatar
 
Join Date: Oct 2005
Location: United States
Posts: 447
Rep Power: 4 Prm753 is on a distinguished road
Send a message via AIM to Prm753 Send a message via MSN to Prm753
Thank you very much, grumpy.

I have this code now:

cpp Syntax (Toggle Plain Text)
  1. if(GetOpenFileName(&ofn))
  2. {
  3. strcpy(Buffer, szFileName);
  4. return Buffer[MAX_PATH];
  5. // MessageBox(0, Buffer, 0, 0);
  6. // SendMessage(GetDlgItem(hwnd, IDC_EDITBOX_TEXT), LB_ADDSTRING, 0, (LPARAM)"test");
  7. }

cpp Syntax (Toggle Plain Text)
  1. case IDB_BROWSEBUTTON:
  2. {
  3. switch (HIWORD(wParam))
  4. {
  5. case BN_CLICKED:
  6. {
  7. Buffer[MAX_PATH] = DoFileOpen(hWnd);
  8. SendMessage(GetDlgItem(hWnd, IDC_EDITBOX_TEXT), LB_ADDSTRING, 0, (LPARAM)Buffer);
  9. // MessageBox(0, Buffer, 0, 0);
  10. }
  11. break;
  12. }
  13. break;
  14. }
  15. break;

The MessageBox() in the second code example displays the path that I select in my browse function. If I change IDC_EDITBOX_TEXT to IDC_LISTBOX_TEXT, the message is received just fine. It displays the path in the listbox. This is fine, this is wonderful, this is dandy, but this is not what I want. I want to put the string into my editbox, and for some reason, SendMessage() fails on doing this. (I think)

Here is my editbox code:

cpp Syntax (Toggle Plain Text)
  1. hWndEditBox = CreateWindow(
  2. "EDIT",
  3. "<type a file name here>",
  4. WS_VISIBLE | WS_CHILD | WS_BORDER,
  5. 10,
  6. 10,
  7. 700,
  8. 30,
  9. hWnd,
  10. (HMENU)IDC_EDITBOX_TEXT,
  11. (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
  12. NULL);
  13.  
  14. HFONT AhFont = (HFONT)GetStockObject( DEFAULT_GUI_FONT );
  15. SendMessage( hWndEditBox, WM_SETFONT, (WPARAM)AhFont, TRUE );

What am I doing wrong here?

Thanks again.
__________________
The world's first athletic computer geek!
The home of PrProgramsStudios
How not to post a question: <-- Please don't reply
Prm753 is offline   Reply With Quote