LOL. Sorry I've been trying to get text from the wrong edit control. Doh!
Ive decided not to use a class now.
now Ive a got a problem with this though (from my dialog procedure):
Code:
char buf[32];
HWND hNameEdit = GetDlgItem( GetDlgItem(hwnd, ID_OPTSDIAG), ID_NAMEEDIT );
int tmp = GetWindowText(hNameEdit, buf, 32);
if(tmp==0){MessageBox(hwnd, "GetWindowText() returned 0!", "Error", MB_OK | MB_ICONEXCLAMATION);}
I'm not getting anything stored in 'buf' and im getting 0 returned from GetWindowText(). is there a problem with this code?
Or is there something wrong with the resource for the dialog and edit? Code for that:
Code:
// Options Dialog
ID_OPTSDIAG DIALOG DISCARDABLE 80, 30, 175, 100
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Options"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "OK", ID_OPTSOK, 25, 70, 50, 20
PUSHBUTTON "Cancel", ID_OPTSCNCL, 95, 70, 50, 20
LTEXT "Display name:", -1, 10, 15, 45, 10
EDITTEXT ID_NAMEEDIT, 60, 14, 90, 11
LTEXT "Text colour:", -1, 10, 40, 45, 10
PUSHBUTTON "Select Colour", ID_COLRBUTTON, 60, 38, 90, 12
END
This is where I create the dialog from the resource:
Code:
DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(ID_OPTSDIAG), hwnd, OptsDiagProc);