i need to create edit box in c++ without using mfc…..
only win32
i need to create edit box in c++ without using mfc….. only win32
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
CreateWindow("EDIT", ...);. You can useCreateWindowExif you prefer, but it’s not necessary. To use it, you’ll also normally want to have your window respond toWM_FOCUSby callingSetFocusto set the focus on the edit control. You’ll typically also want to respond toWM_MOVE(or is itWM_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 (
DialogBoxorDialogBoxEx) containing an edit control. This avoids having to manually set the focus and such.So, here’s a simple demo program. This creates a main window, and fills its client area with an edit control. It can open and save files, do cut/copy/paste of the data in the control, and select a font in which to display the data in the control. It has an accelerator table, so it knows about the usual keyboard shortcuts for most of those (e.g., ctrl-x = cut, ctrl-c = copy, ctrl-v = paste).
First, the main source code:
The, the header:
Note: the header includes defines for a few commands (find/find-next/replace) that aren’t implemented in the program.
Then you need a resource file, on this general order:
Although not strictly necessary, a Makefile to build it comes in handy:
So, if you save those into a directory, open a command prompt for Microsoft’s compiler, and type
nmakein that directory, it should build anotepad.exe, which will be a mildly stripped down version of the normal Windows notepad. It’s missing find/replace, printing, and a couple of other things, but at least has enough to give a decent starting point for how to create and use an edit control.Oh–one other note. This is mostly quickly hacked together from bits and pieces of old code, with a little bit of new duct tape (so to speak) to hold them together. It is not, by any means, exemplary of the best possible coding practices throughout (to put it nicely).