Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateEx for an edit box

46 views
Skip to first unread message

Karen Hood

unread,
May 4, 1999, 3:00:00 AM5/4/99
to
Hi,
I am using CreateEx to create some CEdit boxes on the fly. Here's the
code I'm using...
m_local_edit_box[i].CreateEx( WS_EX_CLIENTEDGE, NULL, NULL,
WS_CHILD | WS_VISIBLE | WS_TABSTOP |ES_LEFT | ES_READONLY |
WS_BORDER, rect_string, this, m_ID++, NULL);

When I try to do a SetWindowText to set the text inside the box it
doesn't work.

My code works when I do a Create....
m_local_edit_box[i].Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP |
ES_LEFT | ES_READONLY | WS_BORDER, rect_string, this,
m_ID++);
SetWindowText works fine with this line of code, but the box isn't
displayed as I'd like it to be.

Anyone got any ideas?

p.s. Thanks for the previous help. It worked great!


Phaedrus

unread,
May 4, 1999, 3:00:00 AM5/4/99
to
In article <372F22D0...@maxtor.com>,

Karen Hood <Karen...@maxtor.com> wrote:
>Hi,
>I am using CreateEx to create some CEdit boxes on the fly. Here's the
>code I'm using...
>m_local_edit_box[i].CreateEx( WS_EX_CLIENTEDGE, NULL, NULL,
> WS_CHILD | WS_VISIBLE | WS_TABSTOP |ES_LEFT | ES_READONLY |
>WS_BORDER, rect_string, this, m_ID++, NULL);

Oops! You're creating a window with a NULL title--which may be okay--
and a NULL class name--which is definitely not. In other words, you're
not creating an editbox at all; you're just creating a generic window.

>When I try to do a SetWindowText to set the text inside the box it
>doesn't work.

That's because there's nothing to draw the window's contents, since
that would normally be done by the class code, and this window has no
class code associated with it (since the class name is NULL).

>My code works when I do a Create....
>m_local_edit_box[i].Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP |
> ES_LEFT | ES_READONLY | WS_BORDER, rect_string, this,
>m_ID++);
>SetWindowText works fine with this line of code, but the box isn't
>displayed as I'd like it to be.

This works because you're now calling CEditBox::Create, which sets the
class name and other needed info appropriately. The CEditBox class doesn't
have a CreateEx method; so you're actually calling CWnd::CreateEx, which
doesn't know which class name to use unless you tell it.

>Anyone got any ideas?

Two possibilities:
*Use your CreateEx call, but use "EDIT" for the class name, rather than
NULL.
*Use the Create call, and call ModifyStyleEx(0, WS_EX_CLIENTEDGE,
SWP_FRAMECHANGED) immediately afterwards.


--
\o\ If you're interested in books and stories with transformation themes, \o\
/o/ please have a look at <URL:http://www.halcyon.com/phaedrus>. Thanks! /o/
\o\ FC1.21:FC(W/C)p6arw A- C->++ D>++ H+ M>+ P R T++++ W** Z+ Sm RLCT \o\
/o/ a cmn++++$ d e++ f+++ h- i++wf p-- sm# /o/

0 new messages