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

Combo Box with more than 256 char - problem when selecting entry

4 views
Skip to first unread message

Andreas Buchinger

unread,
Dec 7, 2009, 1:02:56 PM12/7/09
to
Hi,
I've a Combo Box which I widen to 512 chars with

WinSendMsg(WinWindowFromID(hwnd, DD_FILESRCH),
EM_SETTEXTLIMIT,
MPFROMSHORT( 512 ),
(MPARAM)0);

Now I can enter up to 512 characters. But when selecting one of the longer
entries in the drop down box, only the first 256 chars plus a few garbage
characters are copied to entry field.

Is there an internal clipboard I've to widen too?

Regards,
Andreas

Lars Erdmann

unread,
Dec 7, 2009, 2:09:39 PM12/7/09
to
Andreas Buchinger schrieb:
My feeling is you are lacking an additional byte for the zero terminator.

Andreas Buchinger

unread,
Dec 7, 2009, 3:01:50 PM12/7/09
to
Lars Erdmann schrieb:
In the drop down box the strings are displayed correctly (longer than 256
characters). If I select one of them, it is automatically (or is there some code
I didn't find yet?) copied to the entry field. But only the first 256 chars.

Steven Levine

unread,
Dec 7, 2009, 4:05:25 PM12/7/09
to
On Mon, 7 Dec 2009 18:02:56 UTC, Andreas Buchinger <and...@gmx.net>
wrote:

Hi Andi,

> WinSendMsg(WinWindowFromID(hwnd, DD_FILESRCH),
> EM_SETTEXTLIMIT,
> MPFROMSHORT( 512 ),
> (MPARAM)0);
> Now I can enter up to 512 characters. But when selecting one of the longer
> entries in the drop down box, only the first 256 chars plus a few garbage
> characters are copied to entry field.
>
> Is there an internal clipboard I've to widen too?

Not a clipboard, per se. A combo box contains two child windows - an
entry-field and a listbox with the ids

#define CBID_EDIT 0x029B
#define CBID_LIST 0x029A

Offhand I would look for buffer sizing issues in your code. It's not
impossible that listbox entries are limited to 256 characters, but if
so, this is not documented TTBOMK.

Steven

--
---------------------------------------------------------------------
Steven Levine <ste...@earthlink.bogus.net>
eCS/Warp/DIY etc. www.scoug.com www.ecomstation.com
---------------------------------------------------------------------

Lars Erdmann

unread,
Dec 8, 2009, 2:16:51 PM12/8/09
to
Andreas Buchinger schrieb:

Hm, reading the PM reference, it seems that EM_SETTEXTLIMIT is not the
correct way to deal with this.
EM_SETTEXTLIMIT sets a limit when you enter something in the entryfield
and NOT when something is copied from the listbox to the entryfield. In
other words: EM_SETTEXTLIMIT limits on "user entry" but not on "Software
generated entry".

I'd try WM_SETWINDOWPARAMS on the entry field:

ENTRYFDATA e={0};
WNDPARAMS p={0};

e.cb = 8; // length of ENTRYFDATA structure
e.cchEditLimit = 512; // text length limit for the edit box
e.ichMinSel = 0; // no text currently selected, cursor before 1.
character
e.ichMaxSel = 0; // no text currently selected, cursor before 1.
character

p.fsStatus = WPM_CTLDATA;
p.cbCtlData = sizeof(e);
p.pCtlData = &e;

WinSendWindowMsg(WinWindowFromID(hwnd,DD_FILESRCH),
WM_SETWINDOWPARAMS,
MPFROMP(&p),
MPVOID);

Instead of setting this during runtime via WM_SETWINDOWPARAMS, you can
also set this in the resource file (if the combobox is defined in a
resource file) or on Window creation (if you create the window via
WinCreateWindow).
The Entryfield associated with the drop down uses the ENTRYFDATA
structure for its control data. The resource directive CTLDATA does the
trick. It allows to set 2-byte values. You can directly set the
ENTRYFDATA parameters from within the resource file:

COMBOBOX "",DD_FILESRCH,10,10,200,20
CTLDATA 8,512,0,0

This will set the ENTRYFDATA structure like this:
e.cb = 8;
e.cchEditLimit = 512;
e.ichMinSel = 0;
e.ichMaxSel = 0;


Lars


Lars Erdmann

unread,
Dec 8, 2009, 2:18:57 PM12/8/09
to
Andreas Buchinger schrieb:

Hm, reading the PM reference, it seems that EM_SETTEXTLIMIT is not the

correct way to deal with this.
EM_SETTEXTLIMIT sets a limit when you enter something in the entryfield
and NOT when something is copied from the listbox to the entryfield. In
other words: EM_SETTEXTLIMIT limits on "user entry" but not on "Software
generated entry".

I'd try WM_SETWINDOWPARAMS on the entry field:

ENTRYFDATA e={0};
WNDPARAMS p={0};

e.cb = sizeof(e); // length of ENTRYFDATA structure


e.cchEditLimit = 512; // text length limit for the edit box
e.ichMinSel = 0; // no text currently selected, cursor before 1.
character
e.ichMaxSel = 0; // no text currently selected, cursor before 1.
character

p.fsStatus = WPM_CTLDATA;
p.cbCtlData = sizeof(e);
p.pCtlData = &e;

WinSendWindowMsg(WinWindowFromID(hwnd,DD_FILESRCH),
WM_SETWINDOWPARAMS,
MPFROMP(&p),
MPVOID);

Instead of setting this during runtime via WM_SETWINDOWPARAMS, you can
also set this in the resource file (if the combobox is defined in a
resource file) or on Window creation (if you create the window via
WinCreateWindow).
The Entryfield associated with the drop down uses the ENTRYFDATA
structure for its control data. The resource directive CTLDATA does the
trick. It allows to set 2-byte values. You can directly set the
ENTRYFDATA parameters from within the resource file:

COMBOBOX "",DD_FILESRCH,10,10,200,20
CTLDATA 8,512,0,0

This will set the ENTRYFDATA structure like this:

e.cb = 8; // (sizeof(ENTRYFDATA))

Andreas Buchinger

unread,
Dec 9, 2009, 3:07:12 PM12/9/09
to
Tried your suggestions (both) but unfortunately no success.

Stepping over in IDEBUG starting from CBN_ENTER message I see only pmmerge code.

What I found out is, the ENTRYFIELDS in this application are subclassed. But I
do not see any problem with text length in the replacement routine -

MRESULT EXPENTRY newEfProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
if ( (msg == WM_PRESPARAMCHANGED) && ((ULONG)mp1 == PP_FONTNAMESIZE) &&
!(g.state & IS_RESETBOXFONTS) )
{
WinSendMsg(WinParent(WinParent(hwnd)),
SWM_PPCHANGED, (MPARAM)hwnd, MPTRUE);
return MRFALSE;
} /* endif */
return g.pDefEfProc(hwnd, msg, mp1, mp2);
}


Andi

Andreas Buchinger

unread,
Dec 15, 2009, 3:41:54 PM12/15/09
to
Steven Levine schrieb:

> On Mon, 7 Dec 2009 18:02:56 UTC, Andreas Buchinger <and...@gmx.net>
> wrote:
>
> Hi Andi,
>
>> WinSendMsg(WinWindowFromID(hwnd, DD_FILESRCH),
>> EM_SETTEXTLIMIT,
>> MPFROMSHORT( 512 ),
>> (MPARAM)0);
>> Now I can enter up to 512 characters. But when selecting one of the longer
>> entries in the drop down box, only the first 256 chars plus a few garbage
>> characters are copied to entry field.
>>
>> Is there an internal clipboard I've to widen too?
>
> Not a clipboard, per se. A combo box contains two child windows - an
> entry-field and a listbox with the ids
>
> #define CBID_EDIT 0x029B
> #define CBID_LIST 0x029A
>
> Offhand I would look for buffer sizing issues in your code. It's not
> impossible that listbox entries are limited to 256 characters, but if
> so, this is not documented TTBOMK.
>
> Steven
>
Now I tend to believe it is a combo-box bug. I've made a work around which
copies the selected entry from the list box part to the entry field part on a
CBN_ENTER message. The code looks like below -

if ( SHORT2FROMMP(mp1) == CBN_ENTER )
{
int i;
char sBuf[512];
i = WinQueryLboxSelectedItem(WinWindowFromID(hwnd,DD_FILESRCH) );
if (i != LIT_NONE )
{
WinQueryLboxItemText( WinWindowFromID(hwnd,DD_FILESRCH), i, sBuf,
sizeof(sBuf) );
WinSetWindowText( WinWindowFromID(hwnd,DD_FILESRCH), sBuf );
}
}

Only draw back I've found till now is - selecting an entry with up/down keys and
closing the list box with the arrow does not generate the CBN_ENTER message. But
the selecting itself copies the crippled text to the entry field. But this is a
minor issue in my case.

Andi

0 new messages