questions about win32 control

This is a discussion on questions about win32 control within the Windows Programming forums, part of the Platform Specific Boards category; I use Dev-C++ with platform SDK. I have few details to make my program easier to use: 1. With singleline ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    5

    Question questions about win32 control

    I use Dev-C++ with platform SDK. I have few details to make my program easier to use:

    1. With singleline editbox how I can use return key so that it push button?

    2. With listbox I have problem that when I refocus listbox cursor of listbox jump in the begining of listbox. I want to keep the cursor in same position than before.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    1. With singleline editbox how I can use return key so that it push button?
    You have to subclass the edit control using SetWindowLongPtr, and assign a new window procedure function. Then you can handle the WM_KEYDOWN message to catch VK_RETURN, and then do whatever sort of handling you want.

    With listbox I have problem that when I refocus listbox cursor of listbox jump in the begining of listbox. I want to keep the cursor in same position than before.
    I've never heard of this sort of thing happening. There must be something fishy with your code that is causing this to happen.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Quote Originally Posted by bithub
    You have to subclass the edit control using SetWindowLongPtr, and assign a new window procedure function. Then you can handle the WM_KEYDOWN message to catch VK_RETURN, and then do whatever sort of handling you want.
    Shouldn't be necessary. Dialog boxes do without that; it's special handling from IsDialogMessage(), I think. So if you give your window the WS_EX_DIALOGPARENT (or something like that) style and include a IsDialogMessage() in your message loop, you should get this behaviour. "This behaviour" being activation of the default button upon pressing enter.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Jan 2006
    Posts
    5
    I probably know what cause 2. I upgrade listbox everytime it catch focus. So now I need also move pointer to back in old position aafter upgrade, but how??

    bithub: Do I use PostMessage or SendMessage? I'm not sure how handle message sending in this kind of situation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 06:49 PM
  2. Basic Win32 Service Control Code
    By The Dog in forum Windows Programming
    Replies: 4
    Last Post: 09-08-2006, 02:00 AM
  3. Edit Control Questions
    By Jaken Veina in forum Windows Programming
    Replies: 2
    Last Post: 04-18-2005, 06:34 PM
  4. Few Questions (Styles, Static Control)
    By Zeusbwr in forum Windows Programming
    Replies: 11
    Last Post: 04-15-2005, 05:13 AM
  5. Updating Static Control Color Real-Time :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-29-2002, 04:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21