Results 1 to 5 of 5

Thread: How to make a textbox?

Threaded View

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Exclamation How to make a textbox?

    I cannot create a multiline textbox on a parent window. I used the following code but it does not show any edit box on my window:

    Code:
    #include <windows.h>
    #include "resource.h"
    #define classname "myclass"
    HWND winhwnd;
    HWND EditBoxHwnd;
    HINSTANCE hinst;
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
    {
    	switch(msg)
    	{
    	case WM_CREATE:
    	EditBoxHwnd = CreateWindow("EDIT", 
    				"df",
                                                 WS_CHILD | WS_VISIBLE
                                           |  ES_MULTILINE | ES_WANTRETURN |
                                                 WS_VSCROLL,
    		        CW_USEDEFAULT,
    		        CW_USEDEFAULT,
    		        CW_USEDEFAULT,
    		        CW_USEDEFAULT,
    			               hwnd,
    				NULL,
    				hinst,
    				NULL);
    		return 0;
    	case WM_DESTROY:
    	     PostQuitMessage(0);
    	   return 0;
    	}
    	return DefWindowProc(hwnd, msg, wparam, lparam);
    }
    
    int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpCmdLine, int nShowCmd)
    {
    	HMENU hmenu;
    	WNDCLASSEX wc;
    	MSG message;
    	// Fills in the class structure
    	wc.cbClsExtra = 0;
    	wc.cbSize = sizeof(WNDCLASSEX);
    	wc.cbWndExtra = 0;
    	wc.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
    	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    	wc.hInstance = hinst;
    	wc.lpfnWndProc = WndProc;
    	wc.lpszClassName = classname;
    	wc.style = CS_HREDRAW | CS_VREDRAW;
    	wc.lpszMenuName = NULL;
    
    	//Registers the Class
    
    	if(!RegisterClassEx(&wc))
    		{
    		MessageBox(NULL, "Class failure","CLASS", MB_OK);
    		return 0;
    	}
    	//Create thw hwnd of our main window
    
    	winhwnd = CreateWindow( 
    		classname, 
    		"Welcome to my Dialog Program",
    		WS_OVERLAPPEDWINDOW,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		NULL,
    		NULL,
    		hinstance,
    		NULL);
    	
    	
    	if(winhwnd == NULL)
    	{
    		MessageBox(NULL, "Hwnd failure","HWND", MB_OK);
    		return 0;
    	}
    	ShowWindow(winhwnd, nShowCmd);
    	UpdateWindow(winhwnd);
    
    	//Messes up with the messages
    
    	while(GetMessage(&message, NULL,0,0))
    		{
    		TranslateMessage(&message);
    		DispatchMessage(&message);
    		}
    
    	return message.wParam;
    }

    Do you know why it does not show the edit box on my window?
    Last edited by abdul; Jul 3rd, 2001 at 08:42 AM.
    Baaaaaaaaah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width