Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

a question for erel or agraham or anyone else

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-27-2008, 10:10 AM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default a question for erel or agraham or anyone else

Hi guys.

I have some labels on a panel. I'd like to draw a line around them.

Is there a way to do this in C# for Smartdevice in VS2005?

I see examples on the net for the desktop label - it has a Borderstyle property but alas the humble compact one doesn't.

I've tried using a Graphics object but I get a null reference error. The Graphics object doesn't have a constructor so it won't compile if I instantiate a new one.

any help would be appreciated.

regards, Ricky
Reply With Quote
  #2 (permalink)  
Old 10-27-2008, 11:54 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

You probably need to override the OnPaint event and use the Graphics given to you in the PaintEventArgs. Note however that this is not my area of expertise. Also Google for Custom Controls - there's a lot of info out there.

Code:
protected override void OnPaint(PaintEventArgs e)
{
   base.OnPaint(e); // call the base class OnPaint
   e.Graphics.xxxx; // 
do your own thing;
}
Reply With Quote
  #3 (permalink)  
Old 10-27-2008, 12:42 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

you could use the b4p form.line to draw a rectangle around any control, like this:

Code:
Form1.Line (Label1.Left-1,Label1.Top-1,Label1.Left+Label1.Width+1,Label1.Top+Label1.Height+1,cRed, B) 'Draws an empty red box
in c# you just need to set the label.borderstyle to one of these values:
None - default value
FixedSingle - draws a single-line rectangle around the control.
Fixed3D - Draws a 3d border on the control.
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!

Last edited by Cableguy : 10-27-2008 at 01:06 PM.
Reply With Quote
  #4 (permalink)  
Old 10-27-2008, 02:55 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Cableguy View Post
you could use the b4p form.line to draw a rectangle around any control,
I'm afraid he wants to draw on a Panel!

Quote:
in c# you just need to set the label.borderstyle
In the Compact Framework labels don't have a BorderStyle, as he indicated in his first post, so this is not possible.

You need to remember that there are significant differences (usually, but not always, omissions) between the full Framework on the desktop and the Compact Framework on the device so you can never make assumptions but need to check the documentation.
Reply With Quote
  #5 (permalink)  
Old 10-27-2008, 03:21 PM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

A work-around is to first draw an image and then put the label on top of the image. If the image is just slightly higher up, more to the left, wider and higher then you get the effect you want (I think). See jpg

I know, it isn't very elegant but hey it works

all the best / Björn
Attached Images
File Type: jpg Labels.jpg (3.5 KB, 10 views)
Reply With Quote
  #6 (permalink)  
Old 10-27-2008, 03:25 PM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

Sorry, the example wasn't very clear, see this one instead. / Björn
Attached Images
File Type: jpg labels2.jpg (3.3 KB, 19 views)
Reply With Quote
  #7 (permalink)  
Old 10-27-2008, 04:24 PM
Senior Member
 
Join Date: Apr 2007
Location: Kindred,ND
Posts: 122
Awards Showcase
Beta Tester 
Total Awards: 1
Default

You can draw label with border and save as bmp etc, then load image to image or image button. there are some draw/paint progs here do a search.
Reply With Quote
  #8 (permalink)  
Old 10-28-2008, 06:33 AM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default overriding

hi agraham,

how do I override the onpaint event for each individual label?

would it be

protected override void la_OnPaint(PaintEventArgs e)

where la is the label?

regards, Ricky
Reply With Quote
  #9 (permalink)  
Old 10-28-2008, 08:56 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

No, you are mapping B4ppc concepts onto C# and it doesn't work like that. You need to create your own label class inheriting from Label (called subclassing), do it in there, and then use instances of your own Label class instead of Label. You could also do it by subclassing Panel and overriding its OnPaint method You are entering a large world here and I can't walk you through it and Windows Forms programming it is not my area of expertise anyway. You will have to do your own research, there is much to learn.

If you Google there are a lot of tutorials out there on the Web and you may need a couple of good books as well.
Reply With Quote
  #10 (permalink)  
Old 10-28-2008, 09:11 AM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default ok mate, thanks

I have come across some stuff on the net.

I'll see how I go.

regards, Ricky
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
question for erel re hardware library Ricky D Questions (Windows Mobile) 0 10-30-2008 06:59 AM
a question for Erel Ricky D Questions (Windows Mobile) 2 10-24-2008 06:06 AM
a question for agraham Ricky D Questions (Windows Mobile) 21 10-19-2008 04:38 PM
Library folder question to Erel agraham Questions (Windows Mobile) 6 11-11-2007 04:27 PM
I vote for agraham! dzt Chit Chat 7 10-26-2007 06:47 PM


All times are GMT. The time now is 03:01 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0