Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trick for use of OnPaint for TextBox/ComboBox on Compact ?

54 views
Skip to first unread message

Mark Johnson

unread,
Mar 19, 2004, 11:00:28 AM3/19/04
to
From what I have found out today there are certain Controls where Windows
does the Painting and an override of OnPaint is not possible.
On Framework.Desktop this can be solved with the use of
"this.SetStyle(ControlStyles.UserPaint,true);",
but this is not supported on Compact.

Is there a workaround/trick to get OnPaint to work without reinventing the
Wheel (rewriting TextBox/ComboBox or whatever other Controls are effected)
?.

All I want to do is to repaint the Border so that it will look more like the
Desktop version (3D Effect).
With my own Controls this works well, but the others .. well ... look very
flat (and boring).

Mark Johnson, Berlin Germany
mj1...@mj10777.de


Alex Feinman [MVP]

unread,
Mar 19, 2004, 11:52:30 AM3/19/04
to
The short answer is - no. Many messages are not routed to the managed level
at all being processed inside unmanaged part of the framework (netcfagl.dll)

--
Alex Feinman
---
Coming to MDC? make sure to stop by the session CLI345
on Thursday for OpenNETCF talk

"Mark Johnson" <mj1...@mj10777.de> wrote in message
news:405b1923$0$10886$9b4e...@newsread2.arcor-online.net...

Tim Wilson

unread,
Mar 19, 2004, 12:58:55 PM3/19/04
to
You could play around with the style bits for the control to give the border
a 3D look.

using System.Runtime.InteropServices;

private const int GWL_EXSTYLE = -20;
private const int WS_EX_WINDOWEDGE = 0x00000100;
private const int WS_EX_CLIENTEDGE = 0x00000200;
private const int SWP_NOSIZE = 0x0001;
private const int SWP_NOMOVE = 0x0002;
private const int SWP_NOZORDER = 0x0004;
private const int SWP_NOACTIVATE = 0x0010;
private const int SWP_FRAMECHANGED = 0x0020;

[DllImport("coredll")]
private static extern IntPtr GetCapture();

[DllImport("coredll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

[DllImport("coredll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
dwNewLong);

[DllImport("coredll")]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
int X, int Y, int cx, int cy, int uFlags);

private void ChangeBorder(Control ctrl)
{
IntPtr hWnd;
int exStyle;
// Get handle.
ctrl.Capture = true;
hWnd = GetCapture();
ctrl.Capture = false;
// Change border.
exStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
SetWindowLong(hWnd, GWL_EXSTYLE, (exStyle | WS_EX_CLIENTEDGE));
// Refresh
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE
| SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}

--
Tim Wilson
.Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}


"Mark Johnson" <mj1...@mj10777.de> wrote in message
news:405b1923$0$10886$9b4e...@newsread2.arcor-online.net...

Katie Schaeffer [MSFT]

unread,
Mar 19, 2004, 11:08:47 PM3/19/04
to
Hi Mark,

Just to let you know, Textbox.BorderStyle is being considered for future
releases.

Tim's suggestion of using SetWindowLong is your best workaround - be
careful as changing some Textbox properties can cause the window to get
re-created (and your 3d border may not be re-applied).

-Katie

This posting is provided "AS IS" with no warranties, and confers no rights.

***.Net Compact Framework Info***
Faq:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.a
spx
QuickStarts: http://samples.gotdotnet.com/quickstart/CompactFramework/
Samples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/h
tml/CompactfxTechArt.asp

--------------------
| From: "Mark Johnson" <mj1...@mj10777.de>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Trick for use of OnPaint for TextBox/ComboBox on Compact ?
| Date: Fri, 19 Mar 2004 17:00:28 +0100
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Lines: 19
| Message-ID: <405b1923$0$10886$9b4e...@newsread2.arcor-online.net>
| Organization: Arcor
| NNTP-Posting-Date: 19 Mar 2004 17:00:36 MET
| NNTP-Posting-Host: 213.23.129.58
| X-Trace:
DXC=N=D:YX:0W\4gL1_>^S7Mi=Q5U85hF6f;4jW\KbG]kaM8liQbn6H@_E9]^hGU23DeG;KgWG2b
RR9h>7U1[1X5OoS51`b<7INc^j0
| X-Complaints-To: ab...@arcor-online.net
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXS01.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!
newsfeed.arcor-online.net!newsread.arcor-online.net!news.arcor.de!not-for-ma
il
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:49027
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

0 new messages