f



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

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
0
andi.b (4)
12/7/2009 6:02:56 PM
comp.os.os2.programmer.misc 1326 articles. 0 followers. Post Follow

7 Replies
395 Views

Similar Articles

[PageSpeed] 17

Andreas Buchinger schrieb:
> 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
My feeling is you are lacking an additional byte for the zero terminator.
0
Lars
12/7/2009 7:09:39 PM
Lars Erdmann schrieb:
> Andreas Buchinger schrieb:
>> 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
> My feeling is you are lacking an additional byte for the zero terminator.
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.
0
Andreas
12/7/2009 8:01:50 PM
On Mon, 7 Dec 2009 18:02:56 UTC, Andreas Buchinger <andi.b@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 <steve53@earthlink.bogus.net>
eCS/Warp/DIY etc. www.scoug.com www.ecomstation.com
---------------------------------------------------------------------
0
Steven
12/7/2009 9:05:25 PM
Andreas Buchinger schrieb:
> Lars Erdmann schrieb:
>> Andreas Buchinger schrieb:
>>> 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
>> My feeling is you are lacking an additional byte for the zero terminator.
> 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.

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





					
	



0
Lars
12/8/2009 7:16:51 PM
Andreas Buchinger schrieb:
 > Lars Erdmann schrieb:
 >> Andreas Buchinger schrieb:
 >>> 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
 >> My feeling is you are lacking an additional byte for the zero 
terminator.
 > 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.

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))
e.cchEditLimit = 512;
e.ichMinSel     = 0;
e.ichMaxSel    = 0;


Lars












0
Lars
12/8/2009 7:18:57 PM
Lars Erdmann schrieb:
> Andreas Buchinger schrieb:
>  > Lars Erdmann schrieb:
>  >> Andreas Buchinger schrieb:
>  >>> 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
>  >> My feeling is you are lacking an additional byte for the zero 
> terminator.
>  > 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.
> 
> 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))
> e.cchEditLimit = 512;
> e.ichMinSel     = 0;
> e.ichMaxSel    = 0;
> 
> 
> Lars
> 
> 
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
0
Andreas
12/9/2009 8:07:12 PM
Steven Levine schrieb:
> On Mon, 7 Dec 2009 18:02:56 UTC, Andreas Buchinger <andi.b@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
Andreas
12/15/2009 8:41:54 PM
Reply: