Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

Newbie questions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
On The Corner - 23 Mar 2005 12:07 GMT
Hi,
I'm a total VC++.NET newbie and I'm stuck with a couple of
stupid problems.
- I have a filled ListView. I'd like to select(or focus)
an Item from code, but I can't find a way to do it. I
can't find an Index property (or something like that)
which allows to be set.

- In a TextBox, when the event KeyDown is triggered, is
there a way to set the returned KeyCode. For example, when
the key 'K' is pressed, I'd like to put the 'H' char in
the TextBox.

I know these questions are quite stupid, but I've spent
all morning browsing the MSDN without finding anything !!!
Thanks in advance for your help !
Nishant Sivakumar - 23 Mar 2005 13:52 GMT
To select an item :- SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);

Index property :- See GetFirstSelectedItemPosition/GetNextSelectedItem in
MSDN

Handling character entry in TextBox :- Override PreTranslateMessage and
handle WM_CHAR in your CEdit derived class

Signature

Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com

> Hi,
> I'm a total VC++.NET newbie and I'm stuck with a couple of
[quoted text clipped - 12 lines]
> all morning browsing the MSDN without finding anything !!!
> Thanks in advance for your help !
On The Corner - 23 Mar 2005 16:15 GMT
Thank you for your help but I'm not using MFC but the .NET
framework.

>-----Original Message-----
>To select an item :- SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
[quoted text clipped - 4 lines]
>Handling character entry in TextBox :- Override PreTranslateMessage and
>handle WM_CHAR in your CEdit derived class
Fred Hebert - 23 Mar 2005 20:01 GMT
Take a look at the KeyPress event of the edit control.  In the help it is
listed as "Control.KeyPress Event".
Micus - 23 Mar 2005 23:55 GMT
> Hi,
> I'm a total VC++.NET newbie and I'm stuck with a couple of
[quoted text clipped - 8 lines]
> the key 'K' is pressed, I'd like to put the 'H' char in
> the TextBox.

I have not done this in a while, but you want to subclass the control. Use
the SetWindowLong() to substitute your own WndProc for the control.
Something like below :

WNDPROC oldEditProc; // to hold old edit control WndProc

LRESULT CALLBACK NewWndProc(HWND, UINT, WPARAM, LPARAM) //New WndProc for
control
{
   ... //handle WM_CHAR and replace wparam(?) with the character you want.
   ...
    return CallWindowProc(oldEditProc, hwnd, msg, wParam, lParam);
}

oldWndProc = (WNDPROC) SetWindowLong(hwndEditControl, GWL_WNDPROC, (LONG)
NewWndProc); //replace WndProc for control in WM_CREATE of parent window

HTH,
M

> I know these questions are quite stupid, but I've spent
> all morning browsing the MSDN without finding anything !!!
> Thanks in advance for your help !

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.