|
-
Jul 2nd, 2001, 10:59 PM
#1
Thread Starter
PowerPoster
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
-
Jul 3rd, 2001, 10:13 AM
#2
Frenzied Member
Change all the:
CW_USEDEFAULT,
to real values like 10,10,100,100
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jul 3rd, 2001, 11:14 AM
#3
Thread Starter
PowerPoster
I still does not show the edit box.
-
Jul 3rd, 2001, 11:17 AM
#4
Frenzied Member
Thats really strange your code works perfectly for me.
Try adding
ShowWindow(EditBoxHwnd,SW_NORMAL);
UpdateWindow(winhwnd);
after your CreateWindow and before return 0;
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jul 3rd, 2001, 11:19 AM
#5
Thread Starter
PowerPoster
Never Mind!
It works now. I just change the "Hinstance" to default hinstance and it works now.
And also, I think that you suggestion(getting rid of CS_USEDEFAULT) was also right.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|