Tech Support > Microsoft Windows > Development Resources > Re: CComboBox Cursor Pos
Re: CComboBox Cursor Pos
Posted by Gernot Frisch on July 29th, 2003



"mik0" <m.wuertinger.donald@t-online.de> schrieb im Newsbeitrag
news:bg3j5r$1mn$02$1@news.t-online.com...

Hi,
first, the 'cursor' is called carret. Cursor is what you move with the
mouse. Anyway.
Try:
GetEditSel() // MFC
or send a CB_GETEDITSEL msg to the window.

// From the MSDN:

SendMessage(
(HWND) hWnd, // handle to destination window
CB_GETEDITSEL, // message to send
(WPARAM) wParam, // starting position (LPDWORD)
(LPARAM) lParam // ending position (LPDWORD)
);
Parameters
wParam
Pointer to a DWORD value that receives the starting position
of the selection. This parameter can be NULL.
lParam
Pointer to a DWORD value that receives the ending position
of the selection. This parameter can be NULL.
Return Values
The return value is a zero-based DWORD value with the starting
position of the selection in the low-order word and with the ending
position of the first character after the last selected character
in the high-order word.

HTH,
-Gernot

In order to reply, revert my forename.

------------------------------
DiNGS Game Basic + ClipChap
http://www.Dream-D-Sign.de








Posted by mik0 on July 29th, 2003


Gernot Frisch wrote:
I already tried GetEditSel() bur it returns 0 for the loword and
hiword... Seeming it's only working when there is a real selection

Is there any other way to get the carret position?


--
To reply by eMail remove the donald from the adress.


Posted by Gernot on July 29th, 2003



VC 6.0:

void CXxDlg::OnEditchangeCombo1()
{
UpdateData();
DWORD dw = m_cbBox.GetEditSel();

m_str.Format("%d %d", LOWORD(dw), HIWORD(dw));
UpdateData(FALSE);
}

This worked pretty good for me!?
-Gernot





Posted by mik0 on July 29th, 2003


Gernot wrote:


I tried everything! But both the lo and hi words are ALWAYS zero, no
matter if there is something selected or not...

wtf is goning on? Any ideas?

--
To reply by eMail remove the donald from the adress.


Posted by Gernot Frisch on July 30th, 2003



"mik0" <m.wuertinger.donald@t-online.de> schrieb im Newsbeitrag
news:bg6kbn$qj4$03$1@news.t-online.com...
As you can see - I use the OnEditchangeCombo function in order to determine
the carret pos. If you pressa button and then read the position, it won't be
there, since the button pressing takes the focus from the CComboBox and thus
removes the carret.
What exactly do you want to archive? Maybe I can write a tiny app and send
it to you? What IDE/compiler do you use?

-Gernot



Posted by mik0 on July 30th, 2003


yeah! it works! i forgot setting the focus to the control before
requesting the selection.

many thx Gernot Frisch!

--
To reply by eMail remove the donald from the adress.


Similar Posts