Link to home
Start Free TrialLog in
Avatar of Nadir Van Thielen
Nadir Van ThielenFlag for Belgium

asked on

C++ EDIT CreateWindow

Hallo,

When i, wane add a new EDIT child window which the user can type text from the keyboard.
a normal text box works, but when I challenge  CreateWindowExW( EDIT ..)

and  BUILD and run the program from my compute noting happens.

Do i miss the paint code or something.

//  Add a new TEXT imput box
//CreateWindow(TEXT("EDIT"),TEXT ("VALEU"), WS_VISIBLE | WS_CHILD | WS_BORDER ,10,10 ,200,25,hWnd, (HMENU) NULL,NULL,NULL );

// Add a new TEXT edit window

CreateWindowExW(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, 10, 10, 200, 25, hWnd, (HMENU) NULL,NULL,NULL );
			

Open in new window

Untitled.jpg
Avatar of sarabande
sarabande
Flag of Luxembourg image

the CreateWindowEx returns a window handle. you need to save that handle in order to call subsequent Windows functions, for example

ShowWindow(hwndEdit, SW_SHOW);

Open in new window


if you provide a parent window (you did with 'hwnd') and a valid ID (as HMENU) to the Create function, you would be able to retrieve the window handle of the edit box by calling

HWND hwndEdit = GetDlgItem(hwndParent, ctrlID);

Open in new window


where ctrlID is the ID that you passed as HMENU to the CreateWindowEx function.

Sara
Avatar of Nadir Van Thielen

ASKER

I , understand  your solution Sara,

but don't understand where i need to call  hwndEdit in the code ,
where this you get   "hwndEdit" from.



CreateWindowExW(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, 10, 10, 200, 25, hWnd, (HMENU) NULL,NULL,NULL );

ShowWindow(hwndEdit, SW_SHOW);

Open in new window

Hi,
CreateWindow returns it:

hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, 10, 10, 200, 25, hWnd, (HMENU) NULL,NULL,NULL );
ShowWindow(hwndEdit, SW_SHOW);

-FA
from your code i see that you have created an mfc application.

if that is true you might consider to use a dialog-based mfc app rather than an SDI application with self-created controls.

you easily can test this option by creating a new mfc application project - say YopaWordEditor - and choose dialog-based as option. the generated mfc code already would generate a dialog resource for you and you easily could design a dialog form by using the resource editor.

Sara
I understand  dialog-based mfc app ,
 but i wanna LOW-LEVEL programming in the distend future build it in a intel FPGA micro controller.
And it's easier to write a c++ kernel


HWND hwndEdit;
...
..
hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, 10, 10, 200, 25, hWnd, (HMENU) NULL,NULL,NULL ); ShowWindow(hwndEdit, SW_SHOW);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial