📄 wpw_wapi_ctrl_95.html
字号:
> UpdateWindow(hdc);
> dwBackColor = SetBkColor(hdc,RGB(0,0,0));
> ReleaseDC( hOurDlg, hdc);
>
You need to respond to the WM_CTLCOLOR message in order to do this. Every control sends its parent (usually a dialog
box) this message when it comes time to paint. wParam is the DC of the control, HIWORD(lParam) is the type of the control
and LOWORD(lParam) is the window handle of the control. In response to WM_CTLCOLOR you can check HIWORD(lParam) to see if
this is the control type who's color you want to change then just call SetBkColor((HDC)wParam, RGB(0,0,0)), however, this
will only change the color of the text and not the windows color (you will get text surrounded by black in a white window).
If you also want to change the windows color you must return a handle to a brush. A short example:
case WM_CTLCOLOR
if ( CTLCOLOR_EDIT == HIWORD(lParam) )
{
SetTextColor((HDC)wParam, RGB(255,255,255));
SetBkColor((HDC)wParam, RGB(0, 0, 0));
return hbrBlackBrush;
}
return 0;
This code will change all edit controls in the dialog box to white text on black background in black windows.
---------------------------------------------------------------------
Donald K. Forbes e-mail: don@mythos.com
_ _ ____ ___ ___ ___ ___ ___ ____ ___ ___ ___
/ / //__/ / /__// //__ /__ / //__ / / //__/ /__/ /__
/ / / / / //__/___/ ___//__// / /_/_// / / \ /___
"My opinions are mine and not necessarily that of my employer"
---------------------------------------------------------------------
</PRE>
<HR><A NAME=WINAPI_DROPDOWN_EDIT>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Editing the dropdown combo control.</H4><PRE>
Hi,
I want to process a <CR> when entered in a CComboBox edit control
I have a CComboBox with the style DROPDOWN.
I can enter numbers into the edit control and can get
a message with CBN_EDITUPDATE and CBN_EDITCHANGE
but when I hit <Enter> I don't get a message?
How do you processes the case when a user types "80<enter>"
I have tried CBN_?, the loose focus message (my notes are at home.
any hints would be appreciated
thank you
--
Mark Gregory, Course Leader m.gregory@rmit.edu.au
PH+61 3 6603243 FAX+61 3 6621060 http://www.co.rmit.edu.au
Department of Communication and Electronic Engineering,
Royal Melbourne Institute of Technology, Melbourne, Australia
<HR>
On 26 Jun 1995 07:39:14 GMT, rcomg@cse.rmit.EDU.AU (Mark Gregory) said in article <3slo72$hg9@aggedor.rmit.EDU.AU>:
>
>
>Hi,
>
>I want to process a <CR> when entered in a CComboBox edit control
You'll have to add processing for the default button in the dialog box. If
you have no default button, you'll get a WM_COMMAND/IDOK message.
Unfortunately, the combobox will never lose focus.
--
Robert Mashlan R2M Software Company Programmer for Hire
mailto:rmashlan@r2m.com http://www.csn.net/~rmashlan PGP key available
Resources for Windows Developers - http://www.csn.net/~rmashlan/windev
Windows Developers FAQ - http://www.csn.net/~rmashlan/win-developer-FAQ
</PRE>
<HR><A NAME=WINAPI_Combox_listControl>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Use Combo list control.</H4><PRE>
Hi!
NetNinja (netninja@svpal.org) wrote:
: Alexander Kurakin <kurakin@oea.ihep.su> wrote:
: >Hi, All!
: >I want to get hexadecimal input by my ComboBox, but I don't know how can I
: >do it?! I have not books to explain this problem. Simple example, please.
: char MyString [ 80 ] ;
: unsigned MyHexNumber ;
: GetDlgItemText ( hMyDialog, MyComboID, MyString, sizeof(MyString) ) ;
: MyHexNumber = (unsigned) strtol ( MyString, 0, 16 ) ;
O'k. Thanks for your advice but my problem is that that I just can't
to get a string from my ComboBox. I don't know how I must to build my
program to use Combo. I try to get a string from edit control window of
ComboBox and then add it into the listbox of it. I sent different
messages to ComboBox but all of my tries to do this operations was wrong.
I made a ComboBox function by MAkeProcInstance procedure to try to intercept
the WM_KEYDOWN/VK_RETURN messages in it but I get nothing! I try to send
WM_COMMAND message to the parent window but it was wrong too.
I don't know where was I wrong? Any simple example, please.
Best regards,
Alex
<HR>
In article <199506301502.kurakin@dxunk2.oea.ihep.su> kurakin@oea.ihep.su writes:
>Hi!
>NetNinja (netninja@svpal.org) wrote:
>: Alexander Kurakin <kurakin@oea.ihep.su> wrote:
>
>: >Hi, All!
>: >I want to get hexadecimal input by my ComboBox, but I don't know how can I
>: >do it?! I have not books to explain this problem. Simple example, please.
>
>: char MyString [ 80 ] ;
>: unsigned MyHexNumber ;
>
>: GetDlgItemText ( hMyDialog, MyComboID, MyString, sizeof(MyString) ) ;
>: MyHexNumber = (unsigned) strtol ( MyString, 0, 16 ) ;
>
>O'k. Thanks for your advice but my problem is that that I just can't
>to get a string from my ComboBox. I don't know how I must to build my
>program to use Combo. I try to get a string from edit control window of
>ComboBox and then add it into the listbox of it. I sent different
>messages to ComboBox but all of my tries to do this operations was wrong.
>I made a ComboBox function by MAkeProcInstance procedure to try to intercept
>the WM_KEYDOWN/VK_RETURN messages in it but I get nothing! I try to send
>WM_COMMAND message to the parent window but it was wrong too.
>I don't know where was I wrong? Any simple example, please.
Well, you've really got me confused now. You definitely don't
want to post WM_COMMAND messages to the parent. Doesn't
GetDlgItemText() retrieve the string properly? You can add a
string to the combobox simply by sending it CB_ADDSTRING. Doesn't
that work? What is the CBS_... style of your combobox? Perhaps
you post some code fragments so we can see what you're trying
to do.
--
John A. Grant jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa
</PRE>
<HR><A NAME=WINAPI_BN_CLICK>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Sending the BN_CLICK message.</H4><PRE>
In article <3to36s$1i6@cello.gina.calstate.edu> Zeke Rogers writes:
> Xref: mozart.unx.sas.com comp.os.ms-windows.programmer.misc:67069
> Path: mozart.unx.sas.com!sas!redstone.interpath.net!news.sprintlink.net!cs.utexas.edu!usc!nic-nac.CSU.net!cello.gina.calstate.edu!usenet
> From: Zeke Rogers
> Newsgroups: comp.os.ms-windows.programmer.misc
> Date: 9 Jul 1995 08:15:24 GMT
> Organization: GomerWare
> Lines: 23
> Distribution: world
> NNTP-Posting-Host: 130.150.1.61
> X-Newsreader: <WinQVT/Net v3.9>
>
> I have been trying to create an application that will
> manipulate the objects of other programs. I have ran into problems
> clicking on the push buttons of other applications. I was able to get
> pointers to the buttons, and so I tried this:
>
> RECT coords;
> Button->GetWindowRect(&coords);
> Button->SendMessage(WM_LBUTTONDOWN,0,
> MAKELONG(coords.left+2,coords.top+2));
> Button->SendMessage(WM_LBUTTONUP,0,
> MAKELONG(coords.left+2,coords.top+2));
>
> Where Button is a CWnd* of the button in question. This seemed to
> work fine when I tried it on the Bitmap Buttons of the application
> I was trying to manipulate, but when I tried it on normal push
> buttons, it would give that button the focus, but would not push it.
>
> I figured that there should be a way to activate the BN_CLICKED
> function of the button, but was not sure how. I tried:
>
> Button->SendMessage(BN_CLICKED);
>
> but this didn't seem to work either...
BN_CLICKED is a Button Notification message sent by the child button to
its parent. There is no CALLBACK function in a button for BN_CLICKED.
--
Bryan Boone SAS Institute Inc.
sasbeb@unx.sas.com SAS Campus Drive
(919) 677-8000 x6039 Cary, NC 27513
__________________________________________________________
__________________________________________________________
</PRE>
<HR><A NAME=WINAPI_EDIT_SETFONT>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: How to set the font on edit control?</H4><PRE>
Uwe Hauck <hauck> wrote:
>hello !
>I want to implement a Editfield with much smaller fonts (maybe even
>user definable ones) instead of the standard size. But how do I implement
>this ??
I tried to send this via e-mail, but my mailer choked on your address.
WM_SETFONT
wParam = (WPARAM) hfont; /* handle of the font
*/
lParam = (LPARAM) MAKELONG((WORD) fRedraw, 0); /* redraw flag
*/
An application sends the WM_SETFONT message to specify the font that
a control is to use when drawing
For more details, look in the Win API help file.
DC
<HR>
In article <3u5kuu$1mp8@kaa.heidelbg.ibm.com> hauck "Uwe Hauck" writes:
>hello !
>I want to implement a Editfield with much smaller fonts (maybe even
>user definable ones) instead of the standard size. But how do I implement
>this ??
You can change the font used by an EDIT control by sending it
a "WM_SETFONT" message containing the HFONT of the font you want it
to use. The only thing to be careful of is that the font must exist for
the lifetime of the control.
Chris
--
--------------------------------------------------------------------------
| Chris Marriott, Warrington, UK | Author of SkyMap v2 shareware |
| chris@chrism.demon.co.uk | astronomy program for Windows. |
| For more info, see http://www.winternet.com/~jasc/skymap.html |
| Author member of Association of Shareware Professionals (ASP) |
--------------------------------------------------------------------------
</PRE>
<HR><A NAME=WINAPI_EDIT_Select>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Selecting all text in an edit window?</H4><PRE>
In article <3uug73$cc6@news.knoware.nl>
pa3azk@knoware.nl "Marcel M. Eichhorn" writes:
>Hi!
>
>I want to select all text in an edit window and did:
>SendMessage(hWndEdit, WM_SETSEL, 0, -1);
>but nothing happens....
It wouldn't. Try:
SendMessage( hWndEdit, EM_SETSEL, 0, MAKELPARAM(0,-1) );
Chris
--
--------------------------------------------------------------------------
Chris Marriott, Warrington, UK | Author of SkyMap v2 award-winning
chris@chrism.demon.co.uk | shareware Windows planetarium.
For full info, see http://www.execpc.com/~skymap
Author member of Association of Shareware Professionals (ASP)
--------------------------------------------------------------------------
<HR>
"Marcel M. Eichhorn" <pa3azk@knoware.nl> wrote:
>Hi!
>I want to select all text in an edit window and did:
>SendMessage(hWndEdit, WM_SETSEL, 0, -1);
>but nothing happens....
Hmmm....try EM_SETSEL assuming ofcourse that you are
using Win32 because you are using wParam, lParam for
start and end instead of just lParam.
<HR>
jagrant@emr1.emr.ca (John Grant) wrote:
>In article <3uug73$cc6@news.knoware.nl> "Marcel M. Eichhorn" <pa3azk@knoware.nl> writes:
>>Hi!
>>
>>I want to select all text in an edit window and did:
>>SendMessage(hWndEdit, WM_SETSEL, 0, -1);
>>but nothing happens....
> That's because there is no such message. Well, I guess you
> meant EM_SETSEL, to which I reply "did you read the documentation
> or are you just making it up as you go along?"
> Quoting directly from the on-line help:
> "...
> wParam = (WPARAM) (UINT) fScroll; /* flag for caret scrolling */
> lParam = MAKELPARAM(ichStart, ichEnd); /* start and end positions */
> ..."
> So you need to use MAKELPARAM(0,-1) which is definitely not the
> same as -1.
Only in Win16. Win32 requires WPARAM=start, LPARAM=end.
</PRE>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -