views:

47

answers:

2

i need to create edit box in c++ without using mfc.....
only win32

+2  A: 

CreateWindow("EDIT", ...);. You can use CreateWindowEx if you prefer, but it's not necessary. To use it, you'll also normally want to have your window respond to WM_FOCUS by calling SetFocus to set the focus on the edit control. You'll typically also want to respond to WM_MOVE (or is it WM_SIZE - I can't remember) by resizing the edit control to fit the client area of the parent window.

Of course you can also create a dialog (DialogBox or DialogBoxEx) containing an edit control. This avoids having to manually set the focus and such.

Jerry Coffin
+1  A: 
HWND CreateTextBox(CONST INT iX, CONST INT iY, CONST UINT uWidth, CONST UINT uHeight, HWND hWnd, CONST UINT uId, HINSTANCE hInstance)
{
   HWND hWndRet = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, iX, iY, (signed)uWidth, (signed)uHeight, hWnd, (HMENU)uId, hInstance, NULL);
   SetBkColor(GetDC(hWndRet), RGB(255, 255, 255));
   return hWndRet;
}

Just a small function I use for creating default, blank text boxes.

myeviltacos
i really like the function you posted but what does uId stand for like what is it for?
Ramiz Toma
uId is the Id of the control. When you create a control in Win32, it has an identifier which is used in your WndProc.If you don't understand what I mean, open the VS resource editor, add a dialog, dump some controls onto the dialog, and take a look at the Ids of the controls.
myeviltacos