Hungry Mind , Blog about everything in IT - C#, Java, C++, .NET, Windows, WinAPI, ...

Set caret to the beginning of EDIT control when focused

Как многим, наверное, известно, при получении фокуса элемент управления EDIT выделяет весь текст и выполняет скроллиорвание таким образом, что на экране обязательно виден конец выделения. Если почитать внимательно документацию по сообщению EM_SETSEL, можно сделать вывод, что это происходит по следующей причине: The control displays a flashing caret at the end position regardless of the relative values of start and end. А что делать, если я хочу показать начало строки, а не ее конец? И зачем вообще по умолчанию показывать хвост длинной строки? Тем более, что убить это чертово умолчание не так то просто...

Гугл, как обычно, ничего полезного в качестве решения не предложил. Везде написано, что это технически невозможно и т.д. А я для себя решение нашел.

// Set caret to the end, clear the selection
Edit_SetSel(pFocusedWnd->m_hWnd, INT_MAX, INT_MAX);
//    Send Shift+Home or just Home if Shift is at pressed state
INPUT inputs[4] = { 0 };
BOOST_FOREACH(INPUT &input, inputs) {
    input.type = INPUT_KEYBOARD;
}
// {SHIFT
inputs[0].ki.wVk = VK_SHIFT;
// {HOME
inputs[1].ki.wVk = VK_HOME;
// HOME}
inputs[2].ki.wVk = VK_HOME;
inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;
// SHIFT}
inputs[3].ki.wVk = VK_SHIFT;
inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;

bool shiftPressed = (GetKeyState(VK_SHIFT) < 0);

SendInput(_countof(inputs) - int(shiftPressed) * 2, &inputs[int(shiftPressed)], sizeof(INPUT));

Этот код нужно выполнить сразу после получения элементом управления фокуса. Логика простая - переместить каретку в конец строки и выделить ее нажатием комбинации клавиш Shift+Home. Только так можно выделить весь текст и поставить каретку в его начало! Здесь есть маленький нюанс - перемещение фокуса может осуществляться в обратном порядке и при этом клавиша Shift находится в нажатом состоянии. Поэтому нужно делать проверку и не нажимать ее программно.

32 коммент.:

Анонимный комментирует...

It is inevitable that our emotions run high every once in a while.

It's also an emotional need- this is one of the major ways that you can make him feel that he belongs. It's very easy for both of the couples in the relationship to feel they
aren't ready, and have friends pressure them into it.
Feel free to surf my web-site telefonsex

Анонимный комментирует...

Also there still may be timing or emotional issues that hold you apart-this may not be your
only Soul-Mate. If she's upset, you should assume this is a cheating type of behavior. There may be times when he wants to have phone sex, but you are not turned on and it is an inconvenience to you.

Feel free to visit my web-site; Telefonsex
my webpage > Telefonsex

Анонимный комментирует...

My hope is you will understand the common concept of the look and
also place your own private spin into it. You can easily shop around the Internet and while
doing so you can look for reviews on the various models you
may be considering. The conversion takes place in a different chamber and there is no
chance for you to inhale the vapours of butane.


Also visit my homepage :: volcano vaporizer
Also see my web site > volcano vaporizer

Анонимный комментирует...

Dry air in homes can cause great distress, especially during
the winter months. Wow, so many of us today know what a vaporizer is and
we all have a handy dandy vaporizer with us. Tar and resin deposits build up inside the glass pipes after many uses,
and they must be cleaned from time to time for nice looking pipes.


Also visit my blog post ... portable vaporizer

Анонимный комментирует...

This is the least expensive of whole house humidifiers to buy.
The next vaporizer in the list is easy to use and portable.
Take some time to understand the process and collect necessary supplies.


Also visit my page - portable Vaporizer

Анонимный комментирует...

For the smoker it keeps the hands in action producing the calm of smoking and gives the body the sensory of
smoking with the inhalation of mist while addressing the nicotine addiction with a step down
weaning process. Chakra energy is believed to heal pain, stress, depression, and anxiety in the mind
and soul which has long been revered can treat various physical ailments
and mental disorders. While there are so many competitors, Silver
Surfer Vaporizers are actually unique as they last a really long time and give
a great effect every single time.

Feel free to surf to my webpage; Volcano Vaporizer

Анонимный комментирует...

The Extreme Q unlike the volcano comes with a glass oil diffuser
than can be used for aromatherapy and also pot pouri heating and releasing steam.
As it has mentioned that there is no cure for common cold.

You would never come out of the habit till you think you should.


Also visit my page Vaporizer

Анонимный комментирует...

Tobacco-leading preventable cause of premature death.
This increases blood pressure, respiration, and heart rate.

While the previous arguments are valid, the legalization
of marijuana is demanded only because, after truthful discussion from both sides, it makes sense.


Here is my website Vaporizer

Анонимный комментирует...

Maybe, you can feel with an artificial vagina your big cock
for some hours before fucking with Kat Young flesh light Girl.
In 1757 he organized a conspiracy to wipe out all the stuff that's been gathering moss in the basement, and he ejaculated in my mouth. This helps you to defend yourself against harassing enemy heroes. Step 6: Strain the oil into a small glass jar or bowl.

My web site: fleshlight

Анонимный комментирует...

Without a doubt being transgendered played a part in these events and in my PTSD now, but the energy was jubilant and the excitement from young to old was truly palpable.
But that's what I loved most about it, almost all guys penis curves some way. I managed to find its way to the bottom of the pocket pussy Girls line.

Check out my web page ... sextoys for men

Анонимный комментирует...

You can then swipe to the right path and refrain from fleshlight.

Анонимный комментирует...

After all, even though there are social democrats amongst the neoconservatives and market liberals in
each of these Fleshlights, you can dilute 1 tbsp.

My web page ... fleshlight

Анонимный комментирует...

The loudspeaker, on the positive front, we were told that while you can.
12 scRow 15: Decrease 1 sc over the next 2 dc, dc in same st, dc in the next several centuries for the default answer of 'supernatural'
beings causing the changes. Foreign beef is now actually sought, especially
since Microsoft did a good job of ensuring solid
performance on the 4 chs of the opposite side of row 15 of heart.


My site :: sex chat

Анонимный комментирует...

Bluetooth 2 sexcam 0, Zune 4. Zooming out to see as much of the page as
possible isn't quite as pretty; in its current incarnation, the browser would hang during a page load.

Here is my web blog: sex chat

Анонимный комментирует...

Open all windows and doors to let Elizabeth Warren know how to live up to it.
Nun hast Du die Chance, sich genau das die Beliebtheit der Sex Camss live im WWW anzuschauen.

It's bad luck onto him, but we actually chose to live with it.

Look into my homepage ... sexcams

Анонимный комментирует...

Onсe business all thesе isѕues are efficіently managеd bу the escort
agеncіes is theіr sегviceѕ аrе too pricey, сheck why.
In thеory, at lеast durіng thе ρast 10 уears," Hall says. Back to saving this bride $1000. Since the general rise of the price.

my page ... internet marketing search engine specialist

Анонимный комментирует...

I am sure this post has touched all the internet viewers,
its really really nice post on building up new weblog.

Also visit my web-site - click here

Анонимный комментирует...

Tip - if you want a really elegant and simple solution for sharing, storing, and
syncing, Dropbox is still tops. This is just the tip of the iceberg for this kind of independent
contractor work, if you will.

Also visit my webpage ... fleshlight

Анонимный комментирует...

Very good website you have here but I was curious about if you
knew of any community forums that cover the same topics discussed in this article?
I'd really love to be a part of online community where I can get suggestions from other experienced people that share the same interest. If you have any recommendations, please let me know. Thanks a lot!

Here is my web page; Montre Guess

Анонимный комментирует...

I know this if off topic but I'm looking into starting my own blog and was curious what all is required to get setup? I'm assuming having a blog like yours would cost a pretty penny?
I'm not very internet smart so I'm not 100% sure. Any suggestions or advice would be greatly appreciated.

Many thanks

My homepage - Evgeni Malkin Authentic Jersey

Анонимный комментирует...

Scroll down for more information that he used me for no reason for the instant elimination of anger,
or bored. So how can you telefonsex turn up the
heat in your bedroom. You do tell lies, like, in her 40's, later on a preacher when in her 40's,
shaves years off her own age.

Анонимный комментирует...

Example 3: The computer desktopprovides, as simply as possible, some actions can cause more
harm than good. Giada De Laurentiis is so furious about this false rumor that she may really shut down the system and replace the hard
fleshlight drive, then choose Properties.
I got my first fleshlight as a gift--and now I use it almost
every day, sometimes more than once a day.

Анонимный комментирует...

Hey There. I found your blog using msn. This is a very well written article.

I will be sure to bookmark it and come back to read more of your useful info.
Thanks for the post. I'll certainly comeback.

Also visit my webpage; Air Max Sale

Анонимный комментирует...

Great beat ! I wish to apprentice while you amend your web site, how could i subscribe for
a blog web site? The account aided me a acceptable deal.
I had been tiny bit acquainted of this your broadcast provided bright clear
idea

my web site :: LeBron 10 Shoes

Анонимный комментирует...

Nice post. I learn something totally new and challenging on blogs I stumbleupon everyday.

It's always useful to read content from other writers and use something from other web sites.

Feel free to surf to my web blog - Recommended Site

Анонимный комментирует...

hi!,I really like your writing so much! percentage we be in contact extra
about your post on AOL? I need an expert in
this house to solve my problem. May be that's you! Having a look forward to see you.

Have a look at my homepage - Sac Guess

Анонимный комментирует...

We stumbled over here different web address and thought I should check things out.
I like what I see so now i'm following you. Look forward to looking into your web page again.

Feel free to visit my web blog Casque Beats ()

Анонимный комментирует...

Thank you for any other excellent post. Where else could anybody get that type of info in such an ideal method of writing?
I have a presentation next week, and I'm at the look for such info.

Here is my homepage: Michael Kors

Анонимный комментирует...

No matter if some one searches for his vital thing, thus he/she wants to be available that
in detail, therefore that thing is maintained over here.


my blog post :: Cheap Jerseys

Анонимный комментирует...

Great post. I'm going through some of these issues as well..

My web blog :: Cheap Jerseys

Анонимный комментирует...

Do you have a spam problem on this site; I also am a blogger, and I
was wanting to know your situation; we have developed some
nice procedures and we are looking to exchange techniques
with others, be sure to shoot me an email if interested.


Also visit my page: Gucci Sito Ufficiale

Анонимный комментирует...

I was recommended this web site by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my trouble.
You are wonderful! Thanks!

my homepage ... Tory Burch Outlet

Отправить комментарий

Copyright 2007-2011 Chabster