NO

Author Topic: Various Windows questions  (Read 5747 times)

tpekar

  • Guest
Various Windows questions
« on: July 08, 2011, 09:50:19 PM »
I am relatively new to Windows programming and had some questions about controls.   Such as:

1)  How can I control the number of characters keyed into a Text Box?
2)  How can I make the cursor advance automatically to the next Text Box once the maximum characters are keyed into a Text    Box?
3)  How can I know which Text Box I am currently in?
4)  How can I change the Font of a Text box?
5)  How can I change from insert mode to overstrike mode in a Text Box?
6)  How can I make the down arrow key advance to the next Text Box?

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Various Windows questions
« Reply #1 on: July 08, 2011, 09:56:32 PM »
I think you may start reading Windows Controls at MSDN.

In addition I seem to remember a link to a tutorial about window controls being posted on one of the boards, so searching the forum should reveal it.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

  • Guest
Re: Various Windows questions
« Reply #2 on: July 08, 2011, 10:17:07 PM »
I am relatively new to Windows programming and had some questions about controls.   Such as:

1)  How can I control the number of characters keyed into a Text Box?

Send the EM_LIMITTEXT message to your text box.

Quote
2)  How can I make the cursor advance automatically to the next Text Box once the maximum characters are keyed into a Text    Box?

By processing the EN_MAXTEXT message and calling SetFocus() to the next window.

Quote
3)  How can I know which Text Box I am currently in?

Call GetFocus() 

Quote
4)  How can I change the Font of a Text box?

By sending the WM_SETFONT message to it.

Quote
5)  How can I change from insert mode to overstrike mode in a Text Box?

That should be handled internally by the edit control... by pressing Insert on the keyboard

Quote
6)  How can I make the down arrow key advance to the next Text Box?

Windows standard is TAB for moving between controls, this is handled by the IsDialogMessage() call in your message loop.

No offense is intended, but I'm with Stephen... you really do need to start reading up on this stuff.  I don't mind answering a couple of questions when you're stuck... but all this stuff you're asking about now is very well documented both on MSDN and in the Windows SDK...

If you don't have thw SDK you can get a copy here, it's totally free and it works offline...

http://www.microsoft.com/download/en/details.aspx?id=18950

For x86 you need GRMSDK_ENG_DVD
For x64 you need GRMSDKX_ENG_DVD

Grab the one you need, burn it to a disk and then run the setup program.

Now, not only do you have a full disclosure of everything "Windows", you have a backup disk to reinstall it if you ever need to.
« Last Edit: July 08, 2011, 10:25:49 PM by CommonTater »

CommonTater

  • Guest
Re: Various Windows questions
« Reply #3 on: July 08, 2011, 10:21:54 PM »
I think you may start reading Windows Controls at MSDN.

In addition I seem to remember a link to a tutorial about window controls being posted on one of the boards, so searching the forum should reveal it.

Two of my favorites...

http://www.winprog.org/tutorial/
http://www.catch22.net/tuts/
« Last Edit: July 08, 2011, 10:24:58 PM by CommonTater »

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Various Windows questions
« Reply #4 on: July 08, 2011, 10:31:21 PM »
Two of my favorites...

http://www.winprog.org/tutorial/
http://www.catch22.net/tuts/

Now that you mention it, catch22 has some really good stuff.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

  • Guest
Re: Various Windows questions
« Reply #5 on: July 08, 2011, 10:49:32 PM »
Now that you mention it, catch22 has some really good stuff.

Yep... got alot of realy good stuff from there over the years.

Also including one of my custom controls... EasySplit... But of course the latest version is here :D

tpekar

  • Guest
Re: Various Windows questions
« Reply #6 on: July 15, 2011, 08:27:14 PM »
Thanks for all the help.  I got everything to work except the EN_MAXTEXT to automatically advance to the next field (text control).  I came up with a workaround for it.

CommonTater

  • Guest
Re: Various Windows questions
« Reply #7 on: July 15, 2011, 10:02:03 PM »
Thanks for all the help.  I got everything to work except the EN_MAXTEXT to automatically advance to the next field (text control).  I came up with a workaround for it.

EN_MAXTEXT is pretty simple... when the editor hits the limit set by EM_LIMITTEXT it sends a WM_COMMAND message with it's MenuID (identifier) in the low word of wparam and EN_MAXTEXT in the high word...

Code: [Select]
case : WM_COMMAND
   switch(LOWORD(wparam))
      {  case ID_EDIT1 :
              switch (HIWORD(wparam))
                   {  case EN_MAXTEXT :
                              DoNextEditBox();
                               return 0;